blob: 0ec515bb44ad4879ab52448211cbe1101fba56d2 [file] [log] [blame]
Nils Diewald4af3f0b2014-06-25 01:43:17 +00001%= javascript begin
2
Nils Diewaldeca30442014-11-18 20:33:54 +00003// Create new hint
4var hint = Object.create(Hint).init();
Nils Diewald4af3f0b2014-06-25 01:43:17 +00005
Nils Diewalde99d9042014-11-20 23:36:54 +00006// Add toggleClass method similar to jquery
7HTMLElement.prototype.toggleClass = function (c1, c2) {
8 var cl = this.classList;
9 if (cl.contains(c1)) {
10 cl.add(c2);
11 cl.remove(c1);
12 }
13 else {
14 cl.remove(c2);
15 cl.add(c1);
16 };
17};
18
Nils Diewald4af3f0b2014-06-25 01:43:17 +000019function openTutorial (o) {
Nils Diewalde99d9042014-11-20 23:36:54 +000020 var tut = document.getElementById("tutorial");
21 tut.classList.add("active")
22 var iframe = tut.getElementsByTagName("iframe")[0];
23 iframe.setAttribute("src", getTutorialPage());
Nils Diewald4af3f0b2014-06-25 01:43:17 +000024};
25
26function closeTutorial (o) {
Nils Diewalde99d9042014-11-20 23:36:54 +000027 document.getElementById("tutorial").classList.remove("active");
Nils Diewald4af3f0b2014-06-25 01:43:17 +000028};
29
30function useQuery (o) {
31 var q = o.getAttribute("data-query");
32 var ql = o.getAttribute("data-query-language");
Nils Diewaldf49633a2014-11-08 22:33:25 +000033 var qc = o.getAttribute("data-query-cutoff");
Nils Diewalde99d9042014-11-20 23:36:54 +000034 if (qc !== 0 && qc !== "0" && qc !== "off" && qc !== null) {
35 document.getElementById("q-cutoff-field").checked = true;
36 };
Nils Diewalde8e88052014-11-10 16:32:02 +000037
Nils Diewalde99d9042014-11-20 23:36:54 +000038 var qlf = document.getElementById("ql-field").options;
39 for (i in qlf)
40 if (qlf[i].value == ql) qlf[i].selected = true;
Nils Diewalde8e88052014-11-10 16:32:02 +000041
Nils Diewalde99d9042014-11-20 23:36:54 +000042 document.getElementById("q-field").value = q;
Nils Diewald4af3f0b2014-06-25 01:43:17 +000043 closeTutorial();
44};
45
Nils Diewalde99d9042014-11-20 23:36:54 +000046document.getElementById("sidebar").addEventListener("click",function(){
47 this.classList.toggle("active");
48},false);
Nils Diewald4af3f0b2014-06-25 01:43:17 +000049
Nils Diewalde99d9042014-11-20 23:36:54 +000050%# document.getElementById("top")
51%# .querySelectorAll("span.location")
52%# .addEventListener("click",function() {
53%# document.getElementById("sidebar").classList.toggle("active");
54%# }, false);
55
56function toggleAlignment (o) {
57 var ol = document.querySelector("#search > ol");
58 ol.toggleClass("align-left", "align-right");
59 o.firstChild.toggleClass("fa-align-right", "fa-align-left");
60};
Nils Diewald7cad8402014-07-08 17:06:56 +000061
Nils Diewald4af3f0b2014-06-25 01:43:17 +000062% end