low_front/public/third/serverfunc.js

679 lines
22 KiB
JavaScript

function logoutasync(a) {
EUI.QueryObj.create("eacl/js/login.do?action=logout", null, function(c, b) {
if (b) {
EUI.CallBackFunc.doCallBack(b, c);
}
stopQueryWebState();
}, a);
}
function logOut() {
var a = canLogOut() || "";
EUI.confirmDialog(null, a + I18N.getString("eacl.commonjs.serverfunc.js.suretologoff", "您确定要注销吗?"), false, null, function(b) {
islogout = true;
logoutasync(function(f) {
try {
var c = f.getDetail();
var d = EUI.getContextPath();
if (c) {
if (c.startsWith("http")) {
window.location.href = c;
} else {
window.location.href = d + c;
}
} else {
window.location.href = d + "eacl/login.do";
}
} catch (g) {}
});
});
}
function canLogOut() {
return "";
var e = getEsenMainFrame();
if (!e) {
var c = EUI.getWorkspace();
if (c) {
return c.canClose();
}
}
var a = e.nb.getPages();
for (var b = 0; b < a.length; b++) {
if (a[b].getContentWindow().getWorkspace) {
var d = a[b].getContentWindow().getWorkspace();
if (d && d.canClose()) {
return d.canClose();
}
}
}
return null;
}
var DEFAULT_PING_TIMEOUT = 50 * 1000;
function getActionWindow() {
if (!this._curActionWindow) {
this._curActionWindow = getEsenMainFrameWindow() || this.window;
}
return this._curActionWindow;
}
function startQueryWebState(a) {
// debugger;
// console.log("startQueryWebState");
// console.log(EUI);
var b = getActionWindow();
if (b._esenface_queryserver_timerid) {
clearTimeout(b._esenface_queryserver_timerid);
}
if (!a) {
a = DEFAULT_PING_TIMEOUT;
}
b._esenface_queryserver_timerid = b.setTimeout(_doWebStateQuery, a);
}
var query_requestCount = 2;
var query_failedcount = 0;
function _doWebStateQuery() {
var param = new EUI.Map();
param.put("action", "webstatequery");
var tp = getActionWindow();
if (tp._esenface_webstatequeries) {
param.put("queriers", tp._esenface_webstatequeries.keySet().join(","));
}
EUI.post({
url: "/edg/eacl/js/login.do",
data: param,
callback: function(queryobj, userdata) {
tp.query_failedcount = 0;
tp._esenface_queryserver_timerid = null;
var txt = queryobj.getDetail();
if (txt == "stopping") {
return;
}
startQueryWebState();
if (txt) {
try {
var querystates = eval("[" + txt + "]");
tp._esenface_webstates = querystates[0];
var keys = tp._esenface_webstatequeries.keySet();
if (query_requestCount) {
query_requestCount++;
if (query_requestCount > 1000) {
query_requestCount = 1;
}
}
for (var i = 0, len = keys.length; i < len; i++) {
var callmap = tp._esenface_webstatequeries.get(keys[i]);
var funckeys = callmap.keySet();
for (var j = 0, clen = funckeys.length; j < clen; j++) {
var callbackfunc = callmap.get(funckeys[j]);
callbackfunc(keys[i], tp._esenface_webstates[keys[i]], query_requestCount);
}
}
} catch (ex) {}
}
},
error: function(e, q, userdata) {
tp.query_failedcount++;
if (q.hp.status == 503) {
if (tp.query_failedcount >= 100) {
tp.query_failedcount = 0;
EUI.showError(e);
return;
}
} else {
if (tp.query_failedcount > 2) {
tp.query_failedcount = 0;
EUI.showError(e);
return;
}
}
startQueryWebState();
},
userdata: window
});
}
function queryStatesNow(names) {
var param = new EUI.Map();
param.put("action", "webstatequery");
var tp = getActionWindow();
if (typeof (names) == "string") {
var arr = [];
arr.push(names);
names = arr;
}
param.put("queriers", names.join(","));
param.put("isOnlyquerier", "true");
var txt = EUI.queryObj("eacl/js/login.do", param);
if (txt) {
try {
var querystates = eval("[" + txt + "]");
var rst = querystates[0];
if (!tp._esenface_webstates) {
tp._esenface_webstates = new Object();
}
for (var i = 0; i < names.length; i++) {
if (rst[names[i]]) {
tp._esenface_webstates[names[i]] = rst[names[i]];
}
}
return rst;
} catch (ex) {}
}
}
function queryStatesAsyn(names, callback) {
var param = new EUI.Map();
param.put("action", "webstatequery");
if (typeof (names) == "string") {
var arr = [];
arr.push(names);
names = arr;
}
param.put("queriers", names.join(","));
param.put("isOnlyquerier", "true");
EUI.QueryObj.create("eacl/js/login.do", param, function(queryobj) {
try {
queryobj.checkResult();
} catch (e) {
EUI.showError(e);
return;
}
var txt = queryobj.getDetail();
if (txt == "stopping") {
return;
}
if (txt) {
try {
var querystates = eval("[" + txt + "]");
var rst = querystates[0];
callback(rst);
} catch (ex) {}
}
});
}
function getQueryState(a) {
var b = getActionWindow();
if (b._esenface_webstates) {
return b._esenface_webstates[a];
} else {
return queryStatesNow(a);
}
}
function updateQueryState(a, b) {
var c = getActionWindow();
if (c._esenface_webstates) {
c._esenface_webstates[a] = b;
}
}
function registQuerier(c, b, a) {
var e = getActionWindow();
if (!e._esenface_webstatequeries) {
e._esenface_webstatequeries = new EUI.Map();
}
if (!a) {
a = b;
}
var d = e._esenface_webstatequeries.get(b);
if (!d) {
d = new EUI.Map();
}
d.put(a, c);
e._esenface_webstatequeries.put(b, d);
}
function removeQuerier(b, a) {
var d = getActionWindow();
if (!a) {
a = b;
}
if (d._esenface_webstatequeries) {
var c = d._esenface_webstatequeries.get(b);
if (!c) {
return;
}
c.remove(a);
if (c.size() == 0) {
d._esenface_webstatequeries.remove(b);
}
}
}
function stopQueryWebState() {
var a = getActionWindow();
if (a._esenface_queryserver_timerid) {
a.clearTimeout(a._esenface_queryserver_timerid);
a._esenface_queryserver_timerid = null;
}
}
function AboutDialog() {
this.wnd = EUI.getRootWindow();
this.doc = this.wnd.document;
this._initAboutDialog();
}
AboutDialog.prototype.dispose = function() {
this.wnd = null;
this.doc = null;
this.dialog.dispose();
}
;
AboutDialog.prototype._initAboutDialog = function() {
var a = this;
if (!this.dialog) {
var b = require("eui/modules/edialog");
this.dialog = new b.EDialog({
wnd: this.wnd,
width: "600",
height: "370",
canResizable: false,
caption: I18N.getString("eacl.commonjs.serverfunc.js.about", "关于")
});
this.dialog.setBottomVisible(false);
this.dialog.setContentIFrameUrl(EUI.getContextPath() + "eacl/serverinfo.do");
}
}
;
function aboutDialog() {
if (!this.dialog) {
this.dialog = new AboutDialog();
}
this.dialog.dialog.open(true);
}
function showQrCode(c, j) {
var b = j.getContainer();
if (!window.mobileQR) {
EUI.include("eacl/login/qrcode.js");
window.mobileQR = new QrCodeDiv(window,false);
}
if (!window.coolQR) {
try {
var a = EUI.ajax({
url: EUI.getContextPath() + "ecool/yuyin/hasPermission.do",
async: false
});
var g = a.getResponseText();
if (g == "true") {
window.coolQR = new QrCodeDiv(window,false,null,I18N.getString("eacl.commonjs.serverfunc.js.coolsyn", "扫码进行酷屏语音同步"),EUI.getContextPath() + "ecool/yuyin/createQRCode.do?contextPath=" + EUI.sys.getRequestURL());
}
} catch (d) {}
}
var h = b.offsetLeft;
var f = b.offsetTop;
var i = b.offsetParent;
while (i) {
h += i.offsetLeft;
f += i.offsetTop;
i = i.offsetParent;
}
if (window.mobileQR._qrcodediv && window.mobileQR._qrcodediv.style.display != "none") {
window.mobileQR.hide();
if (window.coolQR && window.coolQR._qrcodediv.style.display != "none") {
window.coolQR.hide();
}
} else {
window.mobileQR.show(null, {
x: h - 110,
y: f + b.offsetHeight
});
if (window.coolQR) {
window.coolQR.show(null, {
x: h - 110 - 180,
y: f + b.offsetHeight
});
}
}
}
JS_EXPWIZARD = ["eui/modules/etree.js", "eui/modules/edialog.js", "eui/modules/ecommonctrls.js", "eui/modules/epanelsplitter.js", "ecore/js/expwizard/pickerdlg.js", "ecore/js/expwizard/expedit.js"];
function getExpwizardDialog(a) {
return EUI.getObjectFromRootAsync("ExpWizard", "__ESEN$pickerDialog__", true, JS_EXPWIZARD, null, true, a);
}
function showNewMessage(a) {
var b = getActionWindow();
if (a == b._esenface_login_newmsg) {
return;
}
if ($("#msgcnt").length <= 0) {
return;
}
$("#msgcnt")[0].innerHTML = a > 99 ? "99+" : a;
b._esenface_login_newmsg = a;
$("#msgcnt")[0].style.display = a === 0 ? "none" : "block";
$("#msgcnt")[0].parentNode.style.display = a === 0 ? "none" : "block";
$("#msgcnt")[0].parentNode.parentNode.style.display = a === 0 ? "none" : "block";
}
function getEsenMainFrame() {
var b = 0;
var a = window;
while (b++ < 4) {
try {
var c = a.__esen_mainframe;
if (c) {
return c;
}
} catch (d) {}
a = a.parent;
}
}
function getEsenMainFrameWindow() {
var b = 0;
var a = window;
while (b++ < 4) {
try {
var c = a.__esen_mainframe;
if (c) {
return a;
}
} catch (d) {}
a = a.parent;
}
}
function switchLang(b) {
var a = new EUI.Map();
a.put("lang", b);
EUI.QueryObj.create(EUI.getContextPath() + "eacl/locale.do", a, function() {
EUI.getRootWindow().I18N.loadResource(true);
window.location.reload();
});
}
function initLanguageMenu() {
var b = document.getElementById("btn_language");
if (!b) {
return;
}
if (!this.switchlangmenu) {
var a = require("eui/modules/emenu").EPopupMenu;
this.switchlangmenu = new a({});
this.switchlangmenu.loadMenus(languagemenustr, function(d) {
var c = I18N.getLang();
var f = d.getMenuItem("language_" + I18N.getLang());
b.setAttribute("title", f.getCaption().trim());
var e = document.createElement("img");
e.setAttribute("src", f.icon);
b.appendChild(e);
d.getMenuItem("language_" + c).setChecked(true);
});
}
}
function popSwitchLanguage(b) {
var d = b.getBoundingClientRect()
, c = this.switchlangmenu.getContainer().getBoundingClientRect();
var a = d.right - (c.right - c.left)
, e = d.bottom;
this.switchlangmenu.popupAtPosition(a, e);
}
function initLanguageMenuMain(b) {
if (!b || !b.popupMenu) {
return;
}
var a = I18N.getLang();
var d = b.popupMenu;
var c = d.getEMenuItem("language_" + a);
if (c) {
b.setHint(c.getCaption());
b.setImg(c.getIcon());
b.btImg.style.height = "20px";
b.btImg.style.width = "20px";
c.setChecked(true);
}
}
function switchLangMain(a, c) {
var e = c.getName();
var b = e.indexOf("_");
if (b >= 0) {
e = e.substring(b + 1, e.length);
}
if (I18N.getLang() == e) {
c.setChecked(true);
return;
}
var d = new EUI.Map();
d.put("lang", e);
EUI.QueryObj.create(EUI.getContextPath() + "eacl/locale.do", d, function() {
window.location.reload();
});
}
function popSwitchLanguageMain(c) {
var d = btn.getBoundingClientRect()
, b = this.switchlangmenu.getContainer().getBoundingClientRect();
var a = d.right - (b.right - b.left)
, e = d.bottom;
this.switchlangmenu.popupAtPosition(a, e);
}
function restartServer(c, f, d) {
stopQueryWebState();
var b = typeof (c) == "boolean" ? c : false;
var a = typeof (d) == "string" ? d : "";
var e = new EUI.Map();
e.put("action", "restartserver");
e.put("async", b);
e.put("nodeid", a);
if (!b) {
EUI.showWaitDialog(I18N.getString("eacl.commonjs.serverfunc.js.restartingserver", "正在重启服务器..."));
}
new EUI.QueryObj(EUI.getContextPath() + "eacl/setupserver.do",e,function(g) {
try {
g.checkResult();
} catch (h) {
EUI.hideWaitDialog();
EUI.showError(h);
return;
}
if (!b) {
EUI.hideWaitDialog();
}
if (typeof (f) == "function") {
f();
} else {
EUI.getRootWindow().location.reload();
}
}
);
}
function switchPortal(evt) {
var portaldom = document.getElementById("btn_portal");
if (!portaldom) {
return;
}
if (!this.switchportalmenu) {
this.switchportalmenu = new UI.EPopupMenu({});
var contextPath = EUI.getContextPath()
, datas = EUI.queryObj(contextPath + "esmain/portal/portalmgr.do", Map.create({
command: "listportal",
original: true
}));
if (datas) {
datas = eval("(" + datas + ")");
var doc = document;
var urlhref = (doc.defaultView || doc.parentWindow).location.href;
var urlmtc = urlhref.match(/id=([^&]+)/);
var urlportalid = urlmtc ? urlmtc[1] : null;
for (var i = 0, len = datas.length; i < len; i++) {
var data = datas[i];
if (!data["homepage"]) {
continue;
}
var portalid = data["id"];
var item = this.switchportalmenu.addXMenuItem(data["name"] + "(" + data["id"] + ")", null, (function(url, wnd) {
return function() {
wnd.location.href = url;
}
;
}
)(contextPath + "esmain/portal/portal.do?original=true&id=" + portalid, window));
item.setCheckGroup("portal");
}
var item = this.switchportalmenu.addXMenuItem(I18N.getString("eacl.commonjs.serverfunc.js.menu.adminpage", "管理页"), null, (function(url, wnd) {
return function() {
wnd.location.href = url;
}
;
}
)(contextPath + "welcome.do", window));
item.setCheckGroup("portal");
item.setChecked(true);
} else {
this.switchportalmenu.addXMenuItem(I18N.getString("eacl.commonjs.serverfunc.js.menu.no", "无"));
}
}
this.switchportalmenu.popupDownAt(portaldom);
}
function showChangePwdDlg(c, b) {
var a = this;
var d = require("eui/modules/edialog");
if (this.dlg) {
return;
}
this.dlg = new d.EDialog({
wnd: EUI.getRootWindow(),
width: I18N.getString("eacl.commonjs.serverfunc.js.dlgwidth", "560"),
height: I18N.getString("eacl.commonjs.serverfunc.js.dlgheight", "290"),
caption: I18N.getString("eacl.commonjs.serverfunc.js.changepwd", "修改密码")
});
this.dlg.setCanResizable(false);
this.dlg.onclose = function() {
new EUI.QueryObj("eacl/commonjs/checkoldpwd.do","action=doclose",function(e) {}
);
overdueLicenceDlg(b);
}
;
this.dlg.setContentIFrameUrl(EUI.getContextPath() + "eacl/userset/setpw.do?showUserSet=false&showHead=false", function(e) {
var f = e.contentWindow;
f.displayBtn();
f.showTitle(c["message"]);
a.dlg.addButton(I18N.getString("eacl.commonjs.serverfunc.js.ok", "确定"), null, false, true, function() {
EUI.showWaitDialog(1000, I18N.getString("eacl.commonjs.serverfunc.js.changepwding", "正在修改密码"));
var g = f.dosave(null, a.dlg);
if (!g) {
a.dlg.close();
EUI.hideWaitDialogWithComplete(800, I18N.getString("eacl.commonjs.serverfunc.js.changepwdsess", "修改密码成功"));
setTimeout(function() {
a.dlg.dispose();
a.dlg = null;
}, 1500);
}
});
if (!c["isForce"]) {
a.dlg.addButton(I18N.getString("eacl.commonjs.serverfunc.js.cel", "取消"), null, false, false, function() {
a.dlg.close();
a.dlg.dispose();
a.dlg = null;
});
} else {
a.dlg.addButton(I18N.getString("eacl.commonjs.serverfunc.js.loginout", "注销"), null, false, false, function() {
var g = EUI.getContextPath();
if (!window["logoutasync"]) {
EUI.include(g + "eacl/commonjs/serverfunc.js");
}
EUI.confirmDialog(null, I18N.getString("eacl.commonjs.serverfunc.js.suretologoff", "您确定要注销吗?"), false, null, function(h) {
logoutasync(function() {
window.location.href = g + "eacl/login.do";
});
});
});
a.dlg.setHeadButtonVisible(false, 0);
}
});
this.dlg.open(true);
}
function checkOverduePwd() {
EUI.ajax({
url: "eacl/commonjs/checkoldpwd.do",
callback: function(c) {
var a = c.getResponseJSON();
if (a.isCheck) {
var b = a.data;
var d = a.licWarnDay;
if (b) {
showChangePwdDlg(b, d);
} else {
overdueLicenceDlg(d);
}
}
}
});
}
function overdueLicenceDlg(e) {
if (e < 0) {
return;
}
var b = this;
if (!this.licDialog) {
var d = require("eui/modules/edialog");
this.licDialog = new d.EDialog({
wnd: EUI.getRootWindow(),
width: 500,
height: 260,
canResizable: false,
caption: I18N.getString("eacl.commonjs.serverfunc.js.tip", "提示")
});
var c = this.licDialog.getContent();
var a = [];
a.push("<div class='eui-h5 eui-align-center' style=';padding-top: 60px;'><i class='eui-icon eui-icon-l eui-icon-primary eui-padding-right-10'>&#xe0cd;</i>" + I18N.getString("eacl.commonjs.serverfunc.js.showOverdueLicencetip", "服务器还有<span class='eui-error'></span>天到期,请联系销售人员重新注册") + "</div>");
c.innerHTML = a.join("");
this.licDialog.spanDom = $(c).find("span")[0];
this.licDialog.addButton(I18N.getString("eacl.commonjs.serverfunc.js.ok", "确定"), null, false, true, function(f) {
f.close();
});
}
this.licDialog.spanDom.innerText = e;
this.licDialog.open(true);
}
function showCount(b, c, q) {
var r = this;
r.requestCount = q;
var e = c.count;
var n = r.userObj;
var g = EUI.parseBool(n.showStatus, false);
if (e > 0 && g) {
if (!r.targetDom) {
var h = this.getContainer();
var o = $(h).find("i")[0];
var a = document.createElement("label");
a.className = "eui-badge-dot";
o.appendChild(a);
r.targetDom = a;
} else {
EUI.removeClassName(r.targetDom, "eui-hide");
}
} else {
if (r.targetDom) {
if (r.requestCount != q) {
EUI.addClassName(r.targetDom, "eui-hide");
}
}
}
var d = r.popupMenu;
if (d) {
var j = n.items;
for (var f = 0, p = j.length; f < p; f++) {
var r = j[f];
if (r.queryName && (b == r.queryName)) {
var k = r.id;
var l = d.getEMenuItem(k);
var i = l.targetMenuDom;
if (e > 0) {
if (!i) {
var m = l._captionNode;
var a = document.createElement("label");
a.className = "eui-badge";
a.innerHTML = e > 99 ? "99+" : e;
m.appendChild(a);
l.targetMenuDom = a;
} else {
EUI.removeClassName(i, "eui-hide");
if (e != existCount) {
i.innerHTML = e > 99 ? "99+" : e;
}
}
} else {
if (i) {
EUI.addClassName(i, "eui-hide");
}
}
}
}
}
}
function controlItemVisable(d, a) {
var c = this;
var b = a.count;
if (b > 0) {
c.setVisible(true);
} else {
c.setVisible(false);
}
}