// A dygraph "auto-loader".

// Check where this script was sourced from. If it was sourced from
// '../dygraph-dev.js', then we should source all the other scripts with the
// same relative path ('../dygraph.js', '../dygraph-canvas.js', ...)
(function() {
  var src=document.getElementsByTagName('script');
  var script = src[src.length-1].getAttribute("src");
  var m = /^(.*)\/[^/]*\.js$/.exec(script);
  if (!m) {
    console.error("Can't grok dygraph-dev.js path: " + script);
  } else {
    var path = m[1];  // captured group, not the full match.

    // This list needs to be kept in sync w/ the one in generate-combined.sh
    // and the one in jsTestDriver.conf.
    var source_files = [
      "strftime/strftime-min.js",
      "rgbcolor/rgbcolor.js",
      "dygraph-layout.js",
      "dygraph-canvas.js",
      "dygraph.js",
      "dygraph-utils.js",
      "dygraph-gviz.js",
      "dygraph-interaction-model.js",
      "dygraph-options-reference.js"  // Shouldn't be included in generate-combined.sh
    ];

    for (var i = 0; i < source_files.length; i++) {
      document.write('<script type="text/javascript" src="' + path + '/' + source_files[i] + '"></script>\n');
    }
  }
})();

@@ -359,203 +359,9 @@
 %22);%0A
-  var m = /%5E(.*)%5C/%5B%5E/%5D*%5C.js$/.exec(script);%0A  if (!m) %7B%0A    console.error(%22Can't grok dygraph-dev.js path: %22 + script);%0A  %7D else %7B%0A    var path = m%5B1%5D;  // captured group, not the full match.%0A%0A  
+%0A
   //
@@ -431,18 +431,16 @@
 ined.sh%0A
-  
   // and
@@ -470,18 +470,16 @@
 r.conf.%0A
-  
   var so
@@ -497,18 +497,16 @@
 = %5B%0A    
- 
- 
 %22strftim
@@ -529,18 +529,16 @@
 s%22,%0A    
-  
 %22rgbcolo
@@ -549,26 +549,24 @@
 bcolor.js%22,%0A
-  
     %22dygraph
@@ -574,34 +574,32 @@
 layout.js%22,%0A    
-  
 %22dygraph-canvas.
@@ -599,26 +599,24 @@
 canvas.js%22,%0A
-  
     %22dygraph
@@ -617,34 +617,32 @@
 ygraph.js%22,%0A    
-  
 %22dygraph-utils.j
@@ -641,26 +641,24 @@
 -utils.js%22,%0A
-  
     %22dygraph
@@ -664,34 +664,32 @@
 h-gviz.js%22,%0A    
-  
 %22dygraph-interac
@@ -704,18 +704,16 @@
 el.js%22,%0A
-  
     %22dyg
@@ -793,18 +793,14 @@
 .sh%0A
-  
   %5D;%0A%0A
-  
   fo
@@ -845,18 +845,16 @@
  i++) %7B%0A
-  
     docu
@@ -909,20 +909,40 @@
 ' + 
-path + '/' +
+script.replace('dygraph-dev.js',
  sou
@@ -953,16 +953,17 @@
 files%5Bi%5D
+)
  + '%22%3E%3C/
@@ -979,14 +979,8 @@
 ');%0A
-    %7D%0A
   %7D%0A

make dygraph-dev a bit smarter