|
@@ -121,11 +121,15 @@ var BasicFunction = new (function () {
|
|
|
|
|
|
this.get_data = function (url, callback, data, onescope) {
|
|
|
console.log('calling get_data()');
|
|
|
- BasicFunction.Queue.list.push({url: url, callback: callback, gid: -1, data: data, scope: onescope});
|
|
|
+ let jsonData = data;
|
|
|
+ if(typeof data != "string"){
|
|
|
+ jsonData = JSON.stringify(jsonData);
|
|
|
+ }
|
|
|
+ BasicFunction.Queue.list.push({url: url, callback: callback, gid: -1, data: jsonData, scope: onescope});
|
|
|
};
|
|
|
|
|
|
this.new_data_group = function (groupName, callback) {
|
|
|
- var gid = -1;
|
|
|
+ let gid = -1;
|
|
|
BasicFunction.Queue.groups.forEach(function (val) {
|
|
|
if (val.groupName === groupName) {
|
|
|
gid = val.gid;
|
|
@@ -142,7 +146,7 @@ var BasicFunction = new (function () {
|
|
|
};
|
|
|
|
|
|
this.group_get_data = function (groupName, url, callback) {
|
|
|
- var gid = -1;
|
|
|
+ let gid = -1;
|
|
|
BasicFunction.Queue.groups.forEach(function (val) {
|
|
|
if (val.groupName === groupName) {
|
|
|
gid = val.gid;
|
|
@@ -222,13 +226,13 @@ var BasicFunction = new (function () {
|
|
|
}
|
|
|
|
|
|
this.on_gp_success = function(response) {
|
|
|
- var obj = response.json();
|
|
|
+ let obj = response.json();
|
|
|
return obj;
|
|
|
};
|
|
|
|
|
|
this.onReqeustDataReceived = function(responseJson) {
|
|
|
console.warn(responseJson);
|
|
|
- var a = responseJson;
|
|
|
+ let a = responseJson;
|
|
|
if (!BasicFunction.check_if_authfail(a)) {
|
|
|
const error = new Error(responseJson.statusText);
|
|
|
error.response = responseJson;
|
|
@@ -247,7 +251,7 @@ var BasicFunction = new (function () {
|
|
|
|
|
|
this.check_if_authfail = function (errormsg) {
|
|
|
BasicFunction.logerror(errormsg);
|
|
|
- var a = errormsg;
|
|
|
+ let a = errormsg;
|
|
|
if (a == null || typeof a !== "string") {
|
|
|
return false;
|
|
|
} else {
|
|
@@ -261,8 +265,8 @@ var BasicFunction = new (function () {
|
|
|
this.check_if_success = function (response) {
|
|
|
// this == BasicFunction
|
|
|
BasicFunction.loglog("---------------Check-If-Success----------------");
|
|
|
- var a = response.json();
|
|
|
- var b = response.status;
|
|
|
+ let a = response.json();
|
|
|
+ let b = response.status;
|
|
|
if (typeof a === "string") {
|
|
|
try {
|
|
|
a = JSON.parse(a);
|
|
@@ -329,19 +333,13 @@ var BasicFunction = new (function () {
|
|
|
};
|
|
|
|
|
|
this.send_alert = function (a, b) {
|
|
|
-
|
|
|
-
|
|
|
if (BasicFunction.Queue.shouldStop) return;
|
|
|
-
|
|
|
if (BasicFunction.AlertClosingTimeout > 0) {
|
|
|
clearTimeout(BasicFunction.AlertClosingTimeout);
|
|
|
}
|
|
|
-
|
|
|
BasicFunction.logwarn(a);
|
|
|
BasicFunction.logwarn(b);
|
|
|
-
|
|
|
// alert(a +"\n"+ b);
|
|
|
-
|
|
|
BasicFunction.AlertClosingTimeout = setTimeout(function () {
|
|
|
//$("#mpAlert").hide();
|
|
|
}, 10000);
|
|
@@ -349,7 +347,7 @@ var BasicFunction = new (function () {
|
|
|
};
|
|
|
|
|
|
this.getUserName = function (uid) {
|
|
|
- var uname = null;
|
|
|
+ let uname = null;
|
|
|
BasicFunction.Users.list.forEach(function (val, aid) {
|
|
|
BasicFunction.loglog(aid);
|
|
|
if (val.worker.staffId === uid) {
|
|
@@ -367,9 +365,9 @@ var BasicFunction = new (function () {
|
|
|
};
|
|
|
|
|
|
this.on_username_retn = function (obj) {
|
|
|
- var uid = this.url.substring(this.url.indexOf("staffId=") + 8);
|
|
|
+ let uid = this.url.substring(this.url.indexOf("staffId=") + 8);
|
|
|
let ruid = parseInt(uid);
|
|
|
- var out = BasicFunction.first_parse(this, obj);
|
|
|
+ let out = BasicFunction.first_parse(this, obj);
|
|
|
if (out.list.length > 0) {
|
|
|
BasicFunction.Users.list.push({
|
|
|
uid: ruid, worker: out.list[0]
|
|
@@ -384,15 +382,15 @@ var BasicFunction = new (function () {
|
|
|
if (typeof (liveMinutes) !== 'number') {
|
|
|
liveMinutes = 60 * 2;//默认120分钟
|
|
|
}
|
|
|
- var minutes = liveMinutes * 60 * 1000;
|
|
|
- var exp = new Date();
|
|
|
+ let minutes = liveMinutes * 60 * 1000;
|
|
|
+ let exp = new Date();
|
|
|
exp.setTime(exp.getTime() + minutes + 8 * 3600 * 1000);
|
|
|
//path=/表示全站有效,而不是当前页
|
|
|
document.cookie = name + "=" + value + ";path=/;expires=" + exp.toUTCString();
|
|
|
};
|
|
|
|
|
|
this.setCookie = function (c_name, value, expiredays) {
|
|
|
- var exdate = new Date();
|
|
|
+ let exdate = new Date();
|
|
|
exdate.setDate(exdate.getDate() + expiredays);
|
|
|
document.cookie = c_name + "=" + escape(value) +
|
|
|
((expiredays == null) ? "" : ";expires=" + exdate.toGMTString())
|
|
@@ -400,10 +398,10 @@ var BasicFunction = new (function () {
|
|
|
|
|
|
this.getCookie = function (c_name) {
|
|
|
if (document.cookie.length > 0) {
|
|
|
- var c_start = document.cookie.indexOf(c_name + "=");
|
|
|
+ let c_start = document.cookie.indexOf(c_name + "=");
|
|
|
if (c_start !== -1) {
|
|
|
c_start = c_start + c_name.length + 1;
|
|
|
- var c_end = document.cookie.indexOf(";", c_start);
|
|
|
+ let c_end = document.cookie.indexOf(";", c_start);
|
|
|
if (c_end === -1) c_end = document.cookie.length;
|
|
|
return unescape(document.cookie.substring(c_start, c_end))
|
|
|
}
|
|
@@ -415,14 +413,14 @@ var BasicFunction = new (function () {
|
|
|
|
|
|
this.getUserId = function() {
|
|
|
BasicFunction.loglog("Original USERID : " + userId);
|
|
|
- var use = getCookie("doibyUser");
|
|
|
+ let use = getCookie("doibyUser");
|
|
|
if (use == null || use === undefined || use.length <= 0) {
|
|
|
location.href = "sign-in1.html?from=entrance-1&msg=nologin-mustauth";
|
|
|
return;
|
|
|
}
|
|
|
BasicFunction.loglog("Got UID From COOKIE : " + use);
|
|
|
try {
|
|
|
- var mm = parseInt(use);
|
|
|
+ let mm = parseInt(use);
|
|
|
if (mm > 0) {
|
|
|
BasicFunction.userId = mm;
|
|
|
}
|