// 这里调试用的代码我没有删除 loader = (function() { var group_queue = []; // group list //// url_item = {url:str, start: false, finished:false} // 用于调试 var log = function(msg) { return; console.log(msg); } var isfunc = function(obj) { return object.prototype.tostring.call(obj) == "[object function]"; } var isarray = function(obj) { return object.prototype.tostring.call(obj) == "[object array]"; } var isallstart = function(url_items) { for (var idx=0; idx 0) { showgroupinfo(); // is func if (isfunc(group_queue[0])) { log('## nextgroup: exec func'); group_queue[0](); // exec group_queue.shift(); continue; // is array } else if (isallfinished(group_queue[0])) { log('## current group all finished'); group_queue.shift(); continue; } else if (!isanystart(group_queue[0])) { log('## current group no one start!'); loadgroup(); break; } else { break; } } }; var loaderror = function(oerror) { console.error("the script " + oerror.target.src + " is not accessible."); }; var loadscript = function(url_item) { log("load "+url_item.url); url = url_item.url; url_item.start = true; var script = document.createelement('script'); script.type = "text/javascript"; if (script.readystate){ //ie script.onreadystatechange = function() { if (script.readystate == "loaded" || script.readystate == "complete") { script.onreadystatechange = null; url_item.finished = true; loadfinished(); } }; } else { //others script.onload = function(){ url_item.finished = true; loadfinished(); }; } script.onerror = loaderror; script.src = url+'?'+'time='+date.parse(new date()); document.body.appendchild(script); }; var loadgroup = function() { for (var idx=0; idx < group_queue[0].length; idx++) { loadscript(group_queue[0][idx]); } }; var addgroup = function(url_array) { /* log('add :' + url_array);*/ if (url_array.length > 0) { group = []; for (var idx=0; idx