-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
64 lines (57 loc) · 1.59 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
function loadJSONFile(file, callback) {
var client = new XMLHttpRequest();
client.open('GET', file);
client.onreadystatechange = function() {
if (client.readyState === XMLHttpRequest.DONE) {
callback(JSON.parse(client.responseText));
}
}
client.send();
}
function loadVersions() {
loadJSONFile('./static-data/versions.json', function(content) {
renderUpdates(content)
})
}
function renderUpdates(updates) {
for (var i = updates.length - 1; i >= 0; i--) {
renderUpdate(updates[i])
}
}
function renderUpdate(update) {
var html = '<div class="detail-row"><div><span class="version">'
+ update.version
+ '</span><span class="footnote">'
+ update.date
+ '</span></div><div><ul>'
for (var i = 0; i <= update.changes.length - 1; i++) {
html += '<li>' + update.changes[i] + '</li>'
}
html += '</ul></div></div>'
document.getElementById("versions").innerHTML += html
}
function loadScreenshots() {
loadJSONFile('./static-data/screenshots.json', function(content) {
renderScreenshots(content)
})
}
function renderScreenshots(screenshots) {
for (var i = 0; i <= screenshots.length - 1; i++) {
renderScreenshot(screenshots[i])
}
}
function renderScreenshot(screenshot) {
const path = './images/'
const fileName = path + screenshot.name + "." + screenshot.file_extension
const fileNameTwo = path + screenshot.name + "@2x." + screenshot.file_extension + " 2x"
const html = '<img src="'
+ fileName
+ '" srcset="'
+ fileName
+ ', '
+ fileNameTwo
+ '" class="screenshot" alt="'
+ screenshot.alt
+ '" />'
document.getElementById("screenshots").innerHTML += html
}