knockout-raw.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. var DEBUG = true,
  2. // ensure these variables are defined (even if their values are undefined)
  3. jQueryInstance = window.jQuery, // Use a different variable name (not 'jQuery') to avoid overwriting window.jQuery with 'undefined' on IE < 9
  4. require = window.require;
  5. // This script adds <script> tags referencing each of the knockout.js source files in the correct order
  6. // It uses JSONP to fetch the list of source files from source-references.js
  7. (function () {
  8. var debugFileName = "build/knockout-raw.js";
  9. var sourcesReferenceFile = "build/fragments/source-references.js";
  10. function getPathToScriptTagSrc(scriptTagSrc) {
  11. scriptTagSrc = "/" + scriptTagSrc.toLowerCase();
  12. var scriptTags = document.getElementsByTagName("SCRIPT");
  13. for (var i = 0; i < scriptTags.length; i++) {
  14. var src = scriptTags[i].src;
  15. var index = src.toLowerCase().indexOf(scriptTagSrc);
  16. if ((index >= 0) && index == (src.length - scriptTagSrc.length))
  17. return src.substring(0, index + 1);
  18. }
  19. throw "Cannot find script tag referencing " + scriptTagSrc;
  20. };
  21. function referenceScript(url) {
  22. document.write("<script src='" + url + "' type='text/javascript'></script>");
  23. };
  24. var buildFolderPath = getPathToScriptTagSrc(debugFileName);
  25. window.knockoutDebugCallback = function (scriptUrls) {
  26. for (var i = 0; i < scriptUrls.length; i++)
  27. referenceScript(buildFolderPath + scriptUrls[i]);
  28. };
  29. referenceScript(buildFolderPath + sourcesReferenceFile);
  30. })();