forked from knockout/knockout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
knockout-raw.js
34 lines (30 loc) · 1.55 KB
/
knockout-raw.js
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
var DEBUG = true,
// ensure these variables are defined (even if their values are undefined)
jQueryInstance = window.jQuery, // Use a different variable name (not 'jQuery') to avoid overwriting window.jQuery with 'undefined' on IE < 9
amdRequire = window.require;
// This script adds <script> tags referencing each of the knockout.js source files in the correct order
// It uses JSONP to fetch the list of source files from source-references.js
(function () {
var debugFileName = "build/knockout-raw.js";
var sourcesReferenceFile = "build/fragments/source-references.js";
function getPathToScriptTagSrc(scriptTagSrc) {
scriptTagSrc = "/" + scriptTagSrc.toLowerCase();
var scriptTags = document.getElementsByTagName("SCRIPT");
for (var i = 0; i < scriptTags.length; i++) {
var src = scriptTags[i].src;
var index = src.toLowerCase().indexOf(scriptTagSrc);
if ((index >= 0) && index == (src.length - scriptTagSrc.length))
return src.substring(0, index + 1);
}
throw "Cannot find script tag referencing " + scriptTagSrc;
};
function referenceScript(url) {
document.write("<script src='" + url + "' type='text/javascript'></script>");
};
var buildFolderPath = getPathToScriptTagSrc(debugFileName);
window.knockoutDebugCallback = function (scriptUrls) {
for (var i = 0; i < scriptUrls.length; i++)
referenceScript(buildFolderPath + scriptUrls[i]);
};
referenceScript(buildFolderPath + sourcesReferenceFile);
})();