当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript utils.utils类代码示例

本文整理汇总了TypeScript中perfmjs/utils.utils的典型用法代码示例。如果您正苦于以下问题:TypeScript utils类的具体用法?TypeScript utils怎么用?TypeScript utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了utils类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

 _parseLoadedRes: function(options) {
     //只认带有script元素的src属性或src参数中含有onlyforload.js或core.js或core.min.js或core-def.js字符的地址
     options = _utils.extend({loadfile:'core-[0-9]+.[0-9]+.[0-9]+.js|core-[0-9]+.[0-9]+.[0-9]+.min.js|onlyforload.js|core.min.js|core.js', isScript:false, src:'{n:"",t:"js",m:"default;"}'}, options);
     //将sources数组清空并初始化
     this.sources.length = 0;
     var scripts = options['isScript'] ? document.getElementsByTagName("script") : options['src'].split('|');
     for (var i = 0; i < scripts.length; i++) {
         var src = options['isScript'] ? scripts[i].src : (scripts[i].indexOf('^')<0?('onlyforload.js^'+scripts[i]):scripts[i]);
         var scriptOptions = {}, isParsed = options['isScript'] ? (src.isparsed || false) : false;
         if (src && src.match(options['loadfile']) && !isParsed ) {
             if(src.indexOf('^') != -1) {
                 var multiSrcOptions = src.split('^')[1].replace(new RegExp("%20","gm")," ").replace(new RegExp("%22","gm"),"\"").replace(new RegExp("%27","gm"),"\'").split('|');
                 for (var j = 0; j < multiSrcOptions.length; j++) {
                     srcOptions = multiSrcOptions[j];
                     try {
                         scriptOptions = eval("("+srcOptions+")");
                     } catch (err) {
                         if (typeof(JSON) === 'object' && JSON.parse) {
                             scriptOptions = JSON.parse(srcOptions);
                         }
                     }
                     scriptOptions = _utils.extend({n:'',t:'js',m:'default'}, scriptOptions);
                     this.sources[this.sources.length] = scriptOptions;
                 }
                 if (options['isScript']) {
                     scripts[i].setAttribute('isparsed', 'true');
                 }
             }
         }
     }
     if (scripts.length > 0 && this.sources.length < 1) {
         this.sources[this.sources.length] = {n:'',t:'js',m:'default'};
     }
     return this.sources;
 }
开发者ID:perfmjs,项目名称:perfmjs,代码行数:35,代码来源:loader.ts

示例2: formartBallNum

 /**
  * 将小于10的球号码数前加0或去掉0,如将'1,4,5,12'变成"01,04,05,12"
  * fillIntWith2Char: true-e.g.将'1,4,5,12'变成"01,04,05,12", 默认为false-e.g.将'01,04,5,12'变成"1,4,5,12"
  */
 formartBallNum(balls:any, fillIntWith2Char:boolean):string {
     var ballArray = [];
     fillIntWith2Char = fillIntWith2Char || false;
     if (fillIntWith2Char) {
         utils.forEach(balls.toString().split(','), function(item) {
             ballArray[ballArray.length] = (utils.toNumber(item)<10&&item.length<2)?'0'+item:item;
         });
     } else {
         utils.forEach(balls.toString().split(','), function(item) {
             ballArray[ballArray.length] = utils.toNumber(item)+"";
         });
     }
     return ballArray.join(',');
 }
开发者ID:perfmjs,项目名称:perfmjs,代码行数:18,代码来源:betBaseSuanfa.ts

示例3: function


//.........这里部分代码省略.........
            });
        }
    }

    function domContentLoaded() {
        // W3C
        if (doc.addEventListener) {
            doc.removeEventListener("DOMContentLoaded", domContentLoaded, false);
            domReady();
        }

        // IE
        else if (doc.readyState === "complete") {
            // we're here because readyState === "complete" in oldIE
            // which is good enough for us to call the dom ready!
            doc.detachEvent("onreadystatechange", domContentLoaded);
            domReady();
        }
    }

    // Catch cases where ready() is called after the browser event has already occurred.
    // we once tried to use readyState "interactive" here, but it caused issues like the one
    // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
    if (doc.readyState === "complete") {
        domReady();
    }

    // W3C
    else if (doc.addEventListener) {
        doc.addEventListener("DOMContentLoaded", domContentLoaded, false);

        // A fallback to window.onload, that will always work
        win.addEventListener("load", domReady, false);
    }

    // IE
    else {
        // Ensure firing before onload, maybe late but safe also for iframes
        doc.attachEvent("onreadystatechange", domContentLoaded);

        // A fallback to window.onload, that will always work
        win.attachEvent("onload", domReady);

        // If IE and not a frame
        // continually check to see if the document is ready
        var top = false;

        try {
            top = !win.frameElement && doc.documentElement;
        } catch (e) { }

        if (top && top.doScroll) {
            (function doScrollCheck() {
                if (!isDomReady) {
                    try {
                        // Use the trick by Diego Perini
                        // http://javascript.nwbox.com/IEContentLoaded/
                        top.doScroll("left");
                    } catch (error) {
                        // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if assets are queued)
                        win.clearTimeout(api.readyTimeout);
                        api.readyTimeout = win.setTimeout(doScrollCheck, 50);
                        return;
                    }

                    // and execute any waiting functions
                    domReady();
                }
            }());
        }
    }
    //#endregion

    //#region Public Exports
    // INFO: determine which method to use for loading
    api.load  = api.js = isAsync ? apiLoadAsync : apiLoadHack;
    api.test  = conditional;
    api.ready = ready;
    //#endregion

    //#region INIT
    // perform this when DOM is ready
    api.ready(doc, function () {
        if (allLoaded()) {
            each(handlers.ALL, function (callback) {
                one(callback);
            });
        }

        if (api.feature) {
            api.feature("domloaded", true);
        }
    });
    //#endregion

    /*for perfmjs begin*/
    utils.getGlobal('headLoad');
    utils.root.headLoad = api;
    /*for perfmjs end*/
}(window);
开发者ID:perfmjs,项目名称:perfmjs,代码行数:101,代码来源:head.load.ts

示例4: function

 utils.forEach(balls.toString().split(','), function(item) {
     ballArray[ballArray.length] = utils.toNumber(item)+"";
 });
开发者ID:perfmjs,项目名称:perfmjs,代码行数:3,代码来源:betBaseSuanfa.ts


注:本文中的perfmjs/utils.utils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。