var status; (function (root, undefined) { var cgicall = (function () { function doCmd() { var obj, url, cmd, argc = arguments.length, successCallfn = function (d, x, s) {}, errorCallfn = function (d, x, s) {}; if (typeof (arguments[argc - 1]) === 'function') { if (typeof (arguments[argc - 2]) === 'function') { argc = argc - 2; successCallfn = arguments[argc]; errorCallfn = arguments[argc + 1]; } else { argc = argc - 1; successCallfn = arguments[argc]; } } obj = (argc == 2 && typeof arguments[1] === 'object') ? arguments[1] : {}; //console.log(arguments[0]); if (arguments[0] === "DMZ" || arguments[0] === "URLPOLICY" || arguments[0] === "URLFILTER" || arguments[0] === "MACPOLICY" || arguments[0] === "MACFILTER"){ url = '../../cgi-bin/internet.cgi'; } else if (arguments[0] === "IPBANDLIST" || arguments[0] === "WAN_BLACK" || arguments[0] === "NETCHECK" || arguments[0] === "GRE"){ url = '../../cgi-bin/internet.cgi'; } else if (arguments[0] === "PORTRANGLIST" || arguments[0] === "FIREWALL" || arguments[0] === "IPv6" || arguments[0] === "DHCP" || arguments[0] === "VPN"){ url = '../../cgi-bin/internet.cgi'; } else if (arguments[0] === "QOSLIS" || arguments[0] === "DUALWAN" || arguments[0] === "QOSENABLE" || arguments[0] === "PORTLIST"){ url = '../../cgi-bin/internet.cgi'; } else if ( arguments[0] === "WAN" || arguments[0] === "LAN"){ url = '../../cgi-bin/internet.cgi'; } else if (arguments[0] === "WIRELESS_SECURITY" || arguments[0] === "APCLIENT" || arguments[0] === "MESH" || arguments[0] === "MESHPBC"){ url = '../../cgi-bin/wireless.cgi'; } else if (arguments[0] === "FLOW_CTRL" || arguments[0] === "FLOW_ASSISTANT"){ url = '../../cgi-bin/flow.cgi'; } else if (arguments[0] === "WIZARD" || arguments[0] === "SETPW" || arguments[0] === "SETNET" || arguments[0] === "SETWIFI"){ url = '../../cgi-bin/wizard.cgi'; } else if (arguments[0] === "CELLLOCL" || arguments[0] === "LOCK_FREQ" || arguments[0] === "USSD" || arguments[0] === "MASK" || arguments[0] === "PINSET"){ url = '../../cgi-bin/modem.cgi'; } else if (arguments[0] === "CARRIERSEL" || arguments[0] === "DISCONNECT" || arguments[0] === "CONNECT" || arguments[0] === "NETSELECT"){ url = '../../cgi-bin/modem.cgi'; } else if (arguments[0] === "APNLIST" || arguments[0] === "APN"){ url = '../../cgi-bin/modem.cgi'; } else { url = '../../cgi-bin/adm.cgi'; } obj.CMD = arguments[0]; $.ajax({ url: url, type: 'post', dataType: 'text', data: obj, success: successCallfn, error: errorCallfn }); } return { "doCmd": doCmd } }()); function jsonTraversal(func) { var obj = {}, index = 0; for (var i = 0; i < CA.length; i++) { CA[i].v = func(CA[i].n, CA[i].v); //if (CA[i].v !== CA[i].o) { obj[CA[i].n] = CA[i].v; index++; //} } return obj; } function jsTravSet(fp, v) { var doc = getControlByIdMisc(fp), type = doc.attr('type'); switch (type) { case "checkbox": var arr = doc.val().split(" "); var str = v.toString(); doc.prop("checked", str == arr[0]); break; case "radio": var that = doc.attr("name"); $('input:radio[name="' + that + '"]').each(function (index, element) { $(element).prop("checked", $(element).val() == v); }); break; default: doc.val(v); break; } return v; } function jsTravGet(fp, v) { var nv, doc = getControlByIdMisc(fp), type = doc.attr('type'), dataType = doc.attr('data-type'); switch (type) { case 'checkbox': var arr = doc.val().split(" "); if (arr.length == 1) { if (arr[0] == "1") { arr[1] = "0"; } else if (arr[0] == "true") { arr[1] = "false"; } else { console.log(fp + 'checkbox value fail'); } } if (typeof v == "boolean") { arr[0] = true; arr[1] = false; } else if (typeof v == "number") { arr[0] = parseInt(arr[0]); arr[1] = parseInt(arr[1]); } nv = doc.is(":checked") ? arr[0] : arr[1]; break; case 'radio': var that = doc.attr("name"); nv = $('input:radio[name="' + that + '"]:checked').val(); if (typeof v == "number") nv = parseInt(nv); break; default: if (dataType === 'ip') { nv = _IP.ipFormat(doc.val()); } else { nv = doc.val(); } break; } nv = (typeof (nv) == 'undefined' ? v : nv); if (typeof (v) == 'number') nv = parseInt(nv); return nv; } function getControlByIdMisc(id) { var id = id.replace(/\//g, '-'), id = id.replace(/\:/g, '_'); res = $('input#' + id); if (res.length < 1) res = $('select#' + id); if (res.length < 1) res = $('#' + id); return res; } function createModalTips(tip, e) { $("#modal_tips .modal-p span").html(tip); $("#modal_tips .modal-footer .btn-modal").remove(); if (typeof (e) != "undefined") { var input = ''; $("#modal_tips .modal-footer").append(input); } $("#modal_tips").modal("show"); } function setDefaultData(d) { if (typeof d === 'object') { for (var k in d) { setCfgDefault(d[k]); } } else { setCfgDefault(d); } } root.cgicall = cgicall; root.jsonTraversal = jsonTraversal; root.jsTravGet = jsTravGet; root.jsTravSet = jsTravSet; root.createModalTips = createModalTips; root.setDefaultData = setDefaultData; })(this); Date.prototype.format = function (format) { var date = { "M+": this.getMonth() + 1, "d+": this.getDate(), "h+": this.getHours(), "m+": this.getMinutes(), "s+": this.getSeconds(), "q+": Math.floor((this.getMonth() + 3) / 3), "S+": this.getMilliseconds() }; if (/(y+)/i.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)); for (var k in date) { if (new RegExp("(" + k + ")").test(format)) { format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? date[k] : ("00" + date[k]).substr(("" + date[k]).length)); } } return format; } function inputting(obj) { var maxLength = obj.getAttribute("maxlength"); var length = obj.value.replace(/[^\x00-\xff]/g, "012").length; while (length > maxLength) { obj.value = obj.value.substr(0, obj.value.length - 1); length = obj.value.replace(/[^\x00-\xff]/g, "012").length; } } function intToIpstr(ip) { return String((ip >>> 24) & 0xff) + "." + String((ip >>> 16) & 0xff) + "." + String((ip >>> 8) & 0xff) + "." + String((ip >>> 0) & 0xff); } function ipstrToInt(ipstr) { var ip = ipstr.split("."); return (Number(ip[0]) * 16777216) + (Number(ip[1]) * 65536) + (Number(ip[2]) * 256) + (Number(ip[3]) * 1); } function cidrToInt(cidr) { var x = 0; for (var i = 0; i < cidr; i++) { x += (0x80000000 >>> i); } return x; } function intToCidr(ip) { for (var i = 0; i <= 31; i++) { if ((ip & (1 << (31 - i))) == 0) break; } return i; } function cidrToMaskstr(cidr) { var ip = cidrToInt(cidr); return intToIpstr(ip); } function ObjClone(obj) { var o; if (typeof obj == "object") { if (obj === null) { o = null; } else { if (obj instanceof Array) { o = []; for (var i = 0, len = obj.length; i < len; i++) { o.push(ObjClone(obj[i])); } } else { o = {}; for (var j in obj) { o[j] = ObjClone(obj[j]); } } } } else { o = obj; } return o; } function maskstrToCidr(maskstr) { var ip = ipstrToInt(maskstr); return intToCidr(ip); } function OnShowlock(that) { var tt = $(this).closest('.form-group').find('input.form-control') if (tt.length > 0 && (tt.attr('type') == 'text' || tt.attr('type') == 'password')) { if (tt.attr('type') == 'password') { $(this).find('i').removeClass('icon-lock').addClass('icon-lock-open-2'); tt.attr('type', 'text'); } else { $(this).find('i').removeClass('icon-lock-open-2').addClass('icon-lock'); tt.attr('type', 'password'); } } } function setPage(tableID, pno, psize) { var itable = document.getElementById(tableID); var num = itable.rows.length; //表格所有行数(所有记录数) var totalPage = 0; //总页数 var pageSize = psize || 10; //每页显示行数 var cnum = itable.rows[1].cells.length; //总共分几页 if (num / pageSize > parseInt(num / pageSize)) { totalPage = parseInt(num / pageSize) + 1; } else { totalPage = parseInt(num / pageSize); } var currentPage = pno; //当前页数 if (pno == 1) { pageSize = psize ? (psize + 1) : 11; //每页显示行数 } var startRow = (currentPage - 1) * pageSize + 1; //开始显示的行 31 var endRow = currentPage * pageSize; //结束显示的行 40 endRow = (endRow > num) ? num : endRow; //40 //console.log(endRow); //遍历显示数据实现分页 for (var i = 1; i < (num + 1); i++) { var irow = itable.rows[i - 1]; if (pno == 1) { if (i >= startRow && i <= endRow) { irow.style.display = "table-row"; } else { irow.style.display = "none"; } } else { if ((i - 1) >= startRow && (i - 1) <= endRow) { irow.style.display = "table-row"; } else { irow.style.display = "none"; } } } if ((num >= 2) && (cnum != 1) && ((pno == 1) || (pno == totalPage))) endRow -= 1; if ((num - 1) / 10 < totalPage && (num - 1) % 10 == 0) { totalPage -= 1; } // // var pageEnd = document.getElementById("pageEnd"); var tempStrMsg = '
' + la_show + startRow + la_to + endRow + la_entries_none + '' + la_of + (num - 1) + la_entries + '
'; if ((num == 2) && (cnum == 1)) { tempStrMsg = '' + la_z_to_z + '' + la_of_z + '
'; } var tempStr = ""; if (currentPage > 1) { tempStr += '' + la_first_page + ''; tempStr += '' + la_pre_pre_page + ''; } else { tempStr += '' + la_first_page + ''; tempStr += '' + la_pre_page + ''; } var curT1 = true; var curT2 = true; for (var j = 1; j < totalPage + 1; j++) { if (totalPage > 8) { if ((j == 1)) { if (currentPage == j) { tempStr += '' + j + ''; } else { tempStr += '' + j + ''; } } else if (j == totalPage) { if (currentPage == j) { tempStr += '' + totalPage + ''; } else { tempStr += '' + totalPage + ''; } } else { if (j < currentPage) { if (((currentPage - j) <= 3) && ((currentPage - j) > 0)) { tempStr += '' + j + ''; } else if (((currentPage - j) > 3) && (j > 1) && curT1) { curT1 = false; tempStr += '...'; } } else if (j > currentPage) { if (((j - currentPage) > 0) && ((j - currentPage) <= 3)) { tempStr += '' + j + ''; } else if (((j - currentPage) > 3) && (j < totalPage) && curT2) { curT2 = false; tempStr += '...'; } } else { tempStr += '' + currentPage + ''; } } } else { if (j != currentPage) { tempStr += '' + j + ''; } else { tempStr += '' + j + ''; } } } if (currentPage < totalPage) { tempStr += '' + la_next_next_page + ''; tempStr += '' + la_last_page + ''; } else { tempStr += "" + la_next_page + ""; tempStr += "" + la_last_page + ""; } document.getElementById(tableID + "_page").innerHTML = tempStrMsg + '' + tempStr + '
'; } function getWscAuthType(val) { var type = 1; switch (val) { case "WPAPSK": type = 2; break; case "SHARED": type = 4; break; case "WPAPSKWPA2PSK": type = 32; break; case "WPA2PSKWPA3PSK": type = 33; break; default: type = 1; break; } return type; } function getWscEncrypType(val) { //无线密码加密算法转化 var type = 1; switch (val) { case "WEP": type = 2; break; case "TKIP": type = 4; break; case "AES": type = 8; break; case "TKIPAES": type = 12; break; default: type = 1; break; } return type; } function getAllEncrypt(cls) { var len = $(cls).length; var type = ""; for (var i = 0; i < 4; i++) { if (i < len) type += $(cls).eq(i).val(); else type += "OPEN"; if (i != 3) type += ";"; } return type; } function setEncryMode(num, v) { var arr = v.split(";"); num = parseInt(num) ? parseInt(num) : 0; return arr[num] ? arr[num] : ""; }