var gt = new Gettext({ 'domain': 'gmtjs' });
|
|
// 检查是否输入验证码
|
function CheckKey(keyid) {
|
if (document.getElementById(keyid).type != "hidden" && !document.getElementById(keyid).value) {
|
alert(gt.gettext("请输入授权码!"));
|
return false;
|
}
|
return true;
|
}
|
|
// 插入超链接
|
function inserthyperlink(keyID) {
|
var curValue = document.getElementById(keyID).value;
|
// document.getElementById(keyID).value = curValue + "[{文本}]({地址})";
|
document.getElementById(keyID).value = curValue + "<a>" + gt.gettext("文本") + "|openurl=url</a>";
|
}
|
|
// 插入游戏界面
|
function insertgameform(keyID) {
|
var curValue = document.getElementById(keyID).value;
|
// document.getElementById(keyID).value = curValue + "[{文本}]({dfm界面名})";
|
document.getElementById(keyID).value = curValue + "<a>" + gt.gettext("文本") + "|openui=" + gt.gettext("界面编号") + "</a>";
|
}
|
|
function selectall(checkboxkey, tagcheckboxClassName) {
|
var checked = document.getElementById(checkboxkey).checked;
|
//var items=document.getElementsByName(tagcheckboxkey);
|
var items = document.getElementsByClassName(tagcheckboxClassName);
|
//循环设置所有复选框状态
|
for (var i = 0; i < items.length; i++) {
|
items[i].checked = checked;
|
}
|
}
|
|
// 返回当前日期加减运算后的日期
|
function sumDateByDays(days) {
|
var date = new Date();
|
date.setDate(date.getDate() + days);
|
var month = date.getMonth() + 1;
|
var day = date.getDate();
|
return date.format("yyyy-MM-dd")
|
}
|
|
// 判断是否是数字
|
function isRealNum(value) {
|
// isNaN()函数 把空串 空格 以及NUll 按照0来处理 所以先去除
|
if (value === "" || value == null) {
|
return false;
|
}
|
return !isNaN(value) && typeof value === 'number'
|
}
|
|
//浏览器类型判定
|
function getOs() {
|
if (navigator.userAgent.indexOf("MSIE") > 0) {
|
return "IE"; //InternetExplor
|
} else if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) {
|
return "FF"; //firefox
|
} else if (isSafari = navigator.userAgent.indexOf("Safari") > 0) {
|
return "SF"; //Safari
|
} else if (isCamino = navigator.userAgent.indexOf("Camino") > 0) {
|
return "C"; //Camino
|
} else if (isMozilla = navigator.userAgent.indexOf("Gecko/") > 0) {
|
return "G"; //Gecko
|
} else if (isMozilla = navigator.userAgent.indexOf("Opera") >= 0) {
|
return "O"; //opera
|
} else {
|
return 'Other';
|
}
|
}
|
|
//获取换行符
|
function getbr() {
|
var os = getOs();
|
if (os == 'FF' || os == 'SF') { //FireFox、谷歌浏览器用这个
|
return "\n";
|
} else { //IE系列用这个
|
return "\r\n";
|
}
|
}
|
|
/**
|
* 打开子页面
|
* @param {string} url 目标子页面地址,可直接带get参数
|
* @param {string} target
|
* @param {int} width
|
* @param {int} height
|
*/
|
function doopen(url, target = "sonwindow", width = 1000, height = 900) {
|
// 兼容分屏
|
var l = (window.screenX || window.screenLeft || 0) + (screen.availWidth - width) / 2;
|
var t = (screen.availHeight - height) / 2;
|
var specs = 'width=' + width + ',height=' + height + ',top=' + t + ', left = ' + l +
|
',toolbar=no,menubar=no,location=no';
|
// var url = 'userlogdetail.php?GUID=' + GUID + '&Num=' + Num + "&showDetail=" + showDetail;
|
myWindow = window.open(url, target, specs);
|
myWindow.focus();
|
}
|
|
/**
|
* AJAX请求
|
* @param {*} url
|
* @param {*} cFunction
|
*/
|
function ajaxRequest(url, cFunction, method = "GET") {
|
var xhttp;
|
xhttp = new XMLHttpRequest();
|
xhttp.onreadystatechange = function () {
|
if (this.readyState == 4 && this.status == 200) {
|
cFunction(this);
|
}
|
};
|
if (method == "GET") {
|
xhttp.open("GET", url, true); // 异步
|
xhttp.send();
|
} else {
|
var spInfo = url.split("?");
|
xhttp.open("POST", spInfo[0], true);
|
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
xhttp.send(spInfo.length > 1 ? spInfo[1] : "");
|
}
|
}
|
|
function random(min, max) {
|
return Math.round(Math.random() * (max - min)) + min;
|
}
|
|
var isQuerying = false;
|
function setSubmitQuerying(key) {
|
if (isQuerying) {
|
alert(gt.gettext("查询中..."));
|
return false;
|
}
|
isQuerying = true;
|
document.getElementById(key).value = gt.gettext("查询中...");
|
return true;
|
}
|