123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- String.prototype.replaceAll = function(s1,s2){
- return this.replace(new RegExp(s1,"gm"),s2);
- }
- String.prototype.endsWith = function(suffix) {
- return this.indexOf(suffix, this.length - suffix.length) !== -1;
- };
- if (!Array.prototype.includes) {
- Object.defineProperty(Array.prototype, 'includes', {
- value: function(searchElement, fromIndex) {
-
- if (this == null) {
- throw new TypeError('"this" is null or not defined');
- }
- var o = Object(this);
-
- var len = o.length >>> 0;
-
- if (len === 0) {
- return false;
- }
-
-
- var n = fromIndex | 0;
-
-
-
-
-
- var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
-
- while (k < len) {
-
-
-
-
- if (o[k] === searchElement) {
- return true;
- }
- k++;
- }
-
- return false;
- }
- });
- }
- function getContextPath() {
- var pathName = document.location.pathname;
- var index = pathName.substr(1).indexOf("/");
- var result = pathName.substr(0,index+1);
- result=result=="/myconsole"?"":result;
- return result;
- }
- function hide(inputid) {
- $("#tr_" + inputid).hide();
- $("#" + inputid).val("");
- }
- function show(inputid) {
- $("#tr_" + inputid).show();
- }
- function alarmFormatter(cellvalue, options, rowdata) {
- return ' <img src="data:image/png;base64,' + cellvalue + '" class="bigimg" onclick=show("' + cellvalue + '") id="img'
- + rowdata.Id + '" style="height:35px;"/>';
- }
- function modifyJosnKey(json, oddkey, newkey) {
- var val = json[oddkey];
- delete json[oddkey];
- json[newkey] = val;
- }
- function addModel(modelName, postdata) {
- $.each(postdata, function(index, value) {
-
- if (index != "jqGrid_id" && index != "oper" && index != "id") {
- modifyJosnKey(postdata, index, modelName + "." + index);
- }
- if (index == "id") {
- postdata[modelName + "." + index] = value
- }
-
- })
- return postdata;
- }
- function makeTree(inputid,actionURL,type){
- var menuContentID=inputid+"_menuContent";
- var treeDemoID=inputid+"_tree";
-
-
- var check={enable: true,chkStyle: "radio",radioType: "all"};
- if(type=="checkbox"){
- check={enable: true,chkboxType: {"Y":"", "N":""}};
- }
-
- var hideMenu=function () {
- $("#"+menuContentID).fadeOut("fast");
- $("body").unbind("mousedown", onBodyDown);
- }
- var onBodyDown=function (event) {
- if (!(event.target.id == "menuBtn" || event.target.id == inputid
- || event.target.id == menuContentID || $(event.target).parents(
- "#"+menuContentID).length > 0)) {
- hideMenu();
- }
- }
- var onClick=function (e, treeID, treeNode) {
- var zTree = $.fn.zTree.getZTreeObj(treeID);
- zTree.checkNode(treeNode, !treeNode.checked, null, true);
- return false;
- }
- var onCheck=function (e, treeID, treeNode) {
- var zTree = $.fn.zTree.getZTreeObj(treeID),
- nodes = zTree.getCheckedNodes(true),
- v = "",
- rv = "";
-
- for (var i = 0, l = nodes.length; i < l; i++) {
- rv += nodes[i].id + ",";
- v += nodes[i].name + ",";
- }
- if (v.length > 0)
- v = v.substring(0, v.length - 1);
- if (rv.length > 0)
- rv = rv.substring(0, rv.length - 1);
-
-
-
- $("#" + inputid).val(rv);
- $("#" + inputid).attr("offval",rv);
-
- $("#_" + inputid).val(v);
- }
- $.get(getContextPath()+actionURL,{"parentid":$("#"+inputid).val()},function(data){
- $("#_"+inputid).val(data);
- })
- var value=$("#"+inputid).val();
- var upbtn=$('<input class="FormElement ui-widget-content ui-corner-all" role="textbox" type="text" id="_'+inputid +'" value="'+value+'"/>');
-
- $("#"+inputid).parent().append(upbtn);
- $("#"+inputid).hide();
- var setting = {
- check: check,
- view: {
- dblClickExpand: false
- },
- data: {
- simpleData: {
- enable: true,
- idKey: "id",
- pIdKey: "parentid",
- rootPId: "0"
- }
- },
- callback: {
- onClick: onClick,
- onCheck: onCheck
- }
- };
- $("#_"+inputid).click(function(){
- var id = $("#"+inputid).val();
- $.get(getContextPath()+actionURL,{id:$("#"+inputid).attr("rowid")},function(data){
- zNodes=data;
- $("#"+menuContentID).remove();
- var menu='<div id="'+menuContentID+'" class="menuContent" style="display:none; position: absolute;"><ul id="'+treeDemoID+'" class="ztree" style="margin-top:0; width:250px; height: 180px;"></ul></div>';
- $("#"+inputid).parent().append(menu);
- var tree=$.fn.zTree.init($("#"+treeDemoID), setting, zNodes);
- var cityObj = $("#_"+inputid);
- var cityOffset = $("#_"+inputid).position();
- $("#"+menuContentID).css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
- $("body").bind("mousedown", onBodyDown);
- var nodes = tree.getNodesByParam("id", id, null);
- tree.checkNode(nodes[0], true, true);
- });
- })
- }
- function dyniframesize(down) {
- var pTar = null;
- if (document.getElementById) {
- pTar = document.getElementById(down);
- } else {
- eval('pTar = ' + down + ';');
- }
- if (pTar && !window.opera) {
-
- pTar.style.display = "block"
- if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight) {
-
- pTar.height = pTar.contentDocument.body.offsetHeight + 20;
- pTar.width = pTar.contentDocument.body.scrollWidth + 20;
- } else if (pTar.Document && pTar.Document.body.scrollHeight) {
-
- pTar.height = pTar.Document.body.scrollHeight;
- pTar.width = pTar.Document.body.scrollWidth;
- }
- }
- }
- function design(templateFile){
- window.open(templateFile);
- }
- function fullOpen(winurl) {
- objWin__ = window.open( winurl,"","top=0,left=0,scrollbars=yes,width="+(screen.availWidth-200)+",height="+(screen.availHeight-30));
- objWin__ .focus();
- }
|