/** * 全局公用js;每个页面都必(bì)须引用! * * esung Team 2012 */ //日志记录 var log = { disable : false, //是否(fǒu)开启(qǐ)日志(zhì) logInfos : [], getTime : function(){ return (new Date()).getTime(); }, info : function(msg, time) { if(this.disable) return; //if(this.logInfos.length > 100) this.logInfos = []; if(time != undefined) msg += " elapsed : " + time + "ms"; this.logInfos.push(time > 100 ? "" + msg + "" : msg); }, showInfo : function(){ var dialog = $("#_Dialog_Log"); if(!dialog.length){ dialog = $("
").appendTo("body"); } dialog.dialog({ content : this.logInfos.join("
") }).dialog("open"); } };$(function(){ //只(zhī)读控件的处理 $("[readonly='true'],[readonly='readonly']").readOnly(); //绑定事件 $(window).unbind("keydown.global").bind("keydown.global",function(event){ var keyCode = event.keyCode; var doPrevent = false;//是否阻(zǔ)制默认行为 //退格键 if(keyCode == 8){ var d = event.srcElement || event.target; if (d.tagName.toUpperCase() == 'INPUT' || d.tagName.toUpperCase() == 'TEXTAREA') { doPrevent = d.readOnly || d.disabled; } else doPrevent = true; ///CTRL+ALT+X调用日志控制(zhì)台 } else if(keyCode == 88 && event.altKey && event.ctrlKey){ log.showInfo(); } if (doPrevent) event.preventDefault(); }); });// --------【prototype】扩展(zhǎn)start----------------------------------- String.prototype.getByteLength = function() { var _WJ_ = this.match(/[^\x00-\xff]/ig); return this.length + (_WJ_ == null ? 0 : _WJ_.length); };/** * 数字格(gé)式化为金(jīn)额,默认保留两位数 * 如:1234.5678 -> 1,234.57 * @param num * @param n * @returns */ function formatNum(num,n){ n = n || 2; if(num==null){ num = ""; } else { num = num.toFixed(n) + ""; } var intNum = num, decNum = ""; var pointIndex = num.indexOf("."); if (pointIndex >= 0) { intNum = num.substring(0, pointIndex); decNum = num.substring(pointIndex + 1, num.length); } var p = /(\d+)(\d{3})/; while (p.test(intNum)) { intNum = intNum.replace(p, "$1,$2"); } if (decNum) { return intNum + "." + decNum; } else { return intNum; } }// --------【prototype】扩展end----------------------------------- var SkinUtil = {};SkinUtil.getSkin = function() { var currSkin = SkinUtil.getCookie("appskin"); if (!currSkin) { currSkin = "default"; } var pathName = window.document.locations.pathname; // 获取工程(chéng)项目跟路径/esung //if (pathName.indexOf("main.jsp") >= 0) { if (pathName.indexOf("loginMain.do") >= 0) { //alert(pathName) document.write(''); } document.write(''); };SkinUtil.getCookie = function(objName) {// 获取指定(dìng)名(míng)称的cookie的值 var arrStr = document.cookie.split("; "); for ( var i = 0; i < arrStr.length; i++) { var temp = arrStr[i].split("="); if (temp[0] == objName) return unescape(temp[1]); } };SkinUtil.addCookie = function(objName, objValue, objHours) {// 添加cookie var str = objName + "=" + escape(objValue); if (objHours > 0) {// 为0时不设定过期(qī)时间,浏览(lǎn)器关闭时cookie自动消失 var date = new Date(); var ms = objHours * 3600 * 1000; date.setTime(date.getTime() + ms); str += "; expires=" + date.toGMTString(); } document.cookie = str; }; SkinUtil.getSkin(); var $document = $(document);$document.ajaxStart(function(event, request, settings) { //闪屏效(xiào)果不佳,先去除 /** if ($("div.dg-mask").length > 0) { $("div.dg-mask").css({ display : "block" }); // $("div.dg-mask-msg").css({display:"block"}); } else { $("
").css({ "z-index" : "9999", "background-color" : "#FFF", "filter" : "alpha(opacity=50)", "-moz-opacity" : "0.5", "-khtml-opacity" : "0.5", "display" : "block", "position" : "absolute", "width" : "100%", "height" : $(window).height() }).appendTo("body"); // $("
").html("正在处理,请稍候。。。").appendTo("body").css({"display":"block","left":($(document.body).outerWidth(true) - 190) / 2,"top":($(window).height() - 45) / 2}); }**/ }); $document.ajaxComplete(function(event, request, settings) { /**$("div.dg-mask").css({ display : "none" });**/ var jsonResult=jsonevals(request.responseText); if(jsonResult){ if(jsonResult.msg!=undefined&&jsonResult.msg.length>0){ $.messager.alert("提(tí)示(shì)!",jsonResult.msg,"info"); } if(jsonResult.redirecturl!=undefined&&jsonResult.redirecturl.length>0){ window.locations.href = _ContextPath+jsonResult.redirecturl; } } // $("div.dg-mask-msg").css({display:"none"}); }); // --------【皮肤(fū)】封装(zhuāng)end-----------------------------------// --------【菜(cài)单】封装(zhuāng)start--------------------------------- /** * 初(chū)始化系统菜(cài)单方(fāng)法,扩展(zhǎn)的jquery方法(fǎ) * @param options * @returns options.fn * @author zhangsm {@link http://www.esung.com 翼星有限公司} */ (function($) { $.extend($.fn, { initSysMenu : function(options) { this.each(function() { var $this = $(this); var url = $this.attr('url'); var method = $this.attr('method'); $.ajax({ type : 'GET', url : url, cache : false, success : function(response) { var json = jsonevals(response); $.each(json, function(key, value) { var menuId = "menu_" + value.id; //alert(menuId); var menuPanelId = "childPanel_" + value.id; if(value.children != null){ $this.append("" + value.text + ""); var $children = $("