util.js 1.33 KB
// 通用方法

function getQuery(name) {
    var result = window.location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
    if (result == null || result.length < 1)
        return undefined;
    return decodeURIComponent(result[1]);
}


getCDNFile = function (cdnUrl) {
    var link = cdnUrl.substring(cdnUrl.indexOf('/uploads/'), cdnUrl.indexOf('?'));
    return link;
}


;(function($w, $){
    var utils = {};
    /**
     * 访问出错
     * @type {Object}
     */
    utils.errorVisit = {
        template: $('<div id="tips" class="tips">' + 
                            '<div class="tips-inner">' + 
                                '访问出错,请使用正确的方式打开此网站。<br />' + 
                                '请访问 <a href="//geek.gaoxiaobang.com">geek.gaoxiaobang.com</a>' + 
                            '</div>' + 
                        '</div>'),
        show: function(){
            console.info('utils.errorVisit.show');
            var _this = this;
            $('body').append(_this.template);
        },
        hide: function(){
            console.info('utils.errorVisit.hide');
            var _this = this;
            _this.template.remove();
        }
    }
    $w.utils = $w.utils || utils;
})(window, jQuery)

// window.console.log = function(){}
// window.console.info = function(){}