Update gctGenerator.js
This commit is contained in:
parent
e0ff17bac6
commit
ec5c7920a7
1 changed files with 40 additions and 42 deletions
|
@ -6,9 +6,23 @@ if (navigator.userAgent.toLowerCase().indexOf("firefox") > -1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var xmlData;
|
document.getElementById("checkList").addEventListener("click", function(ev) {
|
||||||
function fillChecklist(i) {
|
if (ev.target && ev.target.nodeName == "LI") {
|
||||||
if (i < xmlData.length) {
|
ev.target.classList.toggle("checked");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function parseXML(name) {
|
||||||
|
var xml = new XMLHttpRequest();
|
||||||
|
var file = "codes/" + name + ".xml";
|
||||||
|
xml.onload = function() {
|
||||||
|
if (this.status == 200 && this.responseXML != null) {
|
||||||
|
var xmlData = xml.responseXML;
|
||||||
|
xmlData = (new DOMParser()).parseFromString(xml.responseText, "text/xml");
|
||||||
|
xmlData = xmlData.getElementsByTagName("code");
|
||||||
|
|
||||||
|
var i = 0;
|
||||||
|
for(;i < xmlData.length; i++) {
|
||||||
var li = document.createElement("li");
|
var li = document.createElement("li");
|
||||||
var desc = xmlData[i].getElementsByTagName("title")[0].textContent;
|
var desc = xmlData[i].getElementsByTagName("title")[0].textContent;
|
||||||
var t = document.createTextNode(desc);
|
var t = document.createTextNode(desc);
|
||||||
|
@ -20,34 +34,18 @@ function fillChecklist(i) {
|
||||||
li.setAttribute("data-codeDate", xmlData[i].getElementsByTagName("date")[0].textContent);
|
li.setAttribute("data-codeDate", xmlData[i].getElementsByTagName("date")[0].textContent);
|
||||||
li.setAttribute("data-codeSrc", xmlData[i].getElementsByTagName("source")[0].textContent.replace(/[\s\n\r\t]+/gm, ""));
|
li.setAttribute("data-codeSrc", xmlData[i].getElementsByTagName("source")[0].textContent.replace(/[\s\n\r\t]+/gm, ""));
|
||||||
li.setAttribute("onmouseover", "updateDescription(this)");
|
li.setAttribute("onmouseover", "updateDescription(this)");
|
||||||
|
li.style.animationDuration = 0.4 + i*0.05 + "s";
|
||||||
document.getElementById("checkList").appendChild(li);
|
document.getElementById("checkList").appendChild(li);
|
||||||
i++;
|
}
|
||||||
setTimeout(function() {
|
|
||||||
fillChecklist(i)
|
|
||||||
}, 16);
|
|
||||||
} else {
|
|
||||||
setTimeout(function() {
|
|
||||||
button = document.getElementById("downloadButton");
|
button = document.getElementById("downloadButton");
|
||||||
button.style.transitionDuration = "1s";
|
button.style.transitionDuration = 0.6 + i*0.05 + "s";
|
||||||
button.style.opacity = "1";
|
button.style.opacity = "1";
|
||||||
button.disabled = false;
|
button.disabled = false;
|
||||||
document.getElementById("gameID").disabled = false;
|
document.getElementById("gameID").disabled = false;
|
||||||
}, 24);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseXML(name) {
|
|
||||||
var xml = new XMLHttpRequest();
|
|
||||||
var file = "codes/" + name + ".xml";
|
|
||||||
xml.onload = function() {
|
|
||||||
if (this.status == 200 && this.responseXML != null) {
|
|
||||||
xmlData = xml.responseXML;
|
|
||||||
xmlData = (new DOMParser()).parseFromString(xml.responseText, "text/xml");
|
|
||||||
xmlData = xmlData.getElementsByTagName("code");
|
|
||||||
|
|
||||||
fillChecklist(0);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
xml.open("GET", file);
|
xml.open("GET", file);
|
||||||
xml.send();
|
xml.send();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue