Minor update on poliqarp specific autocompletion
diff --git a/public/hint.js b/public/hint.js
index 6f20c67..f21798a 100644
--- a/public/hint.js
+++ b/public/hint.js
@@ -8,12 +8,14 @@
var Hint = function (param) {
var foundryRegex = new RegExp("(?:^|[^a-zA-Z0-9])([-a-zA-Z0-9]+?)\/(?:([^=]+?)=)?$");
- var search = document.getElementById(param["ref"]);
- var mirror = document.createElement("div");
- var hint = document.createElement("ul");
+ var search = document.getElementById(param["ref"]);
+ var qlField = document.getElementById(param["qlRef"]);
+ var mirror = document.createElement("div");
+ var hint = document.createElement("ul");
var hintSize = param["hintSize"] ? param["hintSize"] : 10;
- var hints = param["hints"];
+ var hints = param["hints"];
var that = this;
+ var ql;
// Build the mirror element
// <div id="searchMirror"><span></span><ul></ul></div>
@@ -56,6 +58,8 @@
fontSize = searchStyle.getPropertyValue("font-size");
fontFamily = searchStyle.getPropertyValue("font-family");
};
+
+ qlSelect();
};
// Hide hint table
@@ -146,12 +150,14 @@
var begin = value.substring(0, start);
var end = value.substring(start, value.length);
search.value = begin + action + end;
- search.selectionStart = search.selectionEnd = (begin + action).length;
+ search.selectionStart = (begin + action).length
+ search.selectionEnd = search.selectionStart;
this.hide();
// Check for new changes
- mirror.firstChild.innerHTML = begin + action;
+ mirror.firstChild.textContent = begin + action;
+
if (foundryRegex.exec(begin + action))
this.show(RegExp.$1 + (RegExp.$2 ? '/' + RegExp.$2 : ''));
};
@@ -161,16 +167,23 @@
if (e.key === '/' || e.key === '=') {
var start = el.selectionStart;
- mirror.firstChild.innerHTML = el.value.substring(0, start);
+ mirror.firstChild.textContent = el.value.substring(0, start);
var sub = el.value.substring(start - 128 >= 0 ? start - 128 : 0, start);
if (foundryRegex.exec(sub))
that.show(RegExp.$1 + (RegExp.$2 ? '/' + RegExp.$2 : ''));
}
+ else if (ql === 'poliqarp' && (e.key === '[' || (e.key === '<' && !e.shiftKey))) {
+ mirror.firstChild.textContent = el.value.substring(0, el.selectionStart);
+ that.show("-foundries");
+ }
else if (e.key !== 'Shift' &&
e.key !== 'Up' &&
e.key !== 'Down' &&
- e.key !== 'Enter') {
+ e.key !== 'Enter' &&
+ e.key !== 'Alt' &&
+ e.key !== 'AltGraph' &&
+ e.key !== 'CapsLock') {
that.hide();
};
};
@@ -193,8 +206,19 @@
};
};
+ function qlSelect () {
+ var nodes = qlField.childNodes;
+ for (var i = 0; i < nodes.length; i++) {
+ if (nodes[i].selected) {
+ ql = nodes[i].value;
+ break;
+ };
+ };
+ };
+
// Initialize style
init();
- search.addEventListener("keyup", changed, false);
- search.addEventListener("keypress", select, false);
+ search.addEventListener("keyup", changed, false);
+ search.addEventListener("keypress", select, false);
+ qlField.addEventListener('change', qlSelect, false);
};
diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep
index a14b0e0..2eb7a7c 100644
--- a/templates/layouts/default.html.ep
+++ b/templates/layouts/default.html.ep
@@ -32,8 +32,17 @@
%= javascript begin
new Hint({
"ref" : "q-field",
+ "qlRef" : "ql-field",
"hintSize" : 10,
"hints" : {
+ "-foundries" : {
+ "corenlp" : ["corenlp/", "CoreNLP"],
+ "cnx" : ["cnx/", "Connexor"],
+ "opennlp" : ["opennlp/", "OpenNLP"],
+ "xip" : ["xip/", "Xerox"],
+ "tt" : ["tt/", "TreeTagger"],
+ "mate" : ["mate/", "Mate"]
+ },
"corenlp" : {
"ne_dewac_175m_600" : ["ne_dewac_175m_600=", "Named Entity"],
"ne_hgc_175m_600" : ["ne_hgc_175m_600=", "Named Entity"]
@@ -164,7 +173,6 @@
$(this).toggleClass('active');
});
-
% end