|
1 |
| -'use strict'; |
| 1 | + |
| 2 | +/*! |
| 3 | + * $script.js Async loader & dependency manager |
| 4 | + * https://github.com/ded/script.js |
| 5 | + * (c) Dustin Diaz, Jacob Thornton 2011 |
| 6 | + * License: MIT |
| 7 | + */ |
| 8 | +(function(a,b){typeof module!="undefined"?module.exports=b():typeof define=="function"&&define.amd?define(a,b):this[a]=b()})("$script",function(){function q(a,b,c){for(c=0,j=a.length;c<j;++c)if(!b(a[c]))return k;return 1}function r(a,b){q(a,function(a){return!b(a)})}function s(a,b,i){function o(a){return a.call?a():d[a]}function p(){if(!--n){d[m]=1,k&&k();for(var a in f)q(a.split("|"),o)&&!r(f[a],o)&&(f[a]=[])}}a=a[l]?a:[a];var j=b&&b.call,k=j?b:i,m=j?a.join(""):b,n=a.length;return setTimeout(function(){r(a,function(a){if(h[a])return m&&(e[m]=1),h[a]==2&&p();h[a]=1,m&&(e[m]=1),t(!c.test(a)&&g?g+a+".js":a,p)})},0),s}function t(c,d){var e=a.createElement("script"),f=k;e.onload=e.onerror=e[p]=function(){if(e[n]&&!/^c|loade/.test(e[n])||f)return;e.onload=e[p]=null,f=1,h[c]=2,d()},e.async=1,e.src=c,b.insertBefore(e,b.firstChild)}var a=document,b=a.getElementsByTagName("head")[0],c=/^https?:\/\//,d={},e={},f={},g,h={},i="string",k=!1,l="push",m="DOMContentLoaded",n="readyState",o="addEventListener",p="onreadystatechange";return!a[n]&&a[o]&&(a[o](m,function u(){a.removeEventListener(m,u,k),a[n]="complete"},k),a[n]="loading"),s.get=t,s.order=function(a,b,c){(function d(e){e=a.shift(),a.length?s(e,d):s(e,b,c)})()},s.path=function(a){g=a},s.ready=function(a,b,c){a=a[l]?a:[a];var e=[];return!r(a,function(a){d[a]||e[l](a)})&&q(a,function(a){return d[a]})?b():!function(a){f[a]=f[a]||[],f[a][l](b),c&&c(e)}(a.join("|")),s},s}); |
2 | 9 |
|
3 | 10 | /**
|
4 | 11 | * @license AngularJS
|
|
11 | 18 | scripts = document.getElementsByTagName("SCRIPT"),
|
12 | 19 | serverPath,
|
13 | 20 | match,
|
14 |
| - globalVars = {}; |
| 21 | + globalVars = {}, |
| 22 | + IGNORE = { |
| 23 | + onkeyup: true, onkeydown: true, onresize: true, |
| 24 | + event: true, frames: true, external: true, |
| 25 | + sessionStorage: true, clipboardData: true, localStorage: true}; |
15 | 26 |
|
16 | 27 | for(var j = 0; j < scripts.length; j++) {
|
17 | 28 | match = (scripts[j].src || "").match(filename);
|
|
20 | 31 | }
|
21 | 32 | }
|
22 | 33 |
|
| 34 | + document.write('<link rel="stylesheet" type="text/css" href="' + serverPath + '../css/angular.css"/>'); |
| 35 | + |
| 36 | + $script.path(serverPath+'../'); |
| 37 | + $script('angularFiles', function() { |
| 38 | + var index = 0, |
| 39 | + scripts = angularFiles.angularSrc; |
| 40 | + |
| 41 | + try { delete window.angularFiles; } catch(e) { window.angularFiles = undefined; } |
| 42 | + // initialize the window property cache |
| 43 | + for (var prop in window) { |
| 44 | + if (IGNORE[prop] || prop.match(/^moz[A-Z]/)) { //skip special variables which keep on changing |
| 45 | + continue; |
| 46 | + } |
| 47 | + try { |
| 48 | + globalVars[key(prop)] = window[prop]; |
| 49 | + } catch(e) {} //ignore properties that throw exception when accessed (common in FF) |
| 50 | + } |
| 51 | + |
| 52 | + (function next() { |
| 53 | + if (index < scripts.length) { |
| 54 | + var file = scripts[index++]; |
| 55 | + |
| 56 | + $script(file.replace(/\.js$/, ''), function() { |
| 57 | + angularClobberTest(file); |
| 58 | + next(); |
| 59 | + }); |
| 60 | + } else { |
| 61 | + // empty the cache to prevent mem leaks |
| 62 | + globalVars = {}; |
| 63 | + |
| 64 | + bindJQuery(); |
| 65 | + publishExternalAPI(window.angular); |
| 66 | + |
| 67 | + angularInit(document, angular.bootstrap); |
| 68 | + } |
| 69 | + })(); |
| 70 | + }); |
| 71 | + |
23 | 72 | function key(prop) {
|
24 | 73 | return "ng-clobber_" + prop;
|
25 | 74 | }
|
26 | 75 |
|
27 |
| - window.angularClobberTest = function(file) { |
| 76 | + function angularClobberTest(file) { |
28 | 77 | var varKey, prop,
|
29 |
| - clobbered = []; |
| 78 | + clobbered = {}; |
30 | 79 |
|
31 | 80 | for (prop in window) {
|
32 | 81 | varKey = key(prop);
|
33 | 82 |
|
34 |
| - if (prop === 'event') { //skip special variables which keep on changing |
| 83 | + if (IGNORE[prop] || prop.match(/^moz[A-Z]/)) { //skip special variables which keep on changing |
35 | 84 | continue;
|
36 |
| - } |
37 |
| - else if (!globalVars.hasOwnProperty(varKey)) { |
| 85 | + } else if (!globalVars.hasOwnProperty(varKey)) { |
38 | 86 | //console.log('new global variable found: ', prop);
|
39 | 87 | try {
|
40 | 88 | globalVars[varKey] = window[prop];
|
41 | 89 | } catch(e) {} //ignore properties that throw exception when accessed (common in FF)
|
42 | 90 | } else if (globalVars[varKey] !== window[prop] && !isActuallyNaN(window[prop]) && prop != 'jqLite') {
|
43 |
| - clobbered.push(prop); |
| 91 | + clobbered[prop] = true; |
44 | 92 | console.error("Global variable clobbered by script " + file + "! Variable name: " + prop);
|
45 | 93 | globalVars[varKey] = window[prop];
|
46 | 94 | }
|
47 | 95 | }
|
48 | 96 | for (varKey in globalVars) {
|
49 | 97 | prop = varKey.substr(11);
|
50 |
| - if (clobbered.indexOf(prop) == -1 && |
| 98 | + if (prop === 'event' || prop.match(/^moz[A-Z]/)) { //skip special variables which keep on changing |
| 99 | + continue; |
| 100 | + } |
| 101 | + if (!clobbered[prop] && |
51 | 102 | prop != 'event' &&
|
52 | 103 | prop != 'jqLite' &&
|
53 | 104 | !isActuallyNaN(globalVars[varKey]) &&
|
|
60 | 111 | }
|
61 | 112 |
|
62 | 113 | function isActuallyNaN(val) {
|
63 |
| - return isNaN(val) && (typeof val === 'number'); |
64 |
| - } |
65 |
| - }; |
66 |
| - |
67 |
| - window.addScripts = function(scripts) { |
68 |
| - delete window.addScripts; |
69 |
| - delete window.angularFiles; |
70 |
| - |
71 |
| - var prop, i; |
72 |
| - |
73 |
| - // initialize the window property cache |
74 |
| - for (prop in window) { |
75 |
| - try { |
76 |
| - globalVars[key(prop)] = window[prop]; |
77 |
| - } catch(e) {} //ignore properties that throw exception when accessed (common in FF) |
78 |
| - } |
79 |
| - |
80 |
| - // load the js scripts |
81 |
| - for (i in scripts) { |
82 |
| - var file = scripts[i].replace(/src\//, ''); |
83 |
| - document.write('<script type="text/javascript" src="' + serverPath + file + '" ' + |
84 |
| - 'onload="angularClobberTest(\'' + file + '\')"></script>'); |
| 114 | + return (typeof val === 'number') && isNaN(val); |
85 | 115 | }
|
86 | 116 | };
|
87 |
| - |
88 |
| - function addCss(file) { |
89 |
| - document.write('<link rel="stylesheet" type="text/css" href="' + |
90 |
| - serverPath + '../css/' + file + '"/>'); |
91 |
| - } |
92 |
| - |
93 |
| - addCss('angular.css'); |
94 |
| - |
95 |
| - document.write('<script type="text/javascript" src="' + serverPath + '../angularFiles.js' + '" ' + |
96 |
| - 'onload="addScripts(angularFiles.angularSrc)"></script>'); |
97 |
| - |
98 |
| - function onLoadListener() { |
99 |
| - // empty the cache to prevent mem leaks |
100 |
| - globalVars = {}; |
101 |
| - |
102 |
| - bindJQuery(); |
103 |
| - publishExternalAPI(window.angular); |
104 |
| - |
105 |
| - angularInit(document, angular.bootstrap); |
106 |
| - } |
107 |
| - |
108 |
| - if (window.addEventListener) { |
109 |
| - window.addEventListener('load', onLoadListener, false); |
110 |
| - } else if (window.attachEvent) { |
111 |
| - window.attachEvent('onload', onLoadListener); |
112 |
| - } |
113 |
| - |
114 | 117 | })(window, document);
|
115 | 118 |
|
0 commit comments