-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
72 lines (57 loc) · 2.25 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
let today = new Date();
const currentDateElement = document.getElementById('currentDate');
const currentDateMinusButtonElement = document.getElementById(
'currentDateMinusButton'
);
const currentDatePlusButtonElement = document.getElementById(
'currentDatePlusButton'
);
currentDateElement.innerHTML = formattedDate(today);
currentDateMinusButtonElement.addEventListener('click', () => {
let yesterday = new Date();
yesterday.setDate(today.getDate() - 1);
today = yesterday;
currentDateElement.innerHTML = formattedDate(today);
});
currentDatePlusButtonElement.addEventListener('click', () => {
let tomorrow = new Date();
tomorrow.setDate(today.getDate() + 1);
today = tomorrow;
currentDateElement.innerHTML = formattedDate(today);
});
function formattedDate(date) {
return (
date.getDate() + '.' + (date.getMonth() + 1) + '.' + date.getFullYear()
);
}
//-----------------------------------------
const abgabenPlusButtonElement = document.getElementById('abgabenPlusButton');
const abgabenMinusButtonElement = document.getElementById('abgabenMinusButton');
const abgabenCounterElement = document.getElementById('abgabenCounter');
function increaseAbgaben() {
abgabenCounterElement.innerHTML =
parseInt(abgabenCounterElement.textContent) + 1;
}
function decreaseAbgaben() {
if (parseInt(abgabenCounterElement.textContent) > 0) {
abgabenCounterElement.innerHTML =
parseInt(abgabenCounterElement.textContent) - 1;
}
}
abgabenPlusButtonElement.addEventListener('click', increaseAbgaben);
abgabenMinusButtonElement.addEventListener('click', decreaseAbgaben);
//-----------------------------------------
const videoPlusButtonElement = document.getElementById('videoPlusButton');
const videoMinusButtonElement = document.getElementById('videoMinusButton');
const videoCounterElement = document.getElementById('videoCounter');
function increaseVideo() {
videoCounterElement.innerHTML = parseInt(videoCounterElement.textContent) + 1;
}
function decreaseVideo() {
if (parseInt(videoCounterElement.textContent) > 0) {
videoCounterElement.innerHTML =
parseInt(videoCounterElement.textContent) - 1;
}
}
videoPlusButtonElement.addEventListener('click', increaseVideo);
videoMinusButtonElement.addEventListener('click', decreaseVideo);