-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscreenshots.js
50 lines (42 loc) · 1.09 KB
/
screenshots.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
var modal = document.getElementById('modal');
var span = document.getElementsByClassName("close")[0];
var screenshots = {};
function showscreenshot(s)
{
var e = document.getElementById('screenshot');
e.innerHTML = "<img width=\"100%\" src=\"https://i.imgur.com/" + s + ".jpg\"/>";
modal.style.display = "block";
}
function getbox(n, content)
{
if (screenshots[n]) {
return("<a href=\"javascript:showscreenshot('" + screenshots[n] + "')\">" + content + "</a>");
}
return content;
}
function screenshotjsonget(url)
{
var r = new XMLHttpRequest();
r.open("GET", url, true);
r.setRequestHeader("Content-type", "application/json")
r.onreadystatechange = function()
{
if (r.readyState == 4 && r.status == 200)
{
var tbl = JSON.parse(r.responseText);
Object.keys(tbl).forEach(function(key, index) {
screenshots[key] = tbl[key];
})
}
}
r.send();
}
screenshotjsonget("https://minetest.foo-projects.org/screenshots.json");
span.onclick = function() {
modal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}