-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
80 lines (53 loc) · 1.75 KB
/
script.js
File metadata and controls
80 lines (53 loc) · 1.75 KB
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
function getData(){
var date = new Date();
var day = date.getDate();
var month = date.getMonth()+1;
const app = document.getElementById('root')
const container = document.createElement('div')
container.setAttribute('class', 'container')
app.appendChild(container)
var request = new XMLHttpRequest()
request.open('GET', 'https://byabbe.se/on-this-day/'+month+'/'+day+'/events.json', true);
request.onload = function() {
// Begin accessing JSON data here
var data = JSON.parse(this.response)
var fulldate = data.date;
/*var circuits = data.MRData.CircuitTable.Circuits;*/
console.log(data);
var events = data.events;
if (request.status >= 200 && request.status < 400) {
$('#fixed').css("display","block");
$('#fixed').text(fulldate);
events.forEach(events => {
const card = document.createElement('div')
card.setAttribute('class', 'card')
container.appendChild(card)
const p1 = document.createElement('p')
p1.textContent = events.description;
const h3 = document.createElement('h5')
h3.textContent = "Year "+events.year;
container.appendChild(card)
card.appendChild(h3)
card.appendChild(p1)
})
} else {
console.log('error')
}
}
request.send()
}
$(document).ready(function () {
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('.scrollup').fadeIn();
} else {
$('.scrollup').fadeOut();
}
});
$('.scrollup').click(function () {
$("html, body").animate({
scrollTop: 0
}, 200);
return false;
});
})