common.js
1.17 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
//设置当前页面导航栏背景色
function addTabs(id) {
$('.layui-nav-item').removeClass('layui-this')
$(id).addClass('layui-this')
}
//设置ajax调取服务接口
function SetServicesPath() {
return "http://192.168.2.108"
}
//设置全局參數
var portal =
{
'api_url': "http://192.168.2.108:8000", //属性名用引号括起来,属性间由逗号隔开
'name': 'myName',
"rootPath": GetRootPath()
};
//截取日期
function CutDate(times) {
var timearr = times.replace(" ", ":").replace(/\:/g, "-").split("-");
var timestr = "" + timearr[0] + "/" + timearr[1] + "/" + timearr[2]
//var timestr = "" + timearr[1].split("")[1] + "月" + timearr[2] + "日\t" + timearr[3] + ":" + timearr[4] + ""
return timestr
}
function GetRootPath() {
var curWwwPath = window.document.location.href;
var pathName = window.document.location.pathname;
var pos = curWwwPath.indexOf(pathName);
return curWwwPath.substring(0, pos);
}
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");
var r = window.location.search.substr(1).match(reg);
if (r!=null) return (r[2]); return null;
}