⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 load-suite.js

📁 JS编译工具
💻 JS
字号:
/*
 * JavaScript Integration Framework
 * License LGPL(您可以在任何地方免费使用,但请不要吝啬您对框架本身的改进)
 * http://www.xidea.org/project/jsi/
 * @author jindw
 * @version $Id: loader-test.js,v 1.3 2008/02/19 13:39:03 jindw Exp $
 */

var scriptBase = this.scriptBase;
var inc = 0;
function LoadSuite(packageList,collectAll){
    LoadSuite[this.id = "$"+(inc++)] = this;
    packageList=collectAll?findPackages(packageList):packageList;
    packageList.sort();
    var paths = [];
    for(var i = 0;i<packageList.length;i++){
        var packageName = packageList[i];
        var packageObject = $import(packageName + ':');
        if(packageObject.name == packageName){
            for(var fileName in packageObject.scriptObjectMap){
                paths.push(packageName.replace(/\.|$/g,'/')+fileName);
            }
            for(var objectName in packageObject.objectScriptMap){
                paths.push(packageName+":"+objectName);
            }
        }else{
            //ref
        }
    }
    //confirm("装载测试单元如下:\n\n"+paths.join('\n'));
    this.paths = paths;
    this.index = 0;
}


LoadSuite.prototype = {
    typeList : "SAL",
    /**
     * @public
     */
    typeText:{
        S:'同步装载',
        A:'异步装载',
        L:'延迟装载'
    },
    /**
     * @public
     */
    startTest:function(type){
        var path = this.paths[this.index];
        type = type || this.typeList.charAt(0);
        this.showLoading(path,type)
        var src = scriptBase+"loader.html?path="+encodeURIComponent(path) + '&type='+type+'&id='+this.id;
        window.open(src,"loader");
    },
    /**
     * @public
     */
    nextTest : function(previousPath,type,previousTarget,exception){
        this.updateLoading.apply(this,arguments);
        var typeList = this.typeList;
        //SALS  S
        var index = typeList.indexOf(type);
        if(index == typeList.length-1){
            this.index++;
            type = typeList.charAt(0);
        }else{//SA
            type = typeList.charAt(index+1);
        }
        if(this.index<this.paths.length){
            this.startTest(type);
        }else{
            confirm("测试完成"+this);
        }
    },
    /**
     * @protected
     */
    showLoading:function(path,type){
        var div = document.createElement('div');
        div.className = "loading";
        div.innerHTML = this.typeText[type] + ":"+path +'....';
        this.getOutputContainer().appendChild(div);
    },
    /**
     * @protected
     */
    updateLoading:function(previousPath,previousType,previousTarget,exception){
        var div = this.getOutputContainer().lastChild;
        var msg = [this.typeText[previousType] ,":",previousPath];
        if(exception){
            div.className="error";
            msg.push("失败!!!<br/>Exception:<br/><pre>");
            for(var n in exception){
                msg.push("  ",n,"=",exception[n]);
                msg.push("\n");
            }
            msg.pop();
            msg.push("</pre>");
        }else{
            div.className="warn";
            if(this.isValid(previousTarget,previousPath)){
                div.className="success";
                msg.push("成功。")
            }else{
                div.className="wanring";
                msg.push("完成,对象为空!!")
            }
            
            
        }
        msg.push('<hr/>');
        div.innerHTML = msg.join('');
    },
    /**
     * @protected
     */
    isValid:function(target,path){
        path = path.split(':')[1];
        if(path){
            path = path.split('.');
            path.reverse();
            var object = target
            while(path.length){
                object = object[path.pop()]
            }
            return object!=target['+undefined'];
        }
        return true;
        
    },
    getOutputContainer:function(){
        return document.getElementById("console");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -