aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolai Tellefsen <niccofyren@gmail.com>2016-03-17 22:38:32 +0100
committerNicolai Tellefsen <niccofyren@gmail.com>2016-03-17 22:38:32 +0100
commita24f3520a43cf59d0ac88270ba956c9aa67de469 (patch)
treefa0c91f605ccedd9cb946fb37d6686560b5ded3b
parentb7887d4b7181e057d77a5f5d093de0400052bd0b (diff)
NMS: Add live highlight to search
Original search only worked with exact matches. Added a simple highlight interface to nms-map.js to enable live highlights while typing.
-rw-r--r--web/nms.gathering.org/index.html2
-rw-r--r--web/nms.gathering.org/js/nms-info-box.js31
-rw-r--r--web/nms.gathering.org/js/nms-map.js30
3 files changed, 38 insertions, 25 deletions
diff --git a/web/nms.gathering.org/index.html b/web/nms.gathering.org/index.html
index 3452b9a..e70c9e3 100644
--- a/web/nms.gathering.org/index.html
+++ b/web/nms.gathering.org/index.html
@@ -89,7 +89,7 @@
<button class="btn btn-default btn-sm" id="legend-5"></button>
</div>
<div class="input-group input-group-sm">
- <input id="searchbox" type="text" class="form-control" placeholder="Search" oninput="nmsInfoBox._search()" />
+ <input id="searchbox" type="text" class="form-control" placeholder="Filter" oninput="nmsInfoBox._search()" />
<span class="input-group-btn">
<button class="btn btn-default" type="button" onclick="nmsInfoBox.show(document.getElementById('searchbox').value);">Go!</button>
</span>
diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js
index b559ba2..6b13498 100644
--- a/web/nms.gathering.org/js/nms-info-box.js
+++ b/web/nms.gathering.org/js/nms-info-box.js
@@ -147,30 +147,21 @@ nmsInfoBox._makeCommentTable = function(content) {
nmsInfoBox._search = function() {
var el = document.getElementById("searchbox");
var id = false;
+ var hits = 0;
if (el) {
id = el.value;
}
- if (id && nmsData.switches.switches[id] != undefined) {
- nmsMap.setSwitchColor(id, "red");
- window.setTimeout(function(){
- nmsMap.setSwitchColor(id, "pink");
- window.setTimeout(function(){
- nmsMap.setSwitchColor(id, "red");
- window.setTimeout(function(){
- nmsMap.setSwitchColor(id, "pink");
- window.setTimeout(function(){
- nmsMap.setSwitchColor(id, "red");
- window.setTimeout(function(){
- nmsMap.setSwitchColor(id, "pink");
- },300);
- },300);
- },300);
- },300);
- },300);
- el.parentElement.classList.remove("has-error");
- el.parentElement.classList.add("has-success");
+ if(id) {
+ for(var sw in nmsData.switches.switches) {
+ if(sw.indexOf(id) > -1) {
+ hits++;
+ nmsMap.setSwitchHighlight(sw,true);
+ } else {
+ nmsMap.setSwitchHighlight(sw,false);
+ }
+ }
} else {
- el.parentElement.classList.add("has-error");
+ nmsMap.removeAllSwitchHighlights();
}
}
diff --git a/web/nms.gathering.org/js/nms-map.js b/web/nms.gathering.org/js/nms-map.js
index d855320..9bba1bf 100644
--- a/web/nms.gathering.org/js/nms-map.js
+++ b/web/nms.gathering.org/js/nms-map.js
@@ -9,20 +9,23 @@
* nmsMap.init() - start things up
* nmsMap.setSwitchColor(switch,color)
* nmsMap.setSwitchInfo(switch,info)
+ * nmsMap.setSwitchHighlight(switch,true/false)
+ * nmsMap.removeAllSwitchHighlights()
*/
var nmsMap = nmsMap || {
_moveInProgress: false,
stats: {
- earlyDrawAll:0,
colorChange:0,
colorSame:0,
+ earlyDrawAll:0,
+ nowDups:0,
+ nows:0,
resizeEvents:0,
- switchInfoUpdate:0,
switchInfoSame:0,
- nowDups:0,
- nows:0
+ switchInfoUpdate:0,
+ highlightChange:0
},
contexts: ["bg","link","blur","switch","text","textInfo","top","input","hidden"],
_info: {},
@@ -43,6 +46,7 @@ var nmsMap = nmsMap || {
},
_color: { },
+ _highlight: { },
_c: {}
}
@@ -68,6 +72,21 @@ nmsMap.setSwitchColor = function(sw, color) {
}
}
+nmsMap.setSwitchHighlight = function(sw, highlight) {
+ if(highlight)
+ highlight == true;
+ if (this._highlight[sw] != highlight) {
+ this._highlight[sw] = highlight;
+ this._drawSwitch(sw);
+ this.stats.highlightChange++;
+ }
+}
+
+nmsMap.removeAllSwitchHighlights = function() {
+ for(var sw in this._highlight)
+ this.setSwitchHighlight(sw,false);
+}
+
nmsMap.reset = function() {
for (var sw in this._color) {
nmsMap.setSwitchColor(sw, undefined);
@@ -226,6 +245,9 @@ nmsMap._drawSwitch = function(sw)
return;
var box = this._getBox(sw);
var color = nmsMap._color[sw];
+ if(nmsMap._highlight[sw]) {
+ color = red;
+ }
if (color == undefined) {
color = blue;
}
0.7.0.1&id=a5f9e3d8d91ccded80af07f6336bca44b1c9a171'>json/ext/generator/generator.h
blob: e47f507b0da13459d300a3cb2633a01f4067fd27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197