util.js
1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// 通用方法
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)