Merge branch 'master' into split
[dygraphs.git] / dygraph-dev.js
... / ...
CommitLineData
1// A dygraph "auto-loader".
2
3// Check where this script was sourced from. If it was sourced from
4// '../dygraph-dev.js', then we should source all the other scripts with the
5// same relative path ('../dygraph.js', '../dygraph-canvas.js', ...)
6(function() {
7 var src=document.getElementsByTagName('script');
8 var script = src[src.length-1].getAttribute("src");
9 var m = /^(.*)\/[^/]*\.js$/.exec(script);
10 if (!m) {
11 console.error("Can't grok dygraph-dev.js path: " + script);
12 } else {
13 var path = m[1]; // captured group, not the full match.
14
15 // This list needs to be kept in sync w/ the one in generate-combined.sh
16 var source_files = [
17 "strftime/strftime-min.js",
18 "rgbcolor/rgbcolor.js",
19 "dygraph-layout.js",
20 "dygraph-canvas.js",
21 "dygraph.js",
22 "dygraph-gviz.js",
23 "dygraph-debug.js" // Shouldn't be included in generate-combined.sh
24 ];
25
26 for (var i = 0; i < source_files.length; i++) {
27 document.write('<script type="text/javascript" src="' + path + '/' + source_files[i] + '"></script>\n');
28 }
29 }
30})();