hxp
2024-09-06 49523e4f736ed3aac7ba4e4148b1b99098525b51
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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;
}