You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

57 lines
2.1 KiB

var Page = {
SvrIp: location.origin,
// SvrIp: "http://192.168.1.130:3868",
// SvrIp: "http://175.178.27.155:56318",
GetQueryString: function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return "";
},
checktoken: function () {
if (location.href.indexOf('/pages/login.html') > -1) {
return;
}
if (location.href.indexOf('/pages/local_server.html') > -1) {
return;
}
setTimeout(function () {
var token = cookie.get("token");
if (!token || token.length == 0) {
location.href = "/pages/login.html";
}
$.ajax({
url: Page.SvrIp + "/api/check_token",
dataType: "json",
data: { token: cookie.get("token") },
type: "GET",
success: function (d) {
if (d.ret != 0) {
location.href = "/pages/login.html";
} else {
Page.checktoken();
}
}
//,
//error: function () {
// location.href = "/pages/login.html";
//}
});
}, 30000);
},
formatDate: function (date) {
if ((date + "").length == 10) {
date = date * 1000;
}
var date = new Date(date);
var YY = date.getFullYear() + '-';
var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
return YY + MM + DD + " " + hh + mm + ss;
}
};
$(function () {
Page.checktoken();
})