Line 1: | Line 1: | ||
var st; | var st; | ||
+ | |||
function animate() { | function animate() { | ||
safe && (handle.style.webkitAnimationName = "handle", handle.style.animationName = "handle", sprite.style.webkitAnimationName = "sprite", sprite.style.animationName = "sprite", safe = !1) | safe && (handle.style.webkitAnimationName = "handle", handle.style.animationName = "handle", sprite.style.webkitAnimationName = "sprite", sprite.style.animationName = "sprite", safe = !1) | ||
Line 14: | Line 15: | ||
function AJAX(e, t, z) { | function AJAX(e, t, z) { | ||
clearTimeout(st); | clearTimeout(st); | ||
− | var n,lb=qs(".JC #loadbar"); | + | var n, lb = qs(".JC #loadbar"); |
− | lb.style.opacity="1"; | + | lb.style.opacity = "1"; |
− | (n = new XMLHttpRequest).onreadystatechange = function() { | + | (n = new XMLHttpRequest).onreadystatechange = function () { |
− | if(z)lb.style.width=n.readyState*25+"%"; | + | if (z) lb.style.width = n.readyState * 25 + "%"; |
4 == n.readyState && t(n) | 4 == n.readyState && t(n) | ||
− | }, n.open("GET", e, !0), n.send(),st=setTimeout(function(){lb.style.opacity="0";st=setTimeout(function(){lb.style.width="0%"},500)},1000) | + | }, n.open("GET", e, !0), n.send(), st = setTimeout(function () { |
+ | lb.style.opacity = "0"; | ||
+ | st = setTimeout(function () { | ||
+ | lb.style.width = "0%" | ||
+ | }, 500) | ||
+ | }, 1000) | ||
} | } | ||
function createindex() { | function createindex() { | ||
var e = contentIndexData; | var e = contentIndexData; | ||
− | Object.keys(e.project).forEach(function(t, n) { | + | Object.keys(e.project).forEach(function (t, n) { |
− | "string" == typeof e.project[t] ? qs("#O2>ul").innerHTML += '<li><a href="£' + e.project[t] + '">' + t + "</a></li>" : (qs("#O2>ul").innerHTML += '<li id="O2-S' + n + '"><a href="#O2-S' + n + '">' + t + "</a></li>", qs("#O2>ul").innerHTML += '<li><ul class="sub"></ul></li>', e.project[t].forEach(function(e) { | + | "string" == typeof e.project[t] ? qs("#O2>ul").innerHTML += '<li><a href="£' + e.project[t] + '">' + t + "</a></li>" : (qs("#O2>ul").innerHTML += '<li id="O2-S' + n + '"><a href="#O2-S' + n + '">' + t + "</a></li>", qs("#O2>ul").innerHTML += '<li><ul class="sub"></ul></li>', e.project[t].forEach(function (e) { |
qs("#O2>ul>li:last-child>ul").innerHTML += '<li><a href="£' + e.replace(/\s+/g, "-").replace(/[^A-Z0-9-_]+/gi, "") + '">' + e + "</a></li>" | qs("#O2>ul>li:last-child>ul").innerHTML += '<li><a href="£' + e.replace(/\s+/g, "-").replace(/[^A-Z0-9-_]+/gi, "") + '">' + e + "</a></li>" | ||
})) | })) | ||
− | }), Object.keys(e.team).forEach(function(t, n) { | + | }), Object.keys(e.team).forEach(function (t, n) { |
− | "string" == typeof e.team[t] ? qs("#O4>ul").innerHTML += '<li><a href="£' + e.team[t] + '">' + t + "</a></li>" : (qs("#O4>ul").innerHTML += '<li id="O4-S' + n + '"><a href="#O4-S' + n + '">' + t + "</a></li>", qs("#O4>ul").innerHTML += '<li><ul class="sub"></ul></li>', e.team[t].forEach(function(e) { | + | "string" == typeof e.team[t] ? qs("#O4>ul").innerHTML += '<li><a href="£' + e.team[t] + '">' + t + "</a></li>" : (qs("#O4>ul").innerHTML += '<li id="O4-S' + n + '"><a href="#O4-S' + n + '">' + t + "</a></li>", qs("#O4>ul").innerHTML += '<li><ul class="sub"></ul></li>', e.team[t].forEach(function (e) { |
qs("#O4>ul>li:last-child>ul").innerHTML += '<li><a href="£' + e.replace(/\s+/g, "-").replace(/[^A-Z0-9-_]+/gi, "") + '">' + e + "</a></li>" | qs("#O4>ul>li:last-child>ul").innerHTML += '<li><a href="£' + e.replace(/\s+/g, "-").replace(/[^A-Z0-9-_]+/gi, "") + '">' + e + "</a></li>" | ||
})) | })) | ||
− | }), Object.keys(e.humanPractices).forEach(function(t, n) { | + | }), Object.keys(e.humanPractices).forEach(function (t, n) { |
− | "string" == typeof e.humanPractices[t] ? qs("#O3>ul").innerHTML += '<li><a href="£' + e.humanPractices[t] + '">' + t + "</a></li>" : (qs("#O3>ul").innerHTML += '<li id="O3-S' + n + '"><a href="#O3-S' + n + '">' + t + "</a></li>", qs("#O3>ul").innerHTML += '<li><ul class="sub"></ul></li>', e.humanPractices[t].forEach(function(e) { | + | "string" == typeof e.humanPractices[t] ? qs("#O3>ul").innerHTML += '<li><a href="£' + e.humanPractices[t] + '">' + t + "</a></li>" : (qs("#O3>ul").innerHTML += '<li id="O3-S' + n + '"><a href="#O3-S' + n + '">' + t + "</a></li>", qs("#O3>ul").innerHTML += '<li><ul class="sub"></ul></li>', e.humanPractices[t].forEach(function (e) { |
qs("#O3>ul>li:last-child>ul").innerHTML += '<li><a href="£' + e.replace(/\s+/g, "-").replace(/[^A-Z0-9-_]+/gi, "") + '">' + e + "</a></li>" | qs("#O3>ul>li:last-child>ul").innerHTML += '<li><a href="£' + e.replace(/\s+/g, "-").replace(/[^A-Z0-9-_]+/gi, "") + '">' + e + "</a></li>" | ||
})) | })) | ||
Line 59: | Line 65: | ||
} | } | ||
− | function renderPage(){ | + | function renderPage() { |
− | var n = html.content || html;qs(".JC #content-body").innerHTML = "", qs(".JC #content-index ol").innerHTML = "", "false" != n.querySelector("div").dataset.templated && qsa("[data-selector]").forEach(function(e) { | + | var n = html.content || html; |
− | + | qs(".JC #content-body").innerHTML = "", qs(".JC #content-index ol").innerHTML = "", "false" != n.querySelector("div").dataset.templated && qsa("[data-selector]").forEach(function (e) { | |
− | + | var t = n.querySelector(e.dataset.selector); | |
− | + | e.innerHTML = t ? e.dataset.text ? t.innerText : t.outerHTML : "" | |
− | + | }), "false" != n.querySelector("div").dataset.wiki ? (qs(".JC #content-index").style.display = "block", n.querySelectorAll("h2, h3").forEach(function (e, t) { | |
− | + | "H2" == e.tagName ? qs(".JC #content-index ol").innerHTML += '<li><a href="#' + e.innerHTML.replace(/\s+/g, "-").replace(/[^A-Z0-9-_]+/gi, "") + "-" + t + '">' + e.innerHTML + "</a></li>" : qs(".JC #content-index ol").lastChild.querySelector("ol") ? qs(".JC #content-index ol").lastChild.querySelector("ol").innerHTML += '<li><a href="#' + e.innerHTML.replace(/\s+/g, "-").replace(/[^A-Z0-9-_]+/gi, "") + "-" + t + '">' + e.innerHTML + "</a></li>" : qs(".JC #content-index ol").lastChild.innerHTML += '<ol><li><a href="#' + e.innerHTML.replace(/\s+/g, "-").replace(/[^A-Z0-9-_]+/gi, "") + "-" + t + '">' + e.innerHTML + "</a></li></ol>" | |
− | + | }), n.querySelectorAll("div h2, div h3").forEach(function (e, t) { | |
− | + | e.id = e.innerHTML.replace(/\s+/g, "-").replace(/[^A-Z0-9-_]+/gi, "") + "-" + t | |
+ | })) : qs(".JC #content-index").style.display = "none", qs(".JC #content-body").innerHTML = n.querySelector("div") ? n.querySelector("div").innerHTML : ""; | ||
+ | n.querySelectorAll("script").forEach(function (p) { | ||
+ | if (p.dataset.run != "false") eval(p.innerHTML) | ||
+ | }) | ||
+ | } | ||
function loadPage(e) { | function loadPage(e) { | ||
− | qs(".JC #content-container").style.visibility = "hidden", AJAX("/Team:Judd_UK/Pages/" + e + "?action=raw&ctype=text/plain", function(t) { | + | qs(".JC #content-container").style.visibility = "hidden", AJAX("/Team:Judd_UK/Pages/" + e + "?action=raw&ctype=text/plain", function (t) { |
if (200 == t.status) { | if (200 == t.status) { | ||
page = e, html.innerHTML = t.responseText; | page = e, html.innerHTML = t.responseText; | ||
renderPage(), qs(".JC #content-container").style.visibility = "visible", animate() | renderPage(), qs(".JC #content-container").style.visibility = "visible", animate() | ||
} else loadPage("404") | } else loadPage("404") | ||
− | },true) | + | }, true) |
} | } | ||
var qs = document.querySelector.bind(document), | var qs = document.querySelector.bind(document), | ||
Line 81: | Line 92: | ||
objectList = null, | objectList = null, | ||
qsa = document.querySelectorAll.bind(document), | qsa = document.querySelectorAll.bind(document), | ||
− | page = location.pathname.substring(14).replace(/\//g, "*"), | + | page = (location.pathname.length >14)?location.pathname.substring(14).replace(/\//g, "*"):"Home", |
html = qs("template"), | html = qs("template"), | ||
mouseDetected = !1; | mouseDetected = !1; | ||
− | window.onpopstate = function(e) { | + | window.onpopstate = function (e) { |
− | return magic ? void(magic = !1) : void(location.pathname.replace(/\//g, "*") | + | return magic ? void(magic = !1) : void((location.pathname.length >14)?location.pathname.substring(14).replace(/\//g, "*"):"Home" != page && loadPage((location.pathname.length >14)?location.pathname.substring(14).replace(/\//g, "*"):"Home")) |
}; | }; | ||
var handle = qs(".JC #handle"), | var handle = qs(".JC #handle"), | ||
sprite = qs(".JC #sprite"), | sprite = qs(".JC #sprite"), | ||
safe = !0; | safe = !0; | ||
− | document.addEventListener("DOMContentLoaded", function (){ | + | document.addEventListener("DOMContentLoaded", function () { |
− | qs("#HQ_page #bodyContent>.mw-content-ltr").classList.remove("mw-content-ltr"), qs("#HQ_page #bodyContent").id = "", qs("#HQ_page").id = "", page!="berhfudf"?loadPage(page):"", createindex(), qs(".JC #sprite").addEventListener((void 0 === qs(".JC").style.animationName ? "webkit" : "") + "animationend", function() { | + | qs("#HQ_page #bodyContent>.mw-content-ltr").classList.remove("mw-content-ltr"), qs("#HQ_page #bodyContent").id = "", qs("#HQ_page").id = "", page != "berhfudf" ? loadPage(page) : "", createindex(), qs(".JC #sprite").addEventListener((void 0 === qs(".JC").style.animationName ? "webkit" : "") + "animationend", function () { |
− | + | handle.style.webkitAnimationName = "", handle.style.animationName = "", sprite.style.webkitAnimationName = "", sprite.style.animationName = "", safe = !0 | |
− | }, !1), qs(".JC #main-img").onmouseenter = animate, document.addEventListener("click", newPage, !1), document.addEventListener("mousemove", function() { | + | }, !1), qs(".JC #main-img").onmouseenter = animate, document.addEventListener("click", newPage, !1), document.addEventListener("mousemove", function () { |
− | + | mouseDetected && (qs("#topstyles").innerHTML = ""), mouseDetected = !0, document.removeEventListener("mousemove", arguments.callee) | |
− | }, !1), qs("#topstyles").innerHTML = ".JC #O1 a{transform:translateX(-150%)!important;opacity:1!important}.JC #O2 a{transform: translateX(-50%)!important;opacity:1!important}.JC #O3 a{transform:translateX(50%)!important;opacity:1!important}.JC #O4 a{transform:translateX(150%)!important;opacity:1!important}", setTimeout(function() { | + | }, !1), qs("#topstyles").innerHTML = ".JC #O1 a{transform:translateX(-150%)!important;opacity:1!important}.JC #O2 a{transform: translateX(-50%)!important;opacity:1!important}.JC #O3 a{transform:translateX(50%)!important;opacity:1!important}.JC #O4 a{transform:translateX(150%)!important;opacity:1!important}", setTimeout(function () { |
− | + | mouseDetected ? qs("#topstyles").innerHTML = "" : mouseDetected = !0 | |
− | }, 4e3), loadStyleSheet("https://fonts.googleapis.com/css?family=Raleway|Open+Sans:300"), loadStyleSheet("https://fonts.googleapis.com/css?family=Creepster");}); | + | }, 4e3), loadStyleSheet("https://fonts.googleapis.com/css?family=Raleway|Open+Sans:300"), loadStyleSheet("https://fonts.googleapis.com/css?family=Creepster"); |
+ | }); |
Revision as of 18:19, 30 October 2017
var st;
function animate() {
safe && (handle.style.webkitAnimationName = "handle", handle.style.animationName = "handle", sprite.style.webkitAnimationName = "sprite", sprite.style.animationName = "sprite", safe = !1)
}
function loadStyleSheet(e) {
if (document.createStyleSheet) document.createStyleSheet(e); else { var t = document.createElement("link"); t.href = e, t.rel = "stylesheet", t.type = "text/css", document.getElementsByTagName("head")[0].appendChild(t) }
}
function AJAX(e, t, z) {
clearTimeout(st); var n, lb = qs(".JC #loadbar"); lb.style.opacity = "1"; (n = new XMLHttpRequest).onreadystatechange = function () { if (z) lb.style.width = n.readyState * 25 + "%"; 4 == n.readyState && t(n) }, n.open("GET", e, !0), n.send(), st = setTimeout(function () { lb.style.opacity = "0"; st = setTimeout(function () { lb.style.width = "0%" }, 500) }, 1000)
}
function createindex() {
var e = contentIndexData; Object.keys(e.project).forEach(function (t, n) {"string" == typeof e.project[t] ? qs("#O2>ul").innerHTML += '
})) }), Object.keys(e.team).forEach(function (t, n) {"string" == typeof e.team[t] ? qs("#O4>ul").innerHTML += '
})) }), Object.keys(e.humanPractices).forEach(function (t, n) {"string" == typeof e.humanPractices[t] ? qs("#O3>ul").innerHTML += '
})) })
}
function newPage(e) {
var t = (e = window.e || e).target.getAttribute("href"); if (null !== t && ("£" == t[0] || "#" == t[0])) { if ("#" == t[0]) { magic = !0; try { qs(".JC #content-body " + t).scrollIntoView({ behavior: "smooth", block: "start", inline: "nearest" }) } catch (e) { location.hash = t } return t == "#" + e.target.parentElement.id && window.scrollTo(0, document.body.scrollTop), void e.preventDefault() } e.preventDefault(), loadPage(t = t.substring(1)), window.history.pushState(null, null, "/Team:Judd_UK/" + t.replace("*", "/")) }
}
function renderPage() {
var n = html.content || html; qs(".JC #content-body").innerHTML = "", qs(".JC #content-index ol").innerHTML = "", "false" != n.querySelector("div").dataset.templated && qsa("[data-selector]").forEach(function (e) { var t = n.querySelector(e.dataset.selector); e.innerHTML = t ? e.dataset.text ? t.innerText : t.outerHTML : "" }), "false" != n.querySelector("div").dataset.wiki ? (qs(".JC #content-index").style.display = "block", n.querySelectorAll("h2, h3").forEach(function (e, t) {"H2" == e.tagName ? qs(".JC #content-index ol").innerHTML += '
- <a href="#' + e.innerHTML.replace(/\s+/g, "-").replace(/[^A-Z0-9-_]+/gi, "") + "-" + t + '">' + e.innerHTML + "</a>
}), n.querySelectorAll("div h2, div h3").forEach(function (e, t) { e.id = e.innerHTML.replace(/\s+/g, "-").replace(/[^A-Z0-9-_]+/gi, "") + "-" + t })) : qs(".JC #content-index").style.display = "none", qs(".JC #content-body").innerHTML = n.querySelector("div") ? n.querySelector("div").innerHTML : ""; n.querySelectorAll("script").forEach(function (p) { if (p.dataset.run != "false") eval(p.innerHTML) })
}
function loadPage(e) {
qs(".JC #content-container").style.visibility = "hidden", AJAX("/Team:Judd_UK/Pages/" + e + "?action=raw&ctype=text/plain", function (t) { if (200 == t.status) { page = e, html.innerHTML = t.responseText; renderPage(), qs(".JC #content-container").style.visibility = "visible", animate() } else loadPage("404") }, true)
} var qs = document.querySelector.bind(document),
magic = !1, objectList = null, qsa = document.querySelectorAll.bind(document), page = (location.pathname.length >14)?location.pathname.substring(14).replace(/\//g, "*"):"Home", html = qs("template"), mouseDetected = !1;
window.onpopstate = function (e) {
return magic ? void(magic = !1) : void((location.pathname.length >14)?location.pathname.substring(14).replace(/\//g, "*"):"Home" != page && loadPage((location.pathname.length >14)?location.pathname.substring(14).replace(/\//g, "*"):"Home"))
}; var handle = qs(".JC #handle"),
sprite = qs(".JC #sprite"), safe = !0;
document.addEventListener("DOMContentLoaded", function () {
qs("#HQ_page #bodyContent>.mw-content-ltr").classList.remove("mw-content-ltr"), qs("#HQ_page #bodyContent").id = "", qs("#HQ_page").id = "", page != "berhfudf" ? loadPage(page) : "", createindex(), qs(".JC #sprite").addEventListener((void 0 === qs(".JC").style.animationName ? "webkit" : "") + "animationend", function () { handle.style.webkitAnimationName = "", handle.style.animationName = "", sprite.style.webkitAnimationName = "", sprite.style.animationName = "", safe = !0 }, !1), qs(".JC #main-img").onmouseenter = animate, document.addEventListener("click", newPage, !1), document.addEventListener("mousemove", function () { mouseDetected && (qs("#topstyles").innerHTML = ""), mouseDetected = !0, document.removeEventListener("mousemove", arguments.callee) }, !1), qs("#topstyles").innerHTML = ".JC #O1 a{transform:translateX(-150%)!important;opacity:1!important}.JC #O2 a{transform: translateX(-50%)!important;opacity:1!important}.JC #O3 a{transform:translateX(50%)!important;opacity:1!important}.JC #O4 a{transform:translateX(150%)!important;opacity:1!important}", setTimeout(function () { mouseDetected ? qs("#topstyles").innerHTML = "" : mouseDetected = !0 }, 4e3), loadStyleSheet("https://fonts.googleapis.com/css?family=Raleway%7COpen+Sans:300"), loadStyleSheet("https://fonts.googleapis.com/css?family=Creepster");
});