aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ext_depends/tinyendian/doc/search.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/ext_depends/tinyendian/doc/search.js')
-rw-r--r--src/ext_depends/tinyendian/doc/search.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/ext_depends/tinyendian/doc/search.js b/src/ext_depends/tinyendian/doc/search.js
new file mode 100644
index 0000000..89a7b15
--- /dev/null
+++ b/src/ext_depends/tinyendian/doc/search.js
@@ -0,0 +1,59 @@
+"use strict";
+var items = [
+{"tinyendian" : "tinyendian.html"},
+{"tinyendian.UTFEncoding" : "tinyendian/UTFEncoding.html"},
+{"tinyendian.swapByteOrder" : "tinyendian.html#swapByteOrder"},
+{"tinyendian.fixUTFByteOrder" : "tinyendian.html#fixUTFByteOrder"},
+];
+function search(str) {
+ var re = new RegExp(str.toLowerCase());
+ var ret = {};
+ for (var i = 0; i < items.length; i++) {
+ var k = Object.keys(items[i])[0];
+ if (re.test(k.toLowerCase()))
+ ret[k] = items[i][k];
+ }
+ return ret;
+}
+
+function searchSubmit(value, event) {
+ console.log("searchSubmit");
+ var resultTable = document.getElementById("results");
+ while (resultTable.firstChild)
+ resultTable.removeChild(resultTable.firstChild);
+ if (value === "" || event.keyCode == 27) {
+ resultTable.style.display = "none";
+ return;
+ }
+ resultTable.style.display = "block";
+ var results = search(value);
+ var keys = Object.keys(results);
+ if (keys.length === 0) {
+ var row = resultTable.insertRow();
+ var td = document.createElement("td");
+ var node = document.createTextNode("No results");
+ td.appendChild(node);
+ row.appendChild(td);
+ return;
+ }
+ for (var i = 0; i < keys.length; i++) {
+ var k = keys[i];
+ var v = results[keys[i]];
+ var link = document.createElement("a");
+ link.href = v;
+ link.textContent = k;
+ link.attributes.id = "link" + i;
+ var row = resultTable.insertRow();
+ row.appendChild(link);
+ }
+}
+
+function hideSearchResults(event) {
+ if (event.keyCode != 27)
+ return;
+ var resultTable = document.getElementById("results");
+ while (resultTable.firstChild)
+ resultTable.removeChild(resultTable.firstChild);
+ resultTable.style.display = "none";
+}
+