omf_web 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +168 -13
- data/bin/omf-web-basic +3 -3
- data/doc/index.md +205 -0
- data/example/NOT_WORKING/brooklyn/brooklyn_server.rb +2 -2
- data/example/NOT_WORKING/frisbee/data_sources/parse_log.rb +1 -1
- data/example/NOT_WORKING/frisbee/viz_server.rb +1 -1
- data/example/NOT_WORKING/gec12/gec12_demo_server.rb +1 -1
- data/example/NOT_WORKING/gec12/visualization.rb +2 -2
- data/example/NOT_WORKING/network/network_server.rb +2 -2
- data/example/NOT_WORKING/wimax/test.rb +2 -2
- data/example/NOT_WORKING/wimax/viz_server.rb +2 -2
- data/example/bridge/auth_basic.rb +75 -0
- data/example/bridge/config.ru +101 -0
- data/example/bridge/configure/configure_widget.rb +32 -0
- data/example/bridge/data_sources/sensor-sqlite.rb +28 -6
- data/example/bridge/data_sources/test31.sq3 +0 -0
- data/example/bridge/htdocs/{js/graph → graph/js}/bridge.js +2 -2
- data/example/bridge/htdocs/{js/graph → graph/js}/event_line_chart.js +7 -6
- data/example/bridge/htdocs/{js/graph → graph/js}/event_table.js +13 -5
- data/example/bridge/htdocs/template/login.html +23 -0
- data/example/bridge/viz_server.rb +3 -5
- data/example/bridge/widgets/configure.yaml +12 -0
- data/example/bridge/widgets/login.yaml +16 -0
- data/example/bridge/{overview.yaml → widgets/overview.yaml} +7 -4
- data/example/demo/data_sources/animals.rb +1 -1
- data/example/demo/data_sources/downloads.rb +1 -1
- data/example/demo/data_sources/generator.rb +1 -1
- data/example/demo/data_sources/histogram.rb +1 -1
- data/example/demo/data_sources/mobile_network.rb +4 -3
- data/example/demo/data_sources/movies.rb +1 -1
- data/example/demo/data_sources/network.rb +4 -3
- data/example/demo/data_sources/returns.rb +1 -1
- data/example/demo/data_sources/static_network.rb +4 -3
- data/example/demo/data_sources/walk.rb +1 -1
- data/example/demo/demo_viz_server.rb +1 -1
- data/example/demo/widgets/linked_graphs_tab.yaml +1 -1
- data/example/openflow-gec15/README.md +21 -0
- data/example/openflow-gec15/code_tab.yaml +36 -0
- data/example/openflow-gec15/dashboard_tab.yaml +72 -0
- data/example/openflow-gec15/doc/screenshot.png +0 -0
- data/example/openflow-gec15/exp_source.rb +104 -0
- data/example/openflow-gec15/of_viz_server.rb +63 -0
- data/example/openflow-gec15/openflow-demo.sq3 +0 -0
- data/example/openflow-gec15/raw_tab.yaml +37 -0
- data/example/openflow-gec15/repository/of-exp.rb +12 -0
- data/example/openflow-gec15/repository/sample.md +52 -0
- data/example/openflow-gec15/repository/trema-ctl6.rb +148 -0
- data/example/simple/README.md +2 -0
- data/example/simple/data_sources/gimi31.sq3 +0 -0
- data/example/simple/data_sources/ping_source.rb +56 -0
- data/example/simple/simple_viz_server.rb +39 -0
- data/example/simple/widgets/charts_tab.yaml +38 -0
- data/lib/omf-web/config.ru +31 -3
- data/lib/omf-web/data_source_proxy.rb +29 -26
- data/lib/omf-web/rack/session_authenticator.rb +93 -0
- data/lib/omf-web/rack/tab_mapper.rb +10 -5
- data/lib/omf-web/rack/websocket_handler.rb +17 -6
- data/lib/omf-web/theme/abstract_page.rb +1 -1
- data/lib/omf-web/theme/bright/flow_renderer.rb +2 -2
- data/lib/omf-web/theme/bright/layout_renderer.rb +15 -0
- data/lib/omf-web/theme/bright/mustache_renderer.rb +29 -0
- data/lib/omf-web/theme/bright/one_column_renderer.rb +2 -2
- data/lib/omf-web/theme/bright/page.rb +33 -8
- data/lib/omf-web/theme/bright/tabbed_renderer.rb +2 -3
- data/lib/omf-web/theme/bright/two_columns_renderer.rb +3 -4
- data/lib/omf-web/version.rb +1 -1
- data/lib/omf-web/widget/code_widget.rb +0 -7
- data/lib/omf-web/widget/layout/two_columns_layout.rb +3 -2
- data/lib/omf-web/widget/mustache_widget.rb +44 -0
- data/lib/omf-web/widget.rb +14 -1
- data/lib/omf_common/lobject.rb +6 -3
- data/omf_web.gemspec +3 -1
- data/share/htdocs/graph/js/abstract_nv_chart.js +14 -4
- data/share/htdocs/graph/js/abstract_widget.js +5 -4
- data/share/htdocs/graph/js/line_chart3.js +2 -0
- data/share/htdocs/graph/js/map2.js +3 -3
- data/share/htdocs/graph/js/network2.js +51 -19
- data/share/htdocs/graph/js/scatter_plot.js +6 -2
- data/share/htdocs/graph/js/table2.js +5 -2
- data/share/htdocs/js/data_source2.js +40 -8
- data/share/htdocs/js/mustache.js +29 -0
- data/share/htdocs/theme/abstract/abstract.js +10 -3
- data/share/htdocs/vendor/mustache-0.7.0/CHANGES +21 -0
- data/share/htdocs/vendor/mustache-0.7.0/LICENSE +10 -0
- data/share/htdocs/vendor/mustache-0.7.0/README.md +374 -0
- data/share/htdocs/vendor/mustache-0.7.0/jquery.mustache.js +635 -0
- data/share/htdocs/vendor/mustache-0.7.0/mustache.js +612 -0
- data/share/htdocs/vendor/nv_d3/js/nv.d3.js +9 -1
- data/share/htdocs/vendor/raphael-2.1.0/raphael.js +5815 -0
- metadata +74 -9
- data/DESIGN_NOTES.txt +0 -56
@@ -0,0 +1,612 @@
|
|
1
|
+
/*!
|
2
|
+
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
3
|
+
* http://github.com/janl/mustache.js
|
4
|
+
*/
|
5
|
+
|
6
|
+
/*global define: false*/
|
7
|
+
|
8
|
+
var Mustache;
|
9
|
+
|
10
|
+
(function (exports) {
|
11
|
+
if (typeof module !== "undefined" && module.exports) {
|
12
|
+
module.exports = exports; // CommonJS
|
13
|
+
} else if (typeof define === "function") {
|
14
|
+
define(exports); // AMD
|
15
|
+
} else {
|
16
|
+
Mustache = exports; // <script>
|
17
|
+
}
|
18
|
+
}((function () {
|
19
|
+
|
20
|
+
var exports = {};
|
21
|
+
|
22
|
+
exports.name = "mustache.js";
|
23
|
+
exports.version = "0.7.0";
|
24
|
+
exports.tags = ["{{", "}}"];
|
25
|
+
|
26
|
+
exports.Scanner = Scanner;
|
27
|
+
exports.Context = Context;
|
28
|
+
exports.Writer = Writer;
|
29
|
+
|
30
|
+
var whiteRe = /\s*/;
|
31
|
+
var spaceRe = /\s+/;
|
32
|
+
var nonSpaceRe = /\S/;
|
33
|
+
var eqRe = /\s*=/;
|
34
|
+
var curlyRe = /\s*\}/;
|
35
|
+
var tagRe = /#|\^|\/|>|\{|&|=|!/;
|
36
|
+
|
37
|
+
// Workaround for https://issues.apache.org/jira/browse/COUCHDB-577
|
38
|
+
// See https://github.com/janl/mustache.js/issues/189
|
39
|
+
function testRe(re, string) {
|
40
|
+
return RegExp.prototype.test.call(re, string);
|
41
|
+
}
|
42
|
+
|
43
|
+
function isWhitespace(string) {
|
44
|
+
return !testRe(nonSpaceRe, string);
|
45
|
+
}
|
46
|
+
|
47
|
+
var isArray = Array.isArray || function (obj) {
|
48
|
+
return Object.prototype.toString.call(obj) === "[object Array]";
|
49
|
+
};
|
50
|
+
|
51
|
+
function escapeRe(string) {
|
52
|
+
return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
|
53
|
+
}
|
54
|
+
|
55
|
+
var entityMap = {
|
56
|
+
"&": "&",
|
57
|
+
"<": "<",
|
58
|
+
">": ">",
|
59
|
+
'"': '"',
|
60
|
+
"'": ''',
|
61
|
+
"/": '/'
|
62
|
+
};
|
63
|
+
|
64
|
+
function escapeHtml(string) {
|
65
|
+
return String(string).replace(/[&<>"'\/]/g, function (s) {
|
66
|
+
return entityMap[s];
|
67
|
+
});
|
68
|
+
}
|
69
|
+
|
70
|
+
// Export the escaping function so that the user may override it.
|
71
|
+
// See https://github.com/janl/mustache.js/issues/244
|
72
|
+
exports.escape = escapeHtml;
|
73
|
+
|
74
|
+
function Scanner(string) {
|
75
|
+
this.string = string;
|
76
|
+
this.tail = string;
|
77
|
+
this.pos = 0;
|
78
|
+
}
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Returns `true` if the tail is empty (end of string).
|
82
|
+
*/
|
83
|
+
Scanner.prototype.eos = function () {
|
84
|
+
return this.tail === "";
|
85
|
+
};
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Tries to match the given regular expression at the current position.
|
89
|
+
* Returns the matched text if it can match, the empty string otherwise.
|
90
|
+
*/
|
91
|
+
Scanner.prototype.scan = function (re) {
|
92
|
+
var match = this.tail.match(re);
|
93
|
+
|
94
|
+
if (match && match.index === 0) {
|
95
|
+
this.tail = this.tail.substring(match[0].length);
|
96
|
+
this.pos += match[0].length;
|
97
|
+
return match[0];
|
98
|
+
}
|
99
|
+
|
100
|
+
return "";
|
101
|
+
};
|
102
|
+
|
103
|
+
/**
|
104
|
+
* Skips all text until the given regular expression can be matched. Returns
|
105
|
+
* the skipped string, which is the entire tail if no match can be made.
|
106
|
+
*/
|
107
|
+
Scanner.prototype.scanUntil = function (re) {
|
108
|
+
var match, pos = this.tail.search(re);
|
109
|
+
|
110
|
+
switch (pos) {
|
111
|
+
case -1:
|
112
|
+
match = this.tail;
|
113
|
+
this.pos += this.tail.length;
|
114
|
+
this.tail = "";
|
115
|
+
break;
|
116
|
+
case 0:
|
117
|
+
match = "";
|
118
|
+
break;
|
119
|
+
default:
|
120
|
+
match = this.tail.substring(0, pos);
|
121
|
+
this.tail = this.tail.substring(pos);
|
122
|
+
this.pos += pos;
|
123
|
+
}
|
124
|
+
|
125
|
+
return match;
|
126
|
+
};
|
127
|
+
|
128
|
+
function Context(view, parent) {
|
129
|
+
this.view = view;
|
130
|
+
this.parent = parent;
|
131
|
+
this.clearCache();
|
132
|
+
}
|
133
|
+
|
134
|
+
Context.make = function (view) {
|
135
|
+
return (view instanceof Context) ? view : new Context(view);
|
136
|
+
};
|
137
|
+
|
138
|
+
Context.prototype.clearCache = function () {
|
139
|
+
this._cache = {};
|
140
|
+
};
|
141
|
+
|
142
|
+
Context.prototype.push = function (view) {
|
143
|
+
return new Context(view, this);
|
144
|
+
};
|
145
|
+
|
146
|
+
Context.prototype.lookup = function (name) {
|
147
|
+
var value = this._cache[name];
|
148
|
+
|
149
|
+
if (!value) {
|
150
|
+
if (name === ".") {
|
151
|
+
value = this.view;
|
152
|
+
} else {
|
153
|
+
var context = this;
|
154
|
+
|
155
|
+
while (context) {
|
156
|
+
if (name.indexOf(".") > 0) {
|
157
|
+
var names = name.split("."), i = 0;
|
158
|
+
|
159
|
+
value = context.view;
|
160
|
+
|
161
|
+
while (value && i < names.length) {
|
162
|
+
value = value[names[i++]];
|
163
|
+
}
|
164
|
+
} else {
|
165
|
+
value = context.view[name];
|
166
|
+
}
|
167
|
+
|
168
|
+
if (value != null) {
|
169
|
+
break;
|
170
|
+
}
|
171
|
+
|
172
|
+
context = context.parent;
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
this._cache[name] = value;
|
177
|
+
}
|
178
|
+
|
179
|
+
if (typeof value === "function") {
|
180
|
+
value = value.call(this.view);
|
181
|
+
}
|
182
|
+
|
183
|
+
return value;
|
184
|
+
};
|
185
|
+
|
186
|
+
function Writer() {
|
187
|
+
this.clearCache();
|
188
|
+
}
|
189
|
+
|
190
|
+
Writer.prototype.clearCache = function () {
|
191
|
+
this._cache = {};
|
192
|
+
this._partialCache = {};
|
193
|
+
};
|
194
|
+
|
195
|
+
Writer.prototype.compile = function (template, tags) {
|
196
|
+
return this._compile(this._cache, template, template, tags);
|
197
|
+
};
|
198
|
+
|
199
|
+
Writer.prototype.compilePartial = function (name, template, tags) {
|
200
|
+
return this._compile(this._partialCache, name, template, tags);
|
201
|
+
};
|
202
|
+
|
203
|
+
Writer.prototype.render = function (template, view, partials) {
|
204
|
+
return this.compile(template)(view, partials);
|
205
|
+
};
|
206
|
+
|
207
|
+
Writer.prototype._compile = function (cache, key, template, tags) {
|
208
|
+
if (!cache[key]) {
|
209
|
+
var tokens = exports.parse(template, tags);
|
210
|
+
var fn = compileTokens(tokens);
|
211
|
+
|
212
|
+
var self = this;
|
213
|
+
cache[key] = function (view, partials) {
|
214
|
+
if (partials) {
|
215
|
+
if (typeof partials === "function") {
|
216
|
+
self._loadPartial = partials;
|
217
|
+
} else {
|
218
|
+
for (var name in partials) {
|
219
|
+
self.compilePartial(name, partials[name]);
|
220
|
+
}
|
221
|
+
}
|
222
|
+
}
|
223
|
+
|
224
|
+
return fn(self, Context.make(view), template);
|
225
|
+
};
|
226
|
+
}
|
227
|
+
|
228
|
+
return cache[key];
|
229
|
+
};
|
230
|
+
|
231
|
+
Writer.prototype._section = function (name, context, text, callback) {
|
232
|
+
var value = context.lookup(name);
|
233
|
+
|
234
|
+
switch (typeof value) {
|
235
|
+
case "object":
|
236
|
+
if (isArray(value)) {
|
237
|
+
var buffer = "";
|
238
|
+
|
239
|
+
for (var i = 0, len = value.length; i < len; ++i) {
|
240
|
+
buffer += callback(this, context.push(value[i]));
|
241
|
+
}
|
242
|
+
|
243
|
+
return buffer;
|
244
|
+
}
|
245
|
+
|
246
|
+
return value ? callback(this, context.push(value)) : "";
|
247
|
+
case "function":
|
248
|
+
var self = this;
|
249
|
+
var scopedRender = function (template) {
|
250
|
+
return self.render(template, context);
|
251
|
+
};
|
252
|
+
|
253
|
+
return value.call(context.view, text, scopedRender) || "";
|
254
|
+
default:
|
255
|
+
if (value) {
|
256
|
+
return callback(this, context);
|
257
|
+
}
|
258
|
+
}
|
259
|
+
|
260
|
+
return "";
|
261
|
+
};
|
262
|
+
|
263
|
+
Writer.prototype._inverted = function (name, context, callback) {
|
264
|
+
var value = context.lookup(name);
|
265
|
+
|
266
|
+
// Use JavaScript's definition of falsy. Include empty arrays.
|
267
|
+
// See https://github.com/janl/mustache.js/issues/186
|
268
|
+
if (!value || (isArray(value) && value.length === 0)) {
|
269
|
+
return callback(this, context);
|
270
|
+
}
|
271
|
+
|
272
|
+
return "";
|
273
|
+
};
|
274
|
+
|
275
|
+
Writer.prototype._partial = function (name, context) {
|
276
|
+
if (!(name in this._partialCache) && this._loadPartial) {
|
277
|
+
this.compilePartial(name, this._loadPartial(name));
|
278
|
+
}
|
279
|
+
|
280
|
+
var fn = this._partialCache[name];
|
281
|
+
|
282
|
+
return fn ? fn(context) : "";
|
283
|
+
};
|
284
|
+
|
285
|
+
Writer.prototype._name = function (name, context) {
|
286
|
+
var value = context.lookup(name);
|
287
|
+
|
288
|
+
if (typeof value === "function") {
|
289
|
+
value = value.call(context.view);
|
290
|
+
}
|
291
|
+
|
292
|
+
return (value == null) ? "" : String(value);
|
293
|
+
};
|
294
|
+
|
295
|
+
Writer.prototype._escaped = function (name, context) {
|
296
|
+
return exports.escape(this._name(name, context));
|
297
|
+
};
|
298
|
+
|
299
|
+
/**
|
300
|
+
* Calculates the bounds of the section represented by the given `token` in
|
301
|
+
* the original template by drilling down into nested sections to find the
|
302
|
+
* last token that is part of that section. Returns an array of [start, end].
|
303
|
+
*/
|
304
|
+
function sectionBounds(token) {
|
305
|
+
var start = token[3];
|
306
|
+
var end = start;
|
307
|
+
|
308
|
+
var tokens;
|
309
|
+
while ((tokens = token[4]) && tokens.length) {
|
310
|
+
token = tokens[tokens.length - 1];
|
311
|
+
end = token[3];
|
312
|
+
}
|
313
|
+
|
314
|
+
return [start, end];
|
315
|
+
}
|
316
|
+
|
317
|
+
/**
|
318
|
+
* Low-level function that compiles the given `tokens` into a function
|
319
|
+
* that accepts two arguments: a Context and a Writer.
|
320
|
+
*/
|
321
|
+
function compileTokens(tokens) {
|
322
|
+
var subRenders = {};
|
323
|
+
|
324
|
+
function subRender(i, tokens, template) {
|
325
|
+
if (!subRenders[i]) {
|
326
|
+
var fn = compileTokens(tokens);
|
327
|
+
subRenders[i] = function (writer, context) {
|
328
|
+
return fn(writer, context, template);
|
329
|
+
};
|
330
|
+
}
|
331
|
+
|
332
|
+
return subRenders[i];
|
333
|
+
}
|
334
|
+
|
335
|
+
function renderFunction(writer, context, template) {
|
336
|
+
var buffer = "";
|
337
|
+
var token, sectionText;
|
338
|
+
|
339
|
+
for (var i = 0, len = tokens.length; i < len; ++i) {
|
340
|
+
token = tokens[i];
|
341
|
+
|
342
|
+
switch (token[0]) {
|
343
|
+
case "#":
|
344
|
+
sectionText = template.slice.apply(template, sectionBounds(token));
|
345
|
+
buffer += writer._section(token[1], context, sectionText, subRender(i, token[4], template));
|
346
|
+
break;
|
347
|
+
case "^":
|
348
|
+
buffer += writer._inverted(token[1], context, subRender(i, token[4], template));
|
349
|
+
break;
|
350
|
+
case ">":
|
351
|
+
buffer += writer._partial(token[1], context);
|
352
|
+
break;
|
353
|
+
case "&":
|
354
|
+
buffer += writer._name(token[1], context);
|
355
|
+
break;
|
356
|
+
case "name":
|
357
|
+
buffer += writer._escaped(token[1], context);
|
358
|
+
break;
|
359
|
+
case "text":
|
360
|
+
buffer += token[1];
|
361
|
+
break;
|
362
|
+
}
|
363
|
+
}
|
364
|
+
|
365
|
+
return buffer;
|
366
|
+
}
|
367
|
+
|
368
|
+
return renderFunction;
|
369
|
+
}
|
370
|
+
|
371
|
+
/**
|
372
|
+
* Forms the given array of `tokens` into a nested tree structure where
|
373
|
+
* tokens that represent a section have a fifth item: an array that contains
|
374
|
+
* all tokens in that section.
|
375
|
+
*/
|
376
|
+
function nestTokens(tokens) {
|
377
|
+
var tree = [];
|
378
|
+
var collector = tree;
|
379
|
+
var sections = [];
|
380
|
+
var token, section;
|
381
|
+
|
382
|
+
for (var i = 0; i < tokens.length; ++i) {
|
383
|
+
token = tokens[i];
|
384
|
+
|
385
|
+
switch (token[0]) {
|
386
|
+
case "#":
|
387
|
+
case "^":
|
388
|
+
token[4] = [];
|
389
|
+
sections.push(token);
|
390
|
+
collector.push(token);
|
391
|
+
collector = token[4];
|
392
|
+
break;
|
393
|
+
case "/":
|
394
|
+
if (sections.length === 0) {
|
395
|
+
throw new Error("Unopened section: " + token[1]);
|
396
|
+
}
|
397
|
+
|
398
|
+
section = sections.pop();
|
399
|
+
|
400
|
+
if (section[1] !== token[1]) {
|
401
|
+
throw new Error("Unclosed section: " + section[1]);
|
402
|
+
}
|
403
|
+
|
404
|
+
if (sections.length > 0) {
|
405
|
+
collector = sections[sections.length - 1][4];
|
406
|
+
} else {
|
407
|
+
collector = tree;
|
408
|
+
}
|
409
|
+
break;
|
410
|
+
default:
|
411
|
+
collector.push(token);
|
412
|
+
}
|
413
|
+
}
|
414
|
+
|
415
|
+
// Make sure there were no open sections when we're done.
|
416
|
+
section = sections.pop();
|
417
|
+
|
418
|
+
if (section) {
|
419
|
+
throw new Error("Unclosed section: " + section[1]);
|
420
|
+
}
|
421
|
+
|
422
|
+
return tree;
|
423
|
+
}
|
424
|
+
|
425
|
+
/**
|
426
|
+
* Combines the values of consecutive text tokens in the given `tokens` array
|
427
|
+
* to a single token.
|
428
|
+
*/
|
429
|
+
function squashTokens(tokens) {
|
430
|
+
var token, lastToken;
|
431
|
+
|
432
|
+
for (var i = 0; i < tokens.length; ++i) {
|
433
|
+
token = tokens[i];
|
434
|
+
|
435
|
+
if (lastToken && lastToken[0] === "text" && token[0] === "text") {
|
436
|
+
lastToken[1] += token[1];
|
437
|
+
lastToken[3] = token[3];
|
438
|
+
tokens.splice(i--, 1); // Remove this token from the array.
|
439
|
+
} else {
|
440
|
+
lastToken = token;
|
441
|
+
}
|
442
|
+
}
|
443
|
+
}
|
444
|
+
|
445
|
+
function escapeTags(tags) {
|
446
|
+
if (tags.length !== 2) {
|
447
|
+
throw new Error("Invalid tags: " + tags.join(" "));
|
448
|
+
}
|
449
|
+
|
450
|
+
return [
|
451
|
+
new RegExp(escapeRe(tags[0]) + "\\s*"),
|
452
|
+
new RegExp("\\s*" + escapeRe(tags[1]))
|
453
|
+
];
|
454
|
+
}
|
455
|
+
|
456
|
+
/**
|
457
|
+
* Breaks up the given `template` string into a tree of token objects. If
|
458
|
+
* `tags` is given here it must be an array with two string values: the
|
459
|
+
* opening and closing tags used in the template (e.g. ["<%", "%>"]). Of
|
460
|
+
* course, the default is to use mustaches (i.e. Mustache.tags).
|
461
|
+
*/
|
462
|
+
exports.parse = function (template, tags) {
|
463
|
+
tags = tags || exports.tags;
|
464
|
+
|
465
|
+
var tagRes = escapeTags(tags);
|
466
|
+
var scanner = new Scanner(template);
|
467
|
+
|
468
|
+
var tokens = [], // Buffer to hold the tokens
|
469
|
+
spaces = [], // Indices of whitespace tokens on the current line
|
470
|
+
hasTag = false, // Is there a {{tag}} on the current line?
|
471
|
+
nonSpace = false; // Is there a non-space char on the current line?
|
472
|
+
|
473
|
+
// Strips all whitespace tokens array for the current line
|
474
|
+
// if there was a {{#tag}} on it and otherwise only space.
|
475
|
+
function stripSpace() {
|
476
|
+
if (hasTag && !nonSpace) {
|
477
|
+
while (spaces.length) {
|
478
|
+
tokens.splice(spaces.pop(), 1);
|
479
|
+
}
|
480
|
+
} else {
|
481
|
+
spaces = [];
|
482
|
+
}
|
483
|
+
|
484
|
+
hasTag = false;
|
485
|
+
nonSpace = false;
|
486
|
+
}
|
487
|
+
|
488
|
+
var start, type, value, chr;
|
489
|
+
|
490
|
+
while (!scanner.eos()) {
|
491
|
+
start = scanner.pos;
|
492
|
+
value = scanner.scanUntil(tagRes[0]);
|
493
|
+
|
494
|
+
if (value) {
|
495
|
+
for (var i = 0, len = value.length; i < len; ++i) {
|
496
|
+
chr = value.charAt(i);
|
497
|
+
|
498
|
+
if (isWhitespace(chr)) {
|
499
|
+
spaces.push(tokens.length);
|
500
|
+
} else {
|
501
|
+
nonSpace = true;
|
502
|
+
}
|
503
|
+
|
504
|
+
tokens.push(["text", chr, start, start + 1]);
|
505
|
+
start += 1;
|
506
|
+
|
507
|
+
if (chr === "\n") {
|
508
|
+
stripSpace(); // Check for whitespace on the current line.
|
509
|
+
}
|
510
|
+
}
|
511
|
+
}
|
512
|
+
|
513
|
+
start = scanner.pos;
|
514
|
+
|
515
|
+
// Match the opening tag.
|
516
|
+
if (!scanner.scan(tagRes[0])) {
|
517
|
+
break;
|
518
|
+
}
|
519
|
+
|
520
|
+
hasTag = true;
|
521
|
+
type = scanner.scan(tagRe) || "name";
|
522
|
+
|
523
|
+
// Skip any whitespace between tag and value.
|
524
|
+
scanner.scan(whiteRe);
|
525
|
+
|
526
|
+
// Extract the tag value.
|
527
|
+
if (type === "=") {
|
528
|
+
value = scanner.scanUntil(eqRe);
|
529
|
+
scanner.scan(eqRe);
|
530
|
+
scanner.scanUntil(tagRes[1]);
|
531
|
+
} else if (type === "{") {
|
532
|
+
var closeRe = new RegExp("\\s*" + escapeRe("}" + tags[1]));
|
533
|
+
value = scanner.scanUntil(closeRe);
|
534
|
+
scanner.scan(curlyRe);
|
535
|
+
scanner.scanUntil(tagRes[1]);
|
536
|
+
type = "&";
|
537
|
+
} else {
|
538
|
+
value = scanner.scanUntil(tagRes[1]);
|
539
|
+
}
|
540
|
+
|
541
|
+
// Match the closing tag.
|
542
|
+
if (!scanner.scan(tagRes[1])) {
|
543
|
+
throw new Error("Unclosed tag at " + scanner.pos);
|
544
|
+
}
|
545
|
+
|
546
|
+
tokens.push([type, value, start, scanner.pos]);
|
547
|
+
|
548
|
+
if (type === "name" || type === "{" || type === "&") {
|
549
|
+
nonSpace = true;
|
550
|
+
}
|
551
|
+
|
552
|
+
// Set the tags for the next time around.
|
553
|
+
if (type === "=") {
|
554
|
+
tags = value.split(spaceRe);
|
555
|
+
tagRes = escapeTags(tags);
|
556
|
+
}
|
557
|
+
}
|
558
|
+
|
559
|
+
squashTokens(tokens);
|
560
|
+
|
561
|
+
return nestTokens(tokens);
|
562
|
+
};
|
563
|
+
|
564
|
+
// The high-level clearCache, compile, compilePartial, and render functions
|
565
|
+
// use this default writer.
|
566
|
+
var _writer = new Writer();
|
567
|
+
|
568
|
+
/**
|
569
|
+
* Clears all cached templates and partials in the default writer.
|
570
|
+
*/
|
571
|
+
exports.clearCache = function () {
|
572
|
+
return _writer.clearCache();
|
573
|
+
};
|
574
|
+
|
575
|
+
/**
|
576
|
+
* Compiles the given `template` to a reusable function using the default
|
577
|
+
* writer.
|
578
|
+
*/
|
579
|
+
exports.compile = function (template, tags) {
|
580
|
+
return _writer.compile(template, tags);
|
581
|
+
};
|
582
|
+
|
583
|
+
/**
|
584
|
+
* Compiles the partial with the given `name` and `template` to a reusable
|
585
|
+
* function using the default writer.
|
586
|
+
*/
|
587
|
+
exports.compilePartial = function (name, template, tags) {
|
588
|
+
return _writer.compilePartial(name, template, tags);
|
589
|
+
};
|
590
|
+
|
591
|
+
/**
|
592
|
+
* Renders the `template` with the given `view` and `partials` using the
|
593
|
+
* default writer.
|
594
|
+
*/
|
595
|
+
exports.render = function (template, view, partials) {
|
596
|
+
return _writer.render(template, view, partials);
|
597
|
+
};
|
598
|
+
|
599
|
+
// This is here for backwards compatibility with 0.4.x.
|
600
|
+
exports.to_html = function (template, view, partials, send) {
|
601
|
+
var result = exports.render(template, view, partials);
|
602
|
+
|
603
|
+
if (typeof send === "function") {
|
604
|
+
send(result);
|
605
|
+
} else {
|
606
|
+
return result;
|
607
|
+
}
|
608
|
+
};
|
609
|
+
|
610
|
+
return exports;
|
611
|
+
|
612
|
+
}())));
|
@@ -305,6 +305,8 @@ nv.models.axis = function() {
|
|
305
305
|
|
306
306
|
d3.transition(g)
|
307
307
|
.call(axis);
|
308
|
+
// g.call(axis);
|
309
|
+
|
308
310
|
|
309
311
|
scale0 = scale0 || axis.scale();
|
310
312
|
|
@@ -3229,6 +3231,7 @@ nv.models.lineChart = function() {
|
|
3229
3231
|
.datum(data.filter(function(d) { return !d.disabled }))
|
3230
3232
|
|
3231
3233
|
d3.transition(linesWrap).call(lines);
|
3234
|
+
//linesWrap.call(lines);
|
3232
3235
|
|
3233
3236
|
|
3234
3237
|
|
@@ -3241,6 +3244,8 @@ nv.models.lineChart = function() {
|
|
3241
3244
|
.attr('transform', 'translate(0,' + y.range()[0] + ')');
|
3242
3245
|
d3.transition(g.select('.nv-x.nv-axis'))
|
3243
3246
|
.call(xAxis);
|
3247
|
+
// g.select('.nv-x.nv-axis')
|
3248
|
+
// .call(xAxis);
|
3244
3249
|
|
3245
3250
|
|
3246
3251
|
yAxis
|
@@ -3250,6 +3255,8 @@ nv.models.lineChart = function() {
|
|
3250
3255
|
|
3251
3256
|
d3.transition(g.select('.nv-y.nv-axis'))
|
3252
3257
|
.call(yAxis);
|
3258
|
+
// g.select('.nv-y.nv-axis')
|
3259
|
+
// .call(yAxis);
|
3253
3260
|
|
3254
3261
|
|
3255
3262
|
|
@@ -3268,7 +3275,8 @@ nv.models.lineChart = function() {
|
|
3268
3275
|
});
|
3269
3276
|
}
|
3270
3277
|
|
3271
|
-
selection.transition().call(chart);
|
3278
|
+
//selection.transition().call(chart);
|
3279
|
+
selection.call(chart);
|
3272
3280
|
});
|
3273
3281
|
|
3274
3282
|
/*
|