All Downloads are FREE. Search and download functionalities are using the official Maven repository.

static.smart-ui.boot.utils.js Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
(function(){
    window.utils = initUtils();
    var path = getJsPath("utils.js",2);
    utils.uihost = path;
    window.initConfig=function(config){
        if(window.smartInitHook){
            window.smartInitHook(config);
        }
        utils.getCurrentBootScriptPath =function(){
            var script = document.currentScript;
            if(!script){
                script = document.querySelector("script[smart-boot-script]");
            }
            var path = script.src;
            var ss = path.split("/");
            ss.length = ss.length - 1;
            path = ss.join("/");
            utils.removeProp(utils,"getCurrentBootScriptPath");
            return path;
        }
        utils.uiVersion=config[utils.from].version;
        document.write('');
        document.write('');
        document.write("");
        if(config.debug){
            if(utils.getParamer("debug") == "true"){
                utils.plugins.push("eruda");
                utils.delayAction(function(){
                    return window.eruda!=null;
                },function(){
                    window.eruda.init();
                });
            }
        }
        if(!config.plugins.router){
            config.plugins.router = [{js:path+"/plugins/router/"+utils.from+".router.js"}];
        }
        initPlugins(config.plugins,utils.plugins);
        document.write('');
        document.write('');
    }
    document.write("");
    document.write("");
    document.write("");
    document.write("");
    function initPlugins(pluginMap,plugins) {
        for(var i=0;i");
                }
                if(plugin.css){
                    document.write('');
                }
            }
        }
    }
    function initUtils(){
        var tools = {
            getParamer: function (key) {
                var map = this.getSearch();
                return map[key];
            },
            getSearch: function () {
                var search = decodeURIComponent(location.search);
                return this.getSearchByStr(search);
            },
            getSearchByStr:function(search){
                if (search) {
                    search = search.substring(1);
                } else {
                    return {};
                }
                var strsz = search.split("&");
                var map = {};
                for (var i=0; imaxDelay){
                        that.removeProp(that,key);
                        that.removeProp(that,timeKey);
                    }else{
                        if(tjFn()){
                            that.removeProp(that,key);
                            that.removeProp(that,timeKey);
                            acFn();
                        }else{
                            setTimeout(that[key],100);
                        }
                    }
                }
                that[key]();
            },
            uuid:function(){
                function S4() {
                    return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
                }
                return S4() + S4() + S4() + S4() + S4() + S4() + S4() + S4();
            }
        }
        var jsSearch = getJsSearch("utils.js");
        var plugins = [];
        if(jsSearch.plugins && jsSearch.plugins.trim()){
            plugins=jsSearch.plugins.trim().split(",");
        }
        jsSearch.plugins = plugins;
        for(var key in jsSearch){
            tools[key] = jsSearch[key];
        }
        function getJsSearch(js){
            var scripts = document.getElementsByTagName("script");
            var map = {};
            var c;
            for (var i = 0, l = scripts.length; i < l; i++) {
                var src = scripts[i].src;
                if ((c = src.indexOf(js) ) != -1) {
                    map = tools.getSearchByStr(src.substring(c+js.length));
                    break;
                }
            }
            return map;
        }
        return tools;
    }
    function getJsPath(js, length) {
        var scripts = document.getElementsByTagName("script");
        var path = "";
        for (var i = 0, l = scripts.length; i < l; i++) {
            var src = scripts[i].src;
            if (src.indexOf(js) != -1) {
                path = src;
                break;
            }
        }
        var ss = path.split("/");
        ss.length = ss.length - length;
        path = ss.join("/");
        return path;
    }
})();




© 2015 - 2025 Weber Informatics LLC | Privacy Policy