var WDEDU_ENTER = 13; var xq = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]; var loadingGIF = ["wait1.svg", "wait2.svg", "wait3.svg", "wait4.svg", "wait5.svg", "wait6.svg", "wait7.svg", "wait8.svg", "wait9.svg", "wait10.svg", "wait11.svg", "wait12.svg"]; opener = null; var thisWin = {}; var thisWinData = {}; var scrollTop = 0; var thisMsgMap = []; try { var _winname = this.name.substr(0, this.name.length - 2); thisWin = p.$("#" + _winname); thisWinData = p.$("#" + _winname).data("paras"); } catch (e) { } $(document).ready(function () { opener = null; window.history.forward(); $("body").bind("contextmenu", function () { window.event.returnValue = false; }); }); function getPageScroll(type) { var yScroll = 0; if (type != null && type == 0) { if (self.pageYOffset) { yScroll = self.pageYOffset; } else if (document.documentElement && document.documentElement.scrollHeight > 0) { // Explorer 6 // Strict yScroll = document.documentElement.scrollHeight; } if (document.body) {// all other Explorers yScroll += document.body.scrollHeight; } } else { yScroll = document.body.scrollHeight; } return yScroll; } function isIE() { if (!!window.ActiveXObject || "ActiveXObject" in window) { return true; } else { return false; } } function returnFSWin(R_retObj, R_inObj) { if (R_retObj != null) { var wh = 160; $(R_inObj.objId + "_img").src = $(R_inObj.objId + "_server").value + R_retObj.url; $(R_inObj.objId + "_file").value = R_retObj.url; changeImgSizeObj($(R_inObj.objId + "_img"), 158, 158); } } function getImgCss(tempImg, wh) { var css = ""; var img = new Image(); img.src = tempImg; if (img.height > img.width && img.height > wh) { css = "height:" + wh + ";"; } else if (img.width > wh) { css = "width:" + wh + ";"; } return css; } function resetImgSize(imgName, height, width) { var imgall = $("#" + imgName); if (imgall.length > 0) { // alert(imgall); var img = new Image(); img.src = imgall.attr("src"); if (img.height > img.width && img.height > height) { imgall.style.height = height; } else if (img.width > width) { imgall.style.width = width; } imgall.style.display = "block"; } } function resetImgSizeObj(imgall, height, width) { //var imgall = $("#" + imgName); imgall.hide(); if (imgall != null) { // alert(imgall); var img = new Image(); img.src = imgall.attr("src"); if (img.height > img.width && img.height > height) { imgall.height(height); } else if (img.width > width) { imgall.width(width); } if (imgall.width() < width) { imgall.css("margin-left", (width - imgall.width()) / 2 + "px"); } imgall.css("vertical-align", "middle"); imgall.show(); } } function changeImgSizeObj(imgObj, width, height) { var img = new Image(); img.src = imgObj.src; var h_ratio = (img.height / height); var w_ratio = (img.width / width); var tempratio = h_ratio > w_ratio ? h_ratio : w_ratio; if (tempratio > 1) { if (h_ratio > w_ratio) { imgObj.height = height; } else { imgObj.width = width; //imgObj.marginTop = Math.floor((height - Math.floor((img.height * imgObj.width) / img.width)) / 2); //alert(imgObj.marginTop); } } else { //imgObj.style.marginLeft = ((width - img.width) / 2) + "px"; } imgObj.style.display = "block"; } function commonRet(_inObj, _data) { $("#s_div").hide(); if (_data == "T") { thisWin.winclose({ ret: _data }); } else { alert(_data); } } function commonRet2(_inObj, _data) { $("#s_div").hide(); $("#t_search").clear; if (_data == null || _data == "" || _data == "T") { } else { alert(_data); } } function openWindowClose(dtIndex, bsid, bsfun, bsparas, paras, cWinName) { thisWin.winclose({ ret: "T" }); p.openWindow(dtIndex, bsid, bsfun, bsparas, paras, p); } function DefEnter(key, jsFun) { if (event.keyCode == key) { eval(jsFun); } return false; } function fs_update(tObj, retFun) { p.openWindow(-1, "PHOTO", "UserPhotoPathListIni", "&in_staffid=" + tObj.staffid, { id: "NRFS_EDIT", width: 850, height: 600, text: "我的文件夹", img: "common/images/win/yggl.png", modal: true, addTask: false, afterclose: retFun, inObj: tObj }, this); } function groupTreeLookUp(_objId, _title, _single, _type, _where, _retFun) { var tObj = {}; tObj.objId = _objId; tObj.single = _single; tObj.type = _type; tObj.where = _where; if (_retFun == null || _retFun == "") { _retFun = "groupTreeLookUpRet"; } p.openWindow(-1, "DCGROUP", "GroupTreeLoopUpIni", "&in_single=" + tObj.single + "&in_type=" + tObj.type, { id: "GROUPTREE_LOOKUP", width: 400, height: 520, text: _title, img: "common/images/win/jggl.png", modal: true, addTask: false, afterclose: _retFun, inObj: tObj }, this); } function groupTreeLookUpRet(_retObj) { if (_retObj != null) { $("#" + _retObj.inObj.objId + "_value").val(_retObj.selids); $("#" + _retObj.inObj.objId + "_text").val(_retObj.seltexts); } } // 加载表格 function clearTable(tableId, _index) { if (_index == null || _index < 0) { //全部删除 _index = 0; } var i = 0; var isTitle = true; $("#" + tableId + " tr").each(function () { if (i >= _index) { $(this).remove(); } i++; }); //设置表格高度 var dpH = $("#" + tableId).attr("dh"); var fat = $("#" + tableId).attr("father"); var _height = $(window).height(); if (fat != null) { _height = fat; } if (dpH != null && dpH > 0) { $("#" + tableId).parent().css("height", _height - dpH); } //滚动条宽度 var _sw = $("#" + tableId).parent()[0].offsetWidth - $("#" + tableId).parent()[0].scrollWidth; $("#" + $("#" + tableId).attr("head") + " tr th:last").css("width", _sw + "px"); if ($("#" + tableId + "_page").length > 0) { setPage(tableId + "_page", 0, 0, 1, ""); } //alert(_sw); } // 加载表格 function clearImgsTable(tableId, _index) { if (_index == null || _index < 0) { //全部删除 _index = 0; } var i = 0; var isTitle = true; //设置表格高度 var dpH = $("#" + tableId).attr("dh"); var _height = $(window).height(); if (dpH != null && dpH > 0) { $("#" + tableId).parent().css("height", _height - dpH); } //alert($("#" + tableId).pareht); } // 加载表格 function addTableRow(tableId, _trid) { if (_trid == null) { var _table = $("#" + tableId).append( ""); var _tr = _table.find("tr:last"); } return _tr; } // 加载表格 function addTableRowEx(tableId, _ptdid, _rowId) { var _table = $("#" + tableId); var _ptr = _ptdid.parent(); var _tr = null; if (_ptr.length > 0) { if ($("tr[exid='" + tableId + "_" + _rowId + "_ex']").length > 0) { _ptr = _table.find("tr[exid='" + tableId + "_" + _rowId + "_ex']:last"); } _tr = _ptr.after(""); _tr = _table.find("tr[exid='" + tableId + "_" + _rowId + "_ex']:last"); } return _tr; } // 加载表格 function removeTableRow() { getTDTarget($(event.target), "TR").remove(); } function getTableRowNum(tableId) { return $("#" + tableId).find("tr").length; } // 加载表格 function addTableCell(tableId, _tr, tdId, _tdHtml, _title, _showAll, _valign) { var table = $("#" + tableId); table.css({"table-layout": "fixed"}); var tableHead = null; var tdWith = ""; var title = (_title != null && _title != "") ? "title=\"" + _title + "\"" : ""; _valign = _valign == null ? "middle" : _valign; if (tableId.length > 0) { tableHead = $("#" + table.attr("head")); //得到对应的td的宽度 var tdLenth = _tr.find("td").length; var th = tableHead.find("tr:first").find("th:eq(" + tdLenth + ")"); tdWith = th.css("width"); var tdWI = th.outerWidth(); if (tdWI == 0) { var style = th.attr("style"); if (style == undefined || style.indexOf("width") == -1) { tdWith = th.width(); } } tdWith = "width:" + tdWith + ";"; } if (_showAll == undefined) { _showAll = true; } var _style = ""; if (_showAll) { _style = "white-space:nowrap;overflow:hidden; text-overflow:ellipsis;-o-text-overflow:ellipsis;vertical-align:middle;"; } else { _style = "word-wrap: break-word;"; } if (_tr.length > 0) { _tr.append("" + _tdHtml + ""); } } // 翻页控件 function setPage(pageDiv, rowsLength, onePageRowsLength, thisPage, clickFun) { // 最大页数 onePageRowsLength = onePageRowsLength == 0 ? 1 : onePageRowsLength; var max = (rowsLength % onePageRowsLength) == 0 ? (rowsLength / onePageRowsLength) : Math.ceil(rowsLength / onePageRowsLength); if (thisPage < 1) { thisPage = 1; } else if (thisPage > max) { thisPage = max; } thisPage = parseInt(thisPage); var _html = ""; // 首页 _html += "首页  上一页"; // 当前 _html += "  " + thisPage + "/" + max + "页  "; _html += "下一页  末页  "; _html += "第 页  "; _html += "  共" + rowsLength + "条记录"; $("#" + pageDiv).html(_html); } function checkAll(_this, _table, _checkId) { $("#" + _table + " input[chtype='" + _checkId + "']").prop("checked", _this.prop("checked")); } function openDialogs(_paras, closeFun, afterCloseFun) { var defaults = { id: "", title: "", width: "80%", father: "", lock: true, mask: true }; var zIndex = 1000; var _opts = $.extend(defaults, _paras); _opts.getid = "#" + _opts.id; var dlgObj = $(_opts.getid).find(".dialog-body"); if (dlgObj.attr("defheight") == 0) { dlgObj.css("height", ($(document).height() - 120) + "px"); } if (_opts.zindex != null) { zIndex = _opts.zindex; } if (_opts.father != "") { zIndex = parseInt($("#" + _opts.father).parent().css("z-index")) + 2; } if (_opts.title != "") { $(_opts.getid + " .dialog-head strong").html(_opts.title); } if (_opts.mask && $("#" + _opts.id + "_mask").length == 0) { $("body").append( "
"); } if (!$(_opts.getid).parent().hasClass("dialog-win")) { $(_opts.getid).wrap( '
'); } var win = $(_opts.getid).parent(); win.find(".dialog").addClass("open"); // $("body").append(win); var x = parseInt($(window).width() - win.outerWidth()) / 2; var y = parseInt($(window).height() - win.outerHeight()) / 2; if (y <= 10) { y = 10; } if (win.outerHeight() >= $(document).height()) { dlgObj.css("height", ($(document).height() - 120) + "px"); } win.css({ "left": x, "top": y }); if ($(_opts.getid).attr("isini") == null) { $(_opts.getid).attr("isini", false); win.find(".dialog-close,.close").each(function () { $(this).click(function () { var isOk = true; if (isOk) { if (afterCloseFun != null) { isOk = afterCloseFun(); } if (isOk) { win.find(".dialog").removeClass("open"); $("#" + _opts.id + "_mask").remove(); } } if (closeFun != null) { isOk = closeFun(); } }); }); $("#" + _paras.getid + "_mask").click(function () { if (!lock) { if (closeFun == null || okFun) { win.find(".dialog").removeClass("open"); $("#" + _opts.id + "_mask").remove(); } } }); } dlgObj.scrollTop(0); }; // 关闭对话框 function closeDialog(getid) { var win = $("#" + getid).parent(); if (win.length > 0) { win.children().children(".dialog").removeClass("open"); $("#" + getid + "_mask").remove(); } }; function getTDTarget(_tag, _name) { if (_tag[0].tagName != _name) { _tag = getTDTarget(_tag.parent(), _name); } return _tag; } var closeAObj = null; // 弹出提示框 function showH5Alert(_id, _text, _alt, _type, _setY, closeFun) { closeTime(_id); var cssO = {}; var alClass = "alert-red"; if (_alt != null) { if (_alt == 1 || _alt == "error") { //错误 alClass = "alert-red"; } else if (_alt == "message") { alClass = "alert-green"; } } if (_setY == null) { _setY = -70; } if (_type != null) { //缺省在底部 cssO = { bottom: 10 }; _type = "bottom"; } else { cssO = { top: 100 }; _type = "top"; } var html = "

" + _text + "

"; $("body").append(html); $("#al_ttalt").animate(cssO, 400, function () { closeAObj = setTimeout(function () { closeH5Alert(_id, _type, _setY); if (closeFun != null) { closeFun(); } }, 2500); }); } function closeH5Alert(_id, _type, _setY) { var cssO = {}; if (_type == "bottom") { cssO = { bottom: _setY }; } else { cssO = { top: _setY }; } $("#al_ttalt").animate(cssO, 400, function () { $("#al_ttalt").remove(); }); } function closeTime(_id) { if (closeAObj != null) { clearTimeout(closeAObj); closeAObj = null; } $("#al_ttalt").remove(); } //发送短信 function toSMS(_phones, _text) { var fromObj = {}; fromObj.phones = _phones; fromObj.text = _text; p.openWindow(-1, "/system/message/index.html", { id: "SMS_LOOKUP", width: 1000, height: 410, text: '信息推送', img: "/common/images/bswin/xxts.png", modal: true, addTask: false, afterclose: "toSMSRet", inObj: fromObj }, this); } function toSMSRet(_data) { } function timeFormatAll(_time) { var showTime = ""; var min = format_number(_time % 60); var hour = format_number(Math.floor(_time / 60)); showTime = hour + ":" + min; return showTime; } function timeToNum(_time) { var timeN = 0; var tims = _time.split(":"); if (tims.length == 2) { timeN = parseInt(tims[0]) * 60 + parseInt(tims[1]); } return timeN; } function format_number(number) { return number < 10 ? '0' + number : number; } //仿真参数 // ********************************************** // 加法函数,用来得到精确的加法结果 // 说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。 // 调用:accAdd(arg1,arg2) // 返回值:arg1加上arg2的精确结果 function accAdd(arg1, arg2) { var r1, r2, m; try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 } try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 } m = Math.pow(10, Math.max(r1, r2)) return (arg1 * m + arg2 * m) / m } // 给Number类型增加一个add方法,调用起来更加方便。 Number.prototype.add = function (arg) { return accAdd(arg, this); } // 减法函数,用来得到精确的加法结果 // 说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。 // 调用:accSub(arg1,arg2) // 返回值:arg1加上arg2的精确结果 function accSub(arg1, arg2) { var r1, r2, m, n; try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 } try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 } m = Math.pow(10, Math.max(r1, r2)); // last modify by deeka // 动态控制精度长度 n = (r1 >= r2) ? r1 : r2; return ((arg1 * m - arg2 * m) / m).toFixed(n); } // 给Number类型增加一个add方法,调用起来更加方便。 Number.prototype.sub = function (arg) { return accSub(arg, this); } // 除法函数,用来得到精确的除法结果 // 说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。 // 调用:accDiv(arg1,arg2) // 返回值:arg1除以arg2的精确结果 function accDiv(arg1, arg2) { var t1 = 0, t2 = 0, r1, r2; try { t1 = arg1.toString().split(".")[1].length } catch (e) { } try { t2 = arg2.toString().split(".")[1].length } catch (e) { } with (Math) { r1 = Number(arg1.toString().replace(".", "")) r2 = Number(arg2.toString().replace(".", "")) return (r1 / r2) * pow(10, t2 - t1); } } // 给Number类型增加一个div方法,调用起来更加方便。 Number.prototype.div = function (arg) { return accDiv(this, arg); } // 乘法函数,用来得到精确的乘法结果 // 说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。 // 调用:accMul(arg1,arg2) // 返回值:arg1乘以arg2的精确结果 function accMul(arg1, arg2) { var m = 0, s1 = arg1.toString(), s2 = arg2.toString(); try { m += s1.split(".")[1].length } catch (e) { } try { m += s2.split(".")[1].length } catch (e) { } return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m) } // 给Number类型增加一个mul方法,调用起来更加方便。 Number.prototype.mul = function (arg) { return accMul(arg, this); } // ********************************************** function getFZWeekObject(list) {// 得到交流列表的周期 var _list = []; if (list.length > 0) { var start = 0; var end = 0; var value = list[0] >= 0; var findNum = 0; for (var i = 1; i < list.length; i++) { var _value = list[i] >= 0; if (value != _value) {// 找到了另一部分 value = _value; findNum++; if (findNum % 2 == 0) { end = i - 1; _list.push({ start: start, end: end }); start = i; end = i; } } } if (end != list.length - 1) { _list.push({ start: start, end: list.length - 1, }); } } return _list; } function getFZWeekValue(objList, list, index) {// 得到电流表的值 var value = 0; var obj = null; for (var i = 0; i < objList.length; i++) { var _obj = objList[i]; if (index >= _obj.start && index < _obj.end) { obj = _obj; break; } } if (obj) { if (obj.value == undefined) { for (var i = obj.start; i < obj.end && i < list.length; i++) { value += accMul(list[i], list[i]); } value = accDiv(value, obj.end - obj.start + 1); value = Math.sqrt(value); obj.value = value; } else { value = obj.value; } } return value; } function getFZWeekValue2(objList, list, list2, index) {// 得到电压表的值 var value = 0; var obj = null; for (var i = 0; i < objList.length; i++) { var _obj = objList[i]; if (index >= _obj.start && index < _obj.end) { obj = _obj; break; } } if (obj) { if (obj.value == undefined) { for (var i = obj.start; i < obj.end && i < list.length; i++) { var v = list[i]; if (i < list2.length) { v -= list2[i]; } value += accMul(v, v);// 平方 } value = accDiv(value, obj.end - obj.start + 1); value = Math.sqrt(value); obj.value = value; } else { value = obj.value; } } return value; } function toAppMessage(_type, _bissid, _title, _text) { var fromObj = {}; fromObj.type = _type;//0:用户,1:教学计划;2:实验班;3:全部计划学生 fromObj.bissid = _bissid; fromObj.label = _title; fromObj.text = _text; p.openWindow(-1, "/system/message/app/index.html", { id: "APPMESSAGE_LOOKUP", width: 800, height: 468, text: _title, img: "/common/images/bswin/jxjh.png", modal: true, addTask: false, afterclose: null, inObj: fromObj }, this); } function stopBubble(e) { if (e && e.stopPropagation) e.stopPropagation(); else window.event.cancelBubble = true; } function getMyImgList(_imgid, _cuser, _afterclose) { var fromObj = {}; fromObj.imgid = _imgid;//0:用户,1:教学计划;2:实验班;3:全部计划学生 fromObj.cuser = _cuser;//0:用户,1:教学计划;2:实验班;3:全部计划学生 p.openWindow(-1, "/system/user/myimgs.html", { id: "MYIMGS_LOOKUP", width: 800, height: 522, text: "相册", img: "/common/images/bswin/jxjh.png", modal: true, addTask: false, afterclose: _afterclose, inObj: fromObj }, this); } // 加载媒体表格 function addTableCellForImg(tableId, imgId, _imgUrl, _descHtml, selectFun) { var _html = ""; _html += "
"; _html += "
"; _html += ""; _html += "
"; _html += _descHtml; _html += "
"; $("#" + tableId).append(_html); if (selectFun != null) { $("#" + imgId).bind("click", function () { selectFun(_imgUrl, imgId); }); } } function resetFile(_obj) { try { if (ie) { // 此处判断是否是IE $('#' + _obj).replaceWith($('#' + _obj).clone(true)); } else { $('#' + _obj).val(''); } } catch (e) { $('#' + _obj).val(''); } } function checkPhone(_phone) { var _tphone = _phone.replace(/(^\s*)|(\s*$)/g, ""); return /^((\(\d{3}\))|(\d{3}\-))?13[0-9]\d{8}?$|15[0-9]\d{8}?$|17[0-9]\d{8}?$|14[0-9]\d{8}?$|18[0-9]\d{8}?$/.test(_tphone); } function previewImage(file, preview) { var MAXWIDTH = 100; var MAXHEIGHT = 100; var div = $('#' + preview).parent(); if (file.files && file.files[0]) { //div.html($('#' + preview)[0].outerHTML); var img = $('#' + preview)[0]; var reader = new FileReader(); reader.onload = function (evt) { img.src = evt.target.result; } reader.readAsDataURL(file.files[0]); } else { var sFilter = 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="'; file.select(); var src = document.selection.createRange().text; //div.html($('#' + preview)[0].outerHTML); var img = $('#' + preview)[0]; img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src; var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight); status = ('rect:' + rect.top + ',' + rect.left + ',' + rect.width + ',' + rect.height); div.html("
"); } } function previewAllImage(file, preview) { var MAXWIDTH = 100; var MAXHEIGHT = 100; var div = $('#' + preview).parent(); $('#' + preview).html(""); if (file.files && file.files.length > 0) { for (var i = 0; i < file.files.length; i++) { var oneF = file.files[i]; var reader = new FileReader(); reader.onload = (function (oneF) { return function (ev) { var _html = ""; _html += "
"; _html += "
"; _html += ""; _html += "
"; $('#' + preview).append(_html); }; })(oneF); reader.readAsDataURL(oneF); } } else { var sFilter = 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="'; file.select(); var src = document.selection.createRange().text; //div.html($('#' + preview)[0].outerHTML); var img = $('#' + preview)[0]; img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src; var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight); status = ('rect:' + rect.top + ',' + rect.left + ',' + rect.width + ',' + rect.height); div.html("
"); } } function previewFile(file, preview) { var fileName = file.files[0].name.toLowerCase(); var tempE = fileName.split("."); $('#' + preview).html(fileName); return tempE[tempE.length - 1]; } function addScript(_path, callback) { $(".tempscript").remove(); var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.type = 'text/javascript'; script.className = "tempscript"; script.onreadystatechange = function () { if (callback != null && this.readyState == 'complete') callback(); } script.onload = function () { if (callback != null) { callback(); } } script.src = _path; head.appendChild(script); } function showSourceIni(_id) { doRefresh(null, "SOURCE", "getSourceShowUrl", "&sourceid=" + _id, function (_data) { if (_data.r == 0) { if (_data.type == 0 || _data.type == 2 || _data.type == 3) { //弹开展示 window.open(_data.url); } else if (_data.type == 1) { //视频" + webHome + "/source/play.html?fid=" + oneD.id + " window.open(_data.url); } else if (_data.type == 6) { //视频" + webHome + "/source/play.html?fid=" + oneD.id + " window.open(_data.url); } else { //文件下载 doRefreshDownLoad("SOURCE", "downloadSource", "&sourceid=" + _id); } } else { alert(_data.error); } }); } function showVideo(_id) { var fromObj = {}; fromObj.fileid = _id; p.openWindow(-1, "/source/play.html", { id: "VIDEO_PLAY", width: 0, height: 600, text: '视频播放', img: "/common/images/bswin/yhgl.png", modal: true, addTask: false, afterclose: "returnCWin", inObj: fromObj }, this); } // 加载媒体表格 function addTableCellForFile(tableId, _fileObj, _descHtml, selectFun) { var _html = ""; _html += "
"; _html += "
"; _html += ""; _html += "
"; _html += _descHtml; _html += "
"; $("#" + tableId).append(_html); if (selectFun != null) { $("#" + _fileObj.fid).parent().bind("click", function () { selectFun(_fileObj); }); } } function showErrDlg(_date, _title) { var _func = "$('#bserror-dlg').remove()"; if (_date.r == 3) { _func = "backToLogin()"; getParent().$(document).keydown(function (e) { if (e.which == 13) { backToLogin(); return false; } }); } if (_title == null || _title == "") { _title = "错误"; } if (getParent().$("#bserror-dlg").length <= 0) { var _html = "
"; _html += "
"; _html += "
" + _date.error + "
"; _html += "
"; _html += "
"; getParent().$("body").append(_html); getParent().$(".errbt").focus(); getParent().openDialogs({ id: "bserror-dlg", title: _title, width: "450px", father: "", zindex: 2800 }, function () { return true; }); } } //从身份证中得到日期 function getBirthdayFromIdCard(idCard) { var birthday = ""; if (idCard != null && idCard != "") { if (idCard.length == 15) { birthday = "19" + idCard.substr(6, 6); } else if (idCard.length == 18) { birthday = idCard.substr(6, 8); } birthday = birthday.replace(/(.{4})(.{2})/, "$1-$2-"); } return birthday; } function doImport(_fileid, _bissid, _paras, closeFun) { if ($("#import-dlg").length <= 0) { //页面加载窗口 var _html = "
"; _html += "
"; _html += "
"; _html += "
"; _html += ""; _html += ""; _html += " 上传XLS文件"; _html += "
"; _html += "
"; _html += "
"; _html += ""; _html += "
"; _html += " 模板下载"; _html += ""; _html += "
"; $("body").append(_html); } $("#pg_filetype").val(_fileid); $("#pg_bissid").val(_bissid); if (_paras != null) { $("#pg_temppath").attr("href", webHome + "/files/import/" + _paras.temppath); $("#pg_tempimg").attr("src", webHome + "/files/import/" + _paras.tempimg); } openDialogs({ id: "import-dlg", title: "文件导入", width: "80%", father: "", zindex: 2500 }, function () { if (closeFun != null) { closeFun(); } return true; }); } function ImportFile() { if ($("#t_file").val() != "" && confirm("是否上传文件?")) { doRefreshFile("form-file", "DCFILE", "ImportFile", "&filetype=" + $("#pg_filetype").val() + "&bissid=" + $("#pg_bissid").val() + "&cuid=" + p.thisLogUser.instid, "t_file_p", function (_data) { resetFile("t_file"); if (_data.r == 0) { alert("导入成功!"); } else { showErrDlg(_data); } $('#l_filename').html(""); }); } } function CheckIdCard(id) { var isOk = false; // 1 "验证通过!", 0 //校验不通过 var format = /^(([1][1-5])|([2][1-3])|([3][1-7])|([4][1-6])|([5][0-4])|([6][1-5])|([7][1])|([8][1-2]))\d{4}(([1][9]\d{2})|([2]\d{3}))(([0][1-9])|([1][0-2]))(([0][1-9])|([1-2][0-9])|([3][0-1]))\d{3}[0-9xX]$/; //号码规则校验 if (!format.test(id)) { alert("身份证号码不合规!"); return isOk; } //区位码校验 //出生年月日校验 前正则限制起始年份为1900; var year = id.substr(6, 4),//身份证年 month = id.substr(10, 2),//身份证月 date = id.substr(12, 2),//身份证日 time = Date.parse(month + '-' + date + '-' + year),//身份证日期时间戳date now_time = Date.parse(new Date()),//当前时间戳 dates = (new Date(year, month, 0)).getDate();//身份证当月天数 if (time > now_time || date > dates) { alert("出生日期不合规!"); return isOk; } //校验码判断 var c = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); //系数 var b = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'); //校验码对照表 var id_array = id.split(""); var sum = 0; for (var k = 0; k < 17; k++) { sum += parseInt(id_array[k]) * parseInt(c[k]); } if (id_array[17].toUpperCase() != b[sum % 11].toUpperCase()) { alert("身份证校验码不合规!"); return isOk; } isOk = true; return isOk } function addWait(_autoClose) { $("#s_div").remove(); $("body").append("
 
"); $("#s_div").show(); showLoading("s_div_img"); if (_autoClose != null && _autoClose > 0) { setTimeout(function () { removeWait(); }, _autoClose); } } function removeWait() { $("#s_div").remove(); } function showLoading(_id, _n) { var n = _n != null ? _n : Math.floor(Math.random() * loadingGIF.length); $("#" + _id).css("background", "url(" + webHome + "/common/images/loading/" + loadingGIF[n] + ") no-repeat center center"); $("#" + _id).parent().show(); return n; } //前面补位0 function pad(num, n) { return (Array(n).join(0) + num).slice(-n); } function servDateToThisDate(_day, _time) { var _days = _day.split("-"); var _times = _time.split(":"); return new Date(_days[0], _days[1] - 1, _days[2], _times[0], _times[1], 0); } function getTimeDistance(timeStr) { let time = null; if (timeStr != null && timeStr != "") { time = new Date(timeStr).getTime(); } else { time = new Date().getTime(); } // 支持传入10位或13位毫秒数,如 1587367194536,"1587367194" // 支持传入日期格式,如 "2020/4/20 15:31:18" if (typeof time == "number" || Number(time) == time) { if (String(time).length == 10) { time = Number(time) * 1000 } else if (String(time).length == 13) { time = Number(time) } else { console.log("时间格式错误"); return time; } } else { if (typeof time == "string" && time.split(" ").length == 2 && time.split(/[- : \/]/).length == 6) { time = new Date(time.replace(/\-/g, '/')).getTime(); } else { console.log("时间格式错误"); return time; } } // 处理之后的time为13位数字格式的毫秒数 var date_now = new Date(); var date_time = new Date(time); var distance = date_now.getTime() - time; var days = Math.floor(distance / (1000 * 60 * 60 * 24)); if (days == 1) { return "昨天" } else if (days > 1 && days < 4) { return days + "天前"; } else if (days > 3) { // 超过3天的,返回日期,如 2018-12-05 // 如果是今年的,就省去年份,返回 12-05 var year = date_time.getFullYear(); var month = date_time.getMonth() + 1; if (month < 10) { month = "0" + month; } var day = date_time.getDate(); if (day < 10) { day = "0" + day; } if (date_now.getFullYear() == year) { return "超过一个月"; } else { return "多年前"; } } var hours = parseInt((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); if (hours > 0) { return hours + "小时前"; } var minutes = parseInt((distance % (1000 * 60 * 60)) / (1000 * 60)); if (minutes > 0) { return minutes + "分钟前"; } return "刚刚"; } function dateFormat(datetime) { var year = datetime.getFullYear(); var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1; var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate(); var hour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime.getHours(); var minute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes() : datetime.getMinutes(); var second = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds() : datetime.getSeconds(); return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second; } function fomatFloat(src, pos) { return Math.round(src * Math.pow(10, pos)) / Math.pow(10, pos); } function isJSON(str) { let isjson = typeof (obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() == "[object object]" && !obj.length; return isjson; } //处理温度 function setCurWD(_inT) { let _t = _inT; try { _t = parseFloat(_t).toFixed(1); } catch (e) { } return _t; } //处理湿度 function setCurSD(_inT) { let _t = _inT; try { _t = parseFloat(_t).toFixed(1); } catch (e) { } return _t; } // function setCurDB(_inT) { let _db = _inT; try { let _dbs = _db.split(","); if (_dbs.length == 2) { _db = "强度" + _dbs[0] + (_dbs[1] != 0 ? "误码率" + _dbs[1] : ""); } } catch (e) { } return _db; } // function getTimeStr(_dateObj, _showSend) { let _timeStr = ""; try { if (_dateObj != null) { _timeStr += (" " + _dateObj.getFullYear() + "年" + (_dateObj.getMonth() + 1) + "月" + _dateObj.getDate() + "日 "); _timeStr += (pad(_dateObj.getHours(), 2) + ":" + pad(_dateObj.getMinutes(), 2) + ":" + pad(_dateObj.getSeconds(), 2)); } } catch (e) { } return _timeStr; } //日期格式化2021-06-01 12:49:00 function getTimeStrfomart(_dateObj, _showSend) { let _timeStr = ""; try { if (_dateObj != null) { var month = _dateObj.getMonth() + 1 < 10 ? "0" + (_dateObj.getMonth() + 1) : _dateObj.getMonth() + 1; var date = _dateObj.getDate() < 10 ? "0" + _dateObj.getDate() : _dateObj.getDate(); _timeStr += (" " + _dateObj.getFullYear() + "-" + month + "-" +date + " "); _timeStr += (pad(_dateObj.getHours(), 2) + ":" + pad(_dateObj.getMinutes(), 2) + ":" + pad(_dateObj.getSeconds(), 2)); } } catch (e) { } return _timeStr; } //日期格式化20210806t150000z function getTimeStrfomartvideo(_dateObj, _showSend) { let _timeStr = ""; try { if (_dateObj != null) { var month = _dateObj.getMonth() + 1 < 10 ? "0" + (_dateObj.getMonth() + 1) : _dateObj.getMonth() + 1; var date = _dateObj.getDate() < 10 ? "0" + _dateObj.getDate() : _dateObj.getDate(); _timeStr += ("" + _dateObj.getFullYear() + "" + month + "" +date + "t"); _timeStr += (pad(_dateObj.getHours(), 2) + "" + pad(_dateObj.getMinutes(), 2) + "" + pad(_dateObj.getSeconds(), 2)+"z"); } } catch (e) { } return _timeStr; } function formatTDate(_dateStr) { try { let _list = _dateStr.split('T'); if (_list.length > 0) { let _newS = _list[0] + " " + _list[1].substr(0, 8); return _newS; } else { return _dateStr; } } catch (e) { return _dateStr; } } function toDate(str) { if (isIE) { try { //首先将日期分隔 ,获取到日期部分 和 时间部分 let day = str.split(' '); //获取日期部分的年月日 let days = day[0].split('-'); //获取时间部分的 时分秒 let mi = day[day.length - 1].split(':'); //获取当前date类型日期 let date = new Date(); //给date赋值  年月日 date.setUTCFullYear(days[0], days[1] - 1, days[2]); //给date赋值 时分秒  首先转换utc时区 :+8       date.setUTCHours(mi[0] - 8, mi[1], mi[2]); return date; } catch (e) { return new Date(str); } } else { return new Date(str); } } function getTimeCount(_fTime, _tTime, _type) { let _tc = 0; if (_type == "s") { _tc = Math.floor((_tTime.getTime() - _fTime.getTime()) / 1000); } else if (_type == "mi") { _tc = Math.floor((_tTime.getTime() - _fTime.getTime()) / (1000 * 60)); } else if (_type == "h") { _tc = Math.floor((_tTime.getTime() - _fTime.getTime()) / (1000 * 60 * 60)); } return _tc; } function showMQMsg(_msg) { //0:目标信息; 1:设备信息; 2:事件信息; 3:报警信息; 4:摄像头指令 let _data = JSON.parse(decodeURIComponent(_msg.data)); let _tempTime = ""; let _html = ""; let _bgType = "bg-main"; let _code = ""; _data.mqType = _msg.mqType; thisMsgMap[thisMsgMap.length] = _data; if (_msg.mqType == 0) { _html = ""; //_html = ("发现目标"); _tempTime = _data.updateTime; _code = _data.targetCode; } else if (_msg.mqType == 1) { //_html = ("发现设备"); _html = ""; _code = _data.deviceId; } else if (_msg.mqType == 2) { let _tempM = _data.eventMark.split(","); if (_tempM.length > 1) { _tempM.length = _tempM.length - 1; _html = (_tempM.toString()); } else { _html = (_data.eventMark); } _tempTime = _data.sendTime; _bgType = "bg-dot"; _code = _data.targetCode; playSound(webHome + "/common/audio/Alarm02.wav"); } else if (_msg.mqType == 3) { _html = (_time + " 有新的报警"); _bgType = "bg-dot"; } else if (_msg.mqType == 4) { } if (_html != "") { showMsg(_code, _html, _bgType, _tempTime, thisMsgMap.length - 1); } } function showMsg(_code, _html, _tclass, _time, _msgIndex) { _tclass = (_tclass != null && _html != "") ? _tclass : "bg-blue"; let _dt = ""; if (_time != null && _time != "") { _dt = getTimeDistance(_time); } else { _dt = getTimeDistance(); } $("#l_mqmsg").prepend("
" + _html + "
" + _dt + "
"); let _bo = ($("#l_mqmsg").height() + 1); if (_bo >= $("#l_mqmsg_p").height()) { $("#l_mqmsg").css("bottom", "0px"); $("#l_mqmsg").css("top", "0px"); } else { $("#l_mqmsg").removeAttr("bottom", _bo + "px"); } $("#l_mqmsg").scrollTop(0); $("#l_mqmsg_p").scrollTop(0); } function doMsgClick(_code, _msgIndex) { if (_msgIndex != null && _msgIndex != "") { try { doMyMsgClick(_code); } catch (e) { } //alert(JSON.stringify(thisMsgMap[_msgIndex])); } } //文本改图片提示,消息服务器连接/断开20210812 function showMsgwebsoket(_code, _html, _tclass, _time, _msgIndex) { _tclass = (_tclass != null && _html != "") ? _tclass : "bg-blue"; let _dt = ""; if (_time != null && _time != "") { _dt = getTimeDistance(_time); } else { _dt = getTimeDistance(); } let img="/yyyzweb/common/images/point/"+_html+".png"; $("#l_mqmsg").prepend("
"); let _bo = ($("#l_mqmsg").height() + 1); if (_bo >= $("#l_mqmsg_p").height()) { $("#l_mqmsg").css("bottom", "0px"); $("#l_mqmsg").css("top", "0px"); } else { $("#l_mqmsg").removeAttr("bottom", _bo + "px"); } $("#l_mqmsg").scrollTop(0); $("#l_mqmsg_p").scrollTop(0); } function doMsgClick(_code, _msgIndex) { if (_msgIndex != null && _msgIndex != "") { try { doMyMsgClick(_code); } catch (e) { } //alert(JSON.stringify(thisMsgMap[_msgIndex])); } } function playSound(_files) { if (isIE()) { //IE内核浏览器 var strEmbed = ''; if ($("body").find("embed").length <= 0) $("body").append(strEmbed); var embed = document.embedPlay; //浏览器不支持 audion,则使用 embed 播放 embed.volume = 100; //embed.play();这个不需要 } else { //非IE内核浏览器 var strAudio = "