-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
49 lines (40 loc) · 1.43 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
const beforeSide = document.querySelector('#before');
const afterSide = document.querySelector('#after');
const btns = document.querySelectorAll('button');
const dayZeroBtn = document.querySelector('#dayZeroBtn');
const dDayBtn = document.querySelector('#dDayBtn');
const obamaBtn = document.querySelector('#obamaBtn');
const dDayLink = 'https://web.archive.org/web/20170119230156/http://whitehouse.gov'
const zeroLink = 'https://web.archive.org/web/20090120204553/http://www.whitehouse.gov/'
const trumpLink = 'https://web.archive.org/web/20170120205436/http://whitehouse.gov'
function getDayZero(e) {
console.log('getting day Zero...')
e.preventDefault();
beforeSide.src = zeroLink;
if (afterSide.src != trumpLink) {
afterSide.src = trumpLink;
}
}
function getDDay(e) {
console.log('getting Transition...')
e.preventDefault();
beforeSide.src = dDayLink;
if (afterSide.src != trumpLink) {
afterSide.src = trumpLink;
}
}
function getStartFinish(e) {
console.log("getting Obama's Start to Finish...")
e.preventDefault();
beforeSide.src = zeroLink;
afterSide.src = dDayLink;
}
function toggleActive(e) {
console.log(e);
btns.forEach(btn => btn.classList.remove('active'));
this.classList.toggle('active');
}
dayZeroBtn.addEventListener('click', getDayZero);
dDayBtn.addEventListener('click', getDDay);
obamaBtn.addEventListener('click', getStartFinish);
btns.forEach(btn => btn.addEventListener('click', toggleActive));