Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. app = {};
  2. app.modules = [];
  3. app.loadScript = function (url, callback) {
  4.     var script = document.createElement("script");
  5.     script.type = "text/javascript";
  6.  
  7.     if (script.readyState) {  //IE
  8.         script.onreadystatechange = function () {
  9.             if (script.readyState == "loaded" ||
  10.                 script.readyState == "complete") {
  11.                 script.onreadystatechange = null;
  12.  
  13.                 if (callback) {
  14.                     callback();
  15.                 }
  16.             }
  17.         };
  18.     } else {  //Others
  19.         script.onload = function () {
  20.             if (callback) {
  21.                 callback();
  22.             }
  23.         };
  24.     }
  25.  
  26.     script.src = url;
  27.     document.getElementsByTagName("head")[0].appendChild(script);
  28. };
  29.  
  30. app.loadModules = function () {
  31.     var that = this;
  32.     $.each(that.modules, function (key, value) {
  33.         that.loadScript(value);
  34.     });
  35. };
  36.  
  37. app.init = function () {
  38.     var that = this;
  39.     that.loadModules();
  40. };
  41.  
  42. app.modules = [
  43.     '/js/app/admin/forum/list.js'
  44. ];
  45.  
  46. app.init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement