Get rid of jQuery
diff --git a/public/js/ajax.js b/public/js/ajax.js
new file mode 100644
index 0000000..2af0bc0
--- /dev/null
+++ b/public/js/ajax.js
@@ -0,0 +1,19 @@
+"use strict";
+
+// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest
+// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest
+// r.addEventListener("progress", updateProgress, false);
+var Ajax = {
+ getJSON : function (url, onload) {
+ var r = new XMLHttpRequest();
+ r.open('GET', url, true);
+ r.setRequestHeader("Accept", "application/json");
+ r.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
+ r.onreadystatechange = function () {
+ if (this.readyState == 4)
+ onload(JSON.parse(this.responseText));
+ };
+ r.send();
+ }
+};
+
diff --git a/public/js/hint.js b/public/js/hint.js
index 1e5f6ec..5e14283 100644
--- a/public/js/hint.js
+++ b/public/js/hint.js
@@ -5,6 +5,7 @@
* - limit the view based on prefix matches
* - highlight matching substrings
* - http://www.cryer.co.uk/resources/javascript/script20_respond_to_keypress.htm
+ * - document.removeEventListener("click",arguments.callee,false);
*/
// Don't let events bubble up
@@ -761,15 +762,16 @@
};
function chooseHint (e) {
+/*
var element = e.target;
while (element.nodeName == "STRONG" || element.nodeName == "SPAN") {
element = element.parentNode;
};
-
if (element === undefined || element.nodeName != "LI")
return;
+*/
- var action = element.getAttribute('data-action');
+ var action = this.getAttribute('data-action');
hint.insertText(action);
var menu = hint.menu();
menu.hide();
diff --git a/public/js/translateTable.js b/public/js/translateTable.js
index 31be939..de3e075 100644
--- a/public/js/translateTable.js
+++ b/public/js/translateTable.js
@@ -193,29 +193,28 @@
function showTable (o) {
var match = o.parentNode.parentNode;
- var table = $(match).children("div").children("div.tokenInfo").first();
+ var table = match.getElementsByClassName("tokenInfo")[0];
-console.log(table);
-
- if (table.hasClass("active")) {
- table.removeClass("active");
+ if (table.classList.contains("active")) {
+ table.classList.remove("active");
return;
}
- else if (table.children("table").length > 0) {
- table.addClass("active");
+ else if (table.getElementsByTagName("table").length > 0) {
+ table.classList.add("active");
return;
};
+
var corpusID = match.getAttribute('data-corpus-id');
var docID = match.getAttribute('data-doc-id');
var matchID = match.getAttribute('data-match-id');
var url = '/corpus/' + corpusID + '/' + docID + '/' + matchID;
var snippet;
- jQuery.getJSON(url, function (res) {
+ Ajax.getJSON(url, function (res) {
var snippet = new SnippetTable(res['snippet']);
- table.addClass("active");
- table.append(snippet.toTable());
+ table.classList.add("active");
+ table.appendChild(snippet.toTable());
});
};
diff --git a/public/sass/kwic-4.0.scss b/public/sass/kwic-4.0.scss
index ee4c3af..a126526 100644
--- a/public/sass/kwic-4.0.scss
+++ b/public/sass/kwic-4.0.scss
@@ -66,13 +66,13 @@
}
}
-ol.free-aligned > li:not(.active):not(:target) > div > div.snippet > span.left {
+ol.align-free > li:not(.active):not(:target) > div > div.snippet > span.left {
display: inline-block;
text-align: right;
width: 50.046%;
}
-ol.free-aligned > li:not(.active):not(:target) > div > div.snippet > span.separator {
+ol.align-free > li:not(.active):not(:target) > div > div.snippet > span.separator {
width: 0px;
height: 1em;
margin-bottom: -2px;
@@ -83,17 +83,17 @@
margin-right: 2px;
}
-ol.free-aligned > li > div > div.snippet > span.right {
+ol.align-free > li > div > div.snippet > span.right {
text-align: left;
}
-ol.left-aligned > li > div > div.snippet > span.context-left {
+ol.align-left > li > div > div.snippet > span.context-left {
display: inline-block;
text-align: right;
width: 50.01%;
}
-ol.right-aligned {
+ol.align-right {
text-align: right;
> li:not(.active):not(:target) > div > div.snippet > span.context-right {
display: inline-block;