-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
86 lines (62 loc) · 2.62 KB
/
script.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
function setTime() {
const clockElement = document.getElementById('clock');
const now = new Date();
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
clockElement.innerHTML = `${hours}<span class="blinking">${':'}</span>${minutes}`;
}
setInterval(setTime, 1000);
setTime();
if ('serviceWorker' in navigator){
navigator.serviceWorker.register('/sw.js');
}
let colorInput = document.getElementById('colorInput');
colorInput.addEventListener('input', () =>{
document.body.style.backgroundColor = colorInput.value;
});
let changingFontStyle = function (fontstyle) {
document.getElementById("clock").style.fontFamily = fontstyle.value;
}
document.getElementById("settings-icon").addEventListener("click", function() {
this.classList.toggle("rotated"); // Toggle the rotation class
});
const toggleButton = document.getElementsByClassName('toggle-button')[0]
const navbarLinks = document.getElementsByClassName('navbar-links')[0]
toggleButton.addEventListener('click', () => {
navbarLinks.classList.toggle('active')
})
const linkAbout = document.getElementsByClassName('linkAbout')[0]
const toggleH1 = document.getElementsByClassName('toggleH1')[0]
linkAbout.addEventListener('click', () => {
toggleH1.classList.toggle('active')
})
// Function to change the text color based on the selected color
function changeTextColor() {
const textElement = document.getElementById('clock');
const colorPicker = document.getElementById('colorPicker');
textElement.style.color = colorPicker.value;
}
// Add event listener to the color picker
document.getElementById('colorPicker').addEventListener('input', changeTextColor);
//font size slider
document.getElementById('slider').addEventListener('input', function() {
document.getElementById('clock').style.fontSize = this.value + 'px';
});
// background Image Picker
const filePicker = document.getElementById('filePicker');
const resetButton = document.getElementById('resetButton');
filePicker.addEventListener('change', (event) => {
const file = event.target.files[0];
if (file) {
const reader = new FileReader();
// Read the selected image file
reader.onload = (e) => {
document.body.style.backgroundImage = `url(${e.target.result})`;
};
reader.readAsDataURL(file);
}
});
resetButton.addEventListener('click', () => {
document.body.style.backgroundImage = "";
filePicker.value = ""; // Reset the file input
});