File: knockout-raw.js

package info (click to toggle)
node-knockout 3.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 2,304 kB
  • sloc: javascript: 26,455; makefile: 5
file content (34 lines) | stat: -rw-r--r-- 1,584 bytes parent folder | download | duplicates (4)
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);
})();