From 486d1a05b31308c5359572bf4eef76d8d7f5e03a Mon Sep 17 00:00:00 2001 From: surikat Date: Tue, 1 Sep 2015 10:35:33 +0200 Subject: [PATCH] improve --- js.js | 4 ++-- js.pack.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js.js b/js.js index 57de82b..681b0fd 100644 --- a/js.js +++ b/js.js @@ -58,7 +58,7 @@ (requiring[u].shift())(u); }; var getSrc = function(u){ - return u?($js.path&&u.indexOf('://')<0&&u.indexOf('/')!==0&&(!$js.pathDetection||u.indexOf($js.path)!=0)?($js.path+u):u)+($js.pathSuffix&&u.indexOf('://')<0&&(!$js.pathDetection||u.substr(u.length-$js.pathSuffix.length)!=$js.pathSuffix)?$js.pathSuffix:''):u; + return u&&u.indexOf('/')!==0?($js.path&&u.indexOf('://')<0&&(!$js.pathDetection||u.indexOf($js.path)!=0)?($js.path+u):u)+($js.pathSuffix&&u.indexOf('://')<0&&(!$js.pathDetection||u.substr(u.length-$js.pathSuffix.length)!=$js.pathSuffix)?$js.pathSuffix:''):u; }; var createScript = function(u){ var s = d.createElement('script'); @@ -426,7 +426,7 @@ }; var apt = function(u,c,m){ m = m?0:1; - u = getSrc(u); + //u = getSrc(u); if(!scripts[m][u]) scripts[m][u] = []; if(typeof(c)=='function') diff --git a/js.pack.js b/js.pack.js index 57f84d1..4ab3ea3 100644 --- a/js.pack.js +++ b/js.pack.js @@ -1 +1 @@ -(function(w,d){var indexOf=Array.prototype.indexOf?function(a,obj,start){return a.indexOf(obj,start)}:function(a,obj,start){var j=a.length;for(var i=(start?start:0),j;i-1)handle(u);else setTimeout(function(){wait(u)},100)};var handle=function(u){if(requiring[u])while(requiring[u].length)(requiring[u].shift())(u)};var getSrc=function(u){return u?($js.path&&u.indexOf('://')<0&&u.indexOf('/')!==0&&(!$js.pathDetection||u.indexOf($js.path)!=0)?($js.path+u):u)+($js.pathSuffix&&u.indexOf('://')<0&&(!$js.pathDetection||u.substr(u.length-$js.pathSuffix.length)!=$js.pathSuffix)?$js.pathSuffix:''):u};var createScript=function(u){var s=d.createElement('script');d.type='text/javascript';d.body.appendChild(s);var realcallback=function(){var shift=$js.modulesStack.shift();if(shift)$js.modules[u]=shift;required.push(u);handle(u);handled.push(u)};var callback=function(){if(intercepting){intercepting.src=u;intercepting.callback=realcallback;intercepting=false}else{realcallback()}};s.onload=callback;s.onreadystatechange=function(){if(callback&&this.readyState==='loaded'){callback()}};s.setAttribute('async','async');s.src=cacheFix(u,$js.dev,$js.min,'js')};var x=function(u,c){if(!u){if(typeof(c)=='function')c();return}u=getSrc(u);if(!requiring[u]){requiring[u]=[];createScript(u)}if(typeof(c)=='function')requiring[u].push(c);if(indexOf(handled,u)>-1)handle(u);else if(indexOf(required,u)>-1)wait(u)};var resolveAsyncArr=function(u){var arr=[];for(var k in u){if((/^-?[0-9]+$/).test(k)){if(typeof(u[k])=='string'){arr.push(u[k])}else{for(var ks in u[k]){arr.push(u[k][ks])}}}else{arr.push(k)}if(typeof(u[k])=='object'){for(var ks in u[k]){if(typeof(u[k][ks])=='string'&&indexOf(arr,u[k][ks])===-1){arr.push(u[k][ks])}}}}return arr};var resolveDeps=function(u,arr){var deps={};for(var k in u){var key=k;if((/^-?[0-9]+$/).test(k))key=u[k];if(typeof($js.dependenciesMap[key])=='object'){if(typeof(deps[key])=='undefined'){deps[key]=[]}for(var ks in $js.dependenciesMap[key]){if(indexOf(deps[key],$js.dependenciesMap[key][ks])===-1){deps[key].push($js.dependenciesMap[key][ks])}if(typeof(arr)!='undefined'&&indexOf(arr,$js.dependenciesMap[key][ks])===-1){arr.push($js.dependenciesMap[key][ks])}}}if(typeof(u[k])=='object'){if(typeof(deps[k])=='undefined'){deps[k]=[]}if(typeof($js.dependenciesMap[key])=='undefined'){$js.dependenciesMap[key]=[]}for(var ks in u[k]){if(typeof(u[k][ks])=='string'){if(indexOf(deps[key],u[k][ks])===-1){deps[key].push(u[k][ks])}if(indexOf($js.dependenciesMap[key],u[k][ks])===-1){$js.dependenciesMap[key].push(u[k][ks])}}}}}return deps};var resolveDepCalls=function(u){var deps={};for(var k in u){if(typeof(u[k])=='object'){for(var ks in u[k]){if(typeof(u[k][ks])=='function'){if(typeof(deps[k])=='undefined'){deps[k]=[]}deps[k].push(u[k][ks])}}}}return deps};var depsLibPush=function(deps,lib,container){if(typeof(deps[lib])!='undefined'){for(var k in deps[lib]){depsLibPush(deps,deps[lib][k],container);if(indexOf(container,deps[lib][k])===-1)container.push(deps[lib][k])}}};var resolveDepMap=function(deps){var depMap={};for(var k in deps){if(typeof(depMap[k])=='undefined'){depMap[k]=[]}depsLibPush(deps,k,depMap[k])}return depMap};var resolveDepTree=function(depMap){var depTree={};for(var k in depMap){for(var k2 in depMap[k]){if(typeof(depTree[depMap[k][k2]])=='undefined'){depTree[depMap[k][k2]]=[]}depTree[depMap[k][k2]].push(k)}}return depTree};var depsToTops=function(deps){var tops=[];var topAll=[];var splices=[];while(!isEmptyObject(deps)){var top=[];for(var i in splices){deps[splices[i][0]].splice(indexOf(deps[splices[i][0]],splices[i][1]),1);if(deps[splices[i][0]].length===0){if(indexOf(topAll,splices[i][0])===-1){top.push(splices[i][0]);topAll.push(splices[i][0])}delete(deps[splices[i][0]])}}splices=[];for(var k in deps){for(var ks in deps[k]){var dep=deps[k][ks];if(typeof(deps[dep])=='undefined'){if(indexOf(topAll,dep)===-1){top.push(dep);topAll.push(dep)}splices.push([k,dep])}}}tops.push(top)}return tops};var r=function(g,depTree,depMap,rio,arrSrc,c){var src=getSrc(g);if(typeof(arrSrc)!='undefined'){if(indexOf(requiredGroups[rio],src)===-1)requiredGroups[rio].push(src);if(requiredGroups[rio].sort().toString()==arrSrc){c()}}for(var z in depTree[g]){var dp=depTree[g][z];if(depMap[dp]){var ok=true;for(var z2 in depMap[dp]){if(indexOf(required,getSrc(depMap[dp][z2]))===-1){ok=false;break}}if(ok){$js(dp,(function(){var dpz=dp.toString();return function(){r(dpz,depTree,depMap,rio,arrSrc,c)}})(),0)}}}};var resolveAlias=function(u){if(typeof(u)=='string'){if(typeof($js.aliasMap[u])!='undefined'){u=$js.aliasMap[u];u=resolveAlias(u)}}else if(typeof(u)=='object'){if(u instanceof Array){var un=[];for(var i in u){if(typeof(u[i])=='string'&&typeof($js.aliasMap[u[i]])!='undefined'){var alias=$js.aliasMap[u[i]];if(typeof(alias)=='object'){for(var ii in alias){if((/^-?[0-9]+$/).test(ii)){var aliasii=alias[ii]}else{var aliasii=ii}aliasii=resolveAlias(aliasii);if(indexOf(un,aliasii)===-1)un.push(aliasii)}}else{alias=resolveAlias(alias);if(indexOf(un,alias)===-1)un.push(alias)}}else{u[i]=resolveAlias(u[i]);if(indexOf(un,u[i])===-1)un.push(u[i])}}u=un}else{for(var k in u){u[k]=resolveAlias(u[k])}}}return u};var requiredGroups=[];var asyncArrayCall=function(uo,s,c,i){var u=[];for(var k in uo)u.push(getSrc(uo[k]));u=u.sort().toString();$js(s,function(){requiredGroups[i].push(getSrc(s));if(requiredGroups[i].sort().toString()==u){if(typeof(c)=='function')c()}},0)};var asyncJsObject=function(u,c){requiredGroups.push([]);var arr=resolveAsyncArr(u);var deps=resolveDeps(u,arr);var m=resolveDepCalls(u);for(var k in u){if(typeof(u[k])!='object'){if((/^-?[0-9]+$/).test(k)){k=u[k]}if(typeof(deps[k])=='undefined'){asyncArrayCall(arr,k,c,requiredGroups.length-1)}}}var o=resolveDepMap(deps);var t=resolveDepTree(o);var tops=depsToTops(deps);var rio=requiredGroups.length-1;var h=[];for(var k in arr){h.push(getSrc(arr[k]))}h=h.sort().toString();var depTreeKeys=[];for(var k in t){if(indexOf(depTreeKeys,k)===-1)depTreeKeys.push(k)}var b=function(){if(c){c();c=null}};var ev='';for(var _g in depTreeKeys.reverse()){var g=depTreeKeys[_g];if(typeof(m[g])!='undefined'){for(var i in m[g].reverse()){ev='m["'+g+'"]['+i+']();'+ev}}if(typeof(u[g])=='function')ev='u["'+g+'"]();'+ev;ev='$js("'+g+'",function(){r("'+g+'",t,o,'+rio+',h,b);'+ev+'},0);'}eval(ev)};var syncJsObject=function(u,c){var tops=depsToTops(resolveDeps(u));if(typeof(tops[0])=='undefined')tops[0]=[];var m=resolveDepCalls(u);for(var k in u){if(typeof(u[k])!='object'){var p;if((/^-?[0-9]+$/).test(k))p=u[k];else p=k;if(indexOf(tops[0],p)===-1)tops[0].push(p)}}var ev=c?'if(c)c();':'';for(var k in tops.reverse()){for(var ks in tops[k].reverse()){var d=tops[k][ks];if(typeof(m[d])!='undefined'){for(var i in m[d].reverse()){ev='m["'+d+'"]['+i+']();'+ev}}if(typeof(u[d])=='function')ev='u["'+d+'"]();'+ev;ev='$js("'+d+'",function(){'+ev+'},1);'}}eval(ev)};var apt=function(u,c,m){m=m?0:1;u=getSrc(u);if(!scripts[m][u])scripts[m][u]=[];if(typeof(c)=='function')scripts[m][u].push(c)};$js=(function(){var js=function(){var u,c,sync=!$js.async;for(var i=0;i-1)exist=true}if(!exist){style=d.createElement('link');style.type='text/css';style.rel='stylesheet';if(media)style.media=media;style.href=cacheFix(fileName,$css.dev,$css.min,'css');d.getElementsByTagName('head')[0].appendChild(style)}}};css.dev=false;css.path='css/';css.pathDetection=true;css.pathSuffix='.css';css.min=false;return css})();var load=function(){apt=x;for(var k in scripts[0])loader(0,k);for(var k in scripts[1])loader(1,k);var ev='';var keys=keysOf(y).reverse();for(var u in keys){u=keys[u];var keys2=keysOf(y[u]).reverse();var ev2='';for(var i in keys2)if(y[u]&&y[u][i])ev2+='y["'+u+'"]["'+i+'"]();';ev='x("'+u+'"'+(ev?',function(){'+ev2+ev+'}':'')+');'}if(ev)eval(ev)};if(w.addEventListener)w.addEventListener('load',load,false);else if(w.attachEvent)w.attachEvent('onload',load);else w.onload=load})(window,document); \ No newline at end of file +(function(w,d){var q=Array.prototype.indexOf?function(a,b,c){return a.indexOf(b,c)}:function(a,b,c){var j=a.length;for(var i=(c?c:0),j;i-1)I(u);else setTimeout(function(){H(u)},100)};var I=function(u){if(F[u])while(F[u].length)(F[u].shift())(u)};var J=function(u){return u&&u.indexOf('/')!==0?($js.path&&u.indexOf('://')<0&&(!$js.pathDetection||u.indexOf($js.path)!=0)?($js.path+u):u)+($js.pathSuffix&&u.indexOf('://')<0&&(!$js.pathDetection||u.substr(u.length-$js.pathSuffix.length)!=$js.pathSuffix)?$js.pathSuffix:''):u};var K=function(u){var s=d.createElement('script');d.type='text/javascript';d.body.appendChild(s);var b=function(){var a=$js.modulesStack.shift();if(a)$js.modules[u]=a;D.push(u);I(u);E.push(u)};var c=function(){if(G){G.src=u;G.callback=b;G=false}else{b()}};s.onload=c;s.onreadystatechange=function(){if(c&&this.readyState==='loaded'){c()}};s.setAttribute('async','async');s.src=B(u,$js.dev,$js.min,'js')};var x=function(u,c){if(!u){if(typeof(c)=='function')c();return}u=J(u);if(!F[u]){F[u]=[];K(u)}if(typeof(c)=='function')F[u].push(c);if(q(E,u)>-1)I(u);else if(q(D,u)>-1)H(u)};var L=function(u){var a=[];for(var k in u){if((/^-?[0-9]+$/).test(k)){if(typeof(u[k])=='string'){a.push(u[k])}else{for(var b in u[k]){a.push(u[k][b])}}}else{a.push(k)}if(typeof(u[k])=='object'){for(var b in u[k]){if(typeof(u[k][b])=='string'&&q(a,u[k][b])===-1){a.push(u[k][b])}}}}return a};var M=function(u,a){var b={};for(var k in u){var c=k;if((/^-?[0-9]+$/).test(k))c=u[k];if(typeof($js.dependenciesMap[c])=='object'){if(typeof(b[c])=='undefined'){b[c]=[]}for(var d in $js.dependenciesMap[c]){if(q(b[c],$js.dependenciesMap[c][d])===-1){b[c].push($js.dependenciesMap[c][d])}if(typeof(a)!='undefined'&&q(a,$js.dependenciesMap[c][d])===-1){a.push($js.dependenciesMap[c][d])}}}if(typeof(u[k])=='object'){if(typeof(b[k])=='undefined'){b[k]=[]}if(typeof($js.dependenciesMap[c])=='undefined'){$js.dependenciesMap[c]=[]}for(var d in u[k]){if(typeof(u[k][d])=='string'){if(q(b[c],u[k][d])===-1){b[c].push(u[k][d])}if(q($js.dependenciesMap[c],u[k][d])===-1){$js.dependenciesMap[c].push(u[k][d])}}}}}return b};var N=function(u){var a={};for(var k in u){if(typeof(u[k])=='object'){for(var b in u[k]){if(typeof(u[k][b])=='function'){if(typeof(a[k])=='undefined'){a[k]=[]}a[k].push(u[k][b])}}}}return a};var O=function(a,b,c){if(typeof(a[b])!='undefined'){for(var k in a[b]){O(a,a[b][k],c);if(q(c,a[b][k])===-1)c.push(a[b][k])}}};var P=function(a){var b={};for(var k in a){if(typeof(b[k])=='undefined'){b[k]=[]}O(a,k,b[k])}return b};var Q=function(a){var b={};for(var k in a){for(var c in a[k]){if(typeof(b[a[k][c]])=='undefined'){b[a[k][c]]=[]}b[a[k][c]].push(k)}}return b};var R=function(a){var b=[];var c=[];var d=[];while(!v(a)){var e=[];for(var i in d){a[d[i][0]].splice(q(a[d[i][0]],d[i][1]),1);if(a[d[i][0]].length===0){if(q(c,d[i][0])===-1){e.push(d[i][0]);c.push(d[i][0])}delete(a[d[i][0]])}}d=[];for(var k in a){for(var f in a[k]){var g=a[k][f];if(typeof(a[g])=='undefined'){if(q(c,g)===-1){e.push(g);c.push(g)}d.push([k,g])}}}b.push(e)}return b};var r=function(g,b,d,e,f,c){var h=J(g);if(typeof(f)!='undefined'){if(q(T[e],h)===-1)T[e].push(h);if(T[e].sort().toString()==f){c()}}for(var z in b[g]){var i=b[g][z];if(d[i]){var j=true;for(var k in d[i]){if(q(D,J(d[i][k]))===-1){j=false;break}}if(j){$js(i,(function(){var a=i.toString();return function(){r(a,b,d,e,f,c)}})(),0)}}}};var S=function(u){if(typeof(u)=='string'){if(typeof($js.aliasMap[u])!='undefined'){u=$js.aliasMap[u];u=S(u)}}else if(typeof(u)=='object'){if(u instanceof Array){var a=[];for(var i in u){if(typeof(u[i])=='string'&&typeof($js.aliasMap[u[i]])!='undefined'){var b=$js.aliasMap[u[i]];if(typeof(b)=='object'){for(var c in b){if((/^-?[0-9]+$/).test(c)){var d=b[c]}else{var d=c}d=S(d);if(q(a,d)===-1)a.push(d)}}else{b=S(b);if(q(a,b)===-1)a.push(b)}}else{u[i]=S(u[i]);if(q(a,u[i])===-1)a.push(u[i])}}u=a}else{for(var k in u){u[k]=S(u[k])}}}return u};var T=[];var U=function(a,s,c,i){var u=[];for(var k in a)u.push(J(a[k]));u=u.sort().toString();$js(s,function(){T[i].push(J(s));if(T[i].sort().toString()==u){if(typeof(c)=='function')c()}},0)};var V=function(u,c){T.push([]);var a=L(u);var d=M(u,a);var m=N(u);for(var k in u){if(typeof(u[k])!='object'){if((/^-?[0-9]+$/).test(k)){k=u[k]}if(typeof(d[k])=='undefined'){U(a,k,c,T.length-1)}}}var o=P(d);var t=Q(o);var e=R(d);var f=T.length-1;var h=[];for(var k in a){h.push(J(a[k]))}h=h.sort().toString();var j=[];for(var k in t){if(q(j,k)===-1)j.push(k)}var b=function(){if(c){c();c=null}};var l='';for(var n in j.reverse()){var g=j[n];if(typeof(m[g])!='undefined'){for(var i in m[g].reverse()){l='m["'+g+'"]['+i+']();'+l}}if(typeof(u[g])=='function')l='u["'+g+'"]();'+l;l='$js("'+g+'",function(){r("'+g+'",t,o,'+f+',h,b);'+l+'},0);'}eval(l)};var W=function(u,c){var a=R(M(u));if(typeof(a[0])=='undefined')a[0]=[];var m=N(u);for(var k in u){if(typeof(u[k])!='object'){var p;if((/^-?[0-9]+$/).test(k))p=u[k];else p=k;if(q(a[0],p)===-1)a[0].push(p)}}var b=c?'if(c)c();':'';for(var k in a.reverse()){for(var e in a[k].reverse()){var d=a[k][e];if(typeof(m[d])!='undefined'){for(var i in m[d].reverse()){b='m["'+d+'"]['+i+']();'+b}}if(typeof(u[d])=='function')b='u["'+d+'"]();'+b;b='$js("'+d+'",function(){'+b+'},1);'}}eval(b)};var X=function(u,c,m){m=m?0:1;if(!C[m][u])C[m][u]=[];if(typeof(c)=='function')C[m][u].push(c)};$js=(function(){var d=function(){var u,c,sync=!$js.async;for(var i=0;i-1)f=true}if(!f){style=d.createElement('link');style.type='text/css';style.rel='stylesheet';if(b)style.media=b;style.href=B(a,$css.dev,$css.min,'css');d.getElementsByTagName('head')[0].appendChild(style)}}};g.dev=false;g.path='css/';g.pathDetection=true;g.pathSuffix='.css';g.min=false;return g})();var bc=function(){X=x;for(var k in C[0])Y(0,k);for(var k in C[1])Y(1,k);var a='';var b=Z(y).reverse();for(var u in b){u=b[u];var c=Z(y[u]).reverse();var d='';for(var i in c)if(y[u]&&y[u][i])d+='y["'+u+'"]["'+i+'"]();';a='x("'+u+'"'+(a?',function(){'+d+a+'}':'')+');'}if(a)eval(a)};if(w.addEventListener)w.addEventListener('load',bc,false);else if(w.attachEvent)w.attachEvent('onload',bc);else w.onload=bc})(window,document); \ No newline at end of file