aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/js/nms-info-box.js
diff options
context:
space:
mode:
authorKristian Lyngstol <kly@kly.no>2016-03-13 17:52:58 +0000
committerKristian Lyngstol <kly@kly.no>2016-03-13 17:52:58 +0000
commitd79ea3095ac5da8344ab727bcb84a73043bbb533 (patch)
treed0fc1f0a20c1627fb5bb44da1950c133d7298f4a /web/nms.gathering.org/js/nms-info-box.js
parenta9656e1fa4bcec5bcbbfe5ca29671d6701014ce8 (diff)
NMS: Add simple searching
Not perfect, but not bad either.
Diffstat (limited to 'web/nms.gathering.org/js/nms-info-box.js')
-rw-r--r--web/nms.gathering.org/js/nms-info-box.js39
1 files changed, 36 insertions, 3 deletions
diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js
index cd34d5e..2ef4c3b 100644
--- a/web/nms.gathering.org/js/nms-info-box.js
+++ b/web/nms.gathering.org/js/nms-info-box.js
@@ -140,6 +140,30 @@ nmsInfoBox._makeCommentTable = function(content) {
}
/*
+ * FIXME: Not sure this belongs here, it's really part of the "Core" ui,
+ * not just the infobox.
+ */
+nmsInfoBox._search = function() {
+ var el = document.getElementById("searchbox");
+ var id = false;
+ if (el) {
+ id = el.value;
+ }
+ if (id && nmsData.switches.switches[id] != undefined) {
+ nmsMap.setSwitchColor(id, "pink");
+ el.parentElement.classList.remove("has-error");
+ el.parentElement.classList.add("has-success");
+ setTimeout(function(){
+ nmsInfoBox.show(id);
+ var el = document.getElementById("searchbox");
+ el.parentElement.classList.remove("has-success");
+ },1000);
+ } else {
+ el.parentElement.classList.add("has-error");
+ }
+}
+
+/*
* Display info on switch "x" in the info-box
*
* Use nmsInfoBox.show(), otherwise changes wont be picked up.
@@ -152,6 +176,7 @@ nmsInfoBox._show = function(x)
var swpanel = document.getElementById("info-switch-panel-body");
var swtitle = document.getElementById("info-switch-title");
var content = [];
+
nmsInfoBox._hide();
nmsInfoBox._showing = x;
@@ -267,10 +292,18 @@ nmsInfoBox._edit = function(sw) {
nmsInfoBox._editChange = function(sw, v) {
var el = document.getElementById("edit-" + sw + "-" + v);
var val = el.value;
- if (v == "placement")
- val = JSON.parse(val);
+ if (v == "placement") {
+ try {
+ val = JSON.parse(val);
+ el.parentElement.classList.remove("has-error");
+ el.parentElement.classList.add("has-success");
+ } catch (e) {
+ el.parentElement.classList.add("has-error");
+ return;
+ }
+ }
nmsInfoBox._editValues[v] = val;
- el.classList.add("bg-warning");
+ el.classList.add("has-warning");
var myData = nmsInfoBox._editStringify(sw);
var out = document.getElementById("edit-output");
out.value = myData;