-
Notifications
You must be signed in to change notification settings - Fork 0
/
homebackscript.js
35 lines (30 loc) · 1.09 KB
/
homebackscript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
document.addEventListener('DOMContentLoaded', function() {
const settingsPage = `
<h1>Instellingen</h1>
<label for="image-url">Afbeelding URL:</label>
<input type="text" id="image-url">
<button onclick="saveSettings()">Opslaan</button>
`;
const mainPage = `
<h1>Instellingen</h1>
<div class="background"></div>
`;
const saveSettings = function() {
const imageUrl = document.getElementById('image-url').value;
localStorage.setItem('background-image-url', imageUrl);
alert('Instellingen opgeslagen!');
loadMainPage();
};
const loadMainPage = function() {
const imageUrl = localStorage.getItem('background-image-url');
const backgroundDiv = document.querySelector('.background');
if (imageUrl) {
backgroundDiv.style.backgroundImage = `url(${imageUrl})`;
} else {
backgroundDiv.style.backgroundImage = 'none';
}
};
document.body.innerHTML = settingsPage;
window.saveSettings = saveSettings;
window.loadMainPage = loadMainPage;
});