-
Notifications
You must be signed in to change notification settings - Fork 3
/
get_map.js
36 lines (30 loc) · 1.04 KB
/
get_map.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
var data = []
fetch('https://shiptest.net/renders/maps.json')
.then(function (response) {
return response.json();
})
.then(function (result) {
renderMaps(result);
})
.catch(function (err) {
console.log(err);
});
function renderMaps(data) {
var mapList = document.createElement('ul');
mapList.classList.add("simple_list");
for (mapName in data) {
var mapNameText = document.createTextNode(mapName);
var mapLink = document.createElement('a');
mapLink.innerHTML = "Webmap";
mapLink.href = "https://shiptest.net/map?map=" + data[mapName]["short_name"]
var mapLinkFull = document.createElement('a');
mapLinkFull.innerHTML = "Full Render";
mapLinkFull.href = "https://shiptest.net/renders/initial/padded/" + data[mapName]["short_name"] + ".png"
var mapParagraph = document.createElement('li');
mapParagraph.appendChild(mapNameText);
mapParagraph.appendChild(mapLink);
mapParagraph.appendChild(mapLinkFull);
mapList.appendChild(mapParagraph);
}
document.getElementById("main").appendChild(mapList);
}