//检测版本号(需要和后台ActionUtil!getMyAPPVersion的版本号一致)
|
var version = "1.0.3";
|
function checkAPPVersion(callback) {
|
$.ajax({
|
type: 'post',
|
async: true,
|
url: 'ActionUtil!getMyAPPVersion',
|
data: null,
|
dataType: 'json',
|
success: function(res) {
|
var rs = JSON.parse(res.json);
|
var newVersion = rs.msg;
|
if(newVersion==version) {
|
callback(true, version, newVersion);
|
}else {
|
callback(false, version, newVersion);
|
}
|
}
|
});
|
}
|
|
|
var GLOBAL = {};
|
|
// 给GLOBAL添加属性
|
GLOBAL.namespace = function(str) {
|
var arr = str.split('.'), o = GLOBAL;
|
for(var i=(arr[0] == 'GLOBAL')?1:0; i<arr.length; i++) {
|
o[arr[i]] = o[arr[i]] || {};
|
o = o[arr[i]];
|
}
|
};
|
|
var timeID;
|
//在页面右上角显示登陆用户的用户名
|
function setUserName(){
|
checkUserlogin();
|
}
|
|
//安全退出
|
function exitUser(){
|
$.post("LoginAction!exitUser",null,function(data){
|
//console.info(data);
|
});
|
window.location.replace("login.jsp");
|
}
|
|
|
// 检查当前用户是否在另一主机登陆
|
function checkUserlogin(){
|
//console.info("check***********************");
|
$.post("LoginAction_check",null,function(data){
|
data = eval("(" + data.result + ")");
|
user=data.uinf;
|
//console.info(data);
|
if(data.code == 1){
|
clearInterval(timeID);
|
//console.info(123+"*****");
|
alert(data.msg);
|
window.location.href="login.jsp";
|
}else{
|
clearInterval(timeID);
|
timeID = setTimeout(checkUserlogin,100);
|
}
|
}).error(function(){
|
clearInterval(timeID);
|
});
|
};
|
|
|
|
// 配置是否是登录页
|
function isLogin(hf) {
|
var _isLogin = false;
|
var patt = /login.jsp/;
|
if(patt.test(hf)) {
|
_isLogin = true;
|
}
|
return _isLogin;
|
}
|
|
//取当前页面名称(带后缀名)
|
function getpageName()
|
{
|
var strUrl=location.href;
|
var arrUrl=strUrl.split("/");
|
var strPage=arrUrl[arrUrl.length-1];
|
var pattern = /(.*\.jsp).*/;
|
var regStr = pattern.test(strPage);
|
var rsPage = RegExp.$1;
|
return rsPage;
|
}
|
|
|
|
// Cookie
|
function getCookie(c_name) { // 根据分隔符取每个变量的值
|
if (document.cookie.length > 0) {
|
c_start = document.cookie.indexOf(c_name + "=");
|
if (c_start != -1) {
|
c_start = c_start + c_name.length + 1;
|
c_end = document.cookie.indexOf("^", c_start);
|
if (c_end == -1)
|
c_end = document.cookie.length;
|
return unescape(document.cookie.substring(c_start, c_end));
|
}
|
}
|
return "";
|
}
|
|
// 设置cookie中的用户名以及密码
|
function setCookie(c_name, n_value, p_name, p_value, expiredays) // 设置cookie
|
{
|
var exdate = new Date();
|
exdate.setDate(exdate.getDate() + expiredays);
|
document.cookie = c_name + "=" + escape(n_value) + "^" + p_name + "="
|
+ escape(p_value)
|
+ ((expiredays == null) ? "" : "^;expires=" + exdate.toGMTString());
|
//console.log(document.cookie+"888");
|
}
|
|
// 设置cookie中的用户名以及密码
|
function setCookietemp(c_name, n_value,expiredays) // 设置cookie
|
{
|
var exdate = new Date();
|
exdate.setDate(exdate.getDate() + expiredays);
|
document.cookie = c_name + "=" + escape(n_value)
|
+ ((expiredays == null) ? "" : "^;expires=" + exdate.toGMTString());
|
//console.log(document.cookie+"888");
|
}
|
|
function setMyCookie(key,value,days){
|
console.info(Base64.encode(JSON.stringify(value)));
|
setCookietemp(key,Base64.encode(new Buffer(JSON.stringify(value)).toStirng()),days);
|
}
|
|
function checkCookie() // 检测cookie是否存在,如果存在则直接读取,否则创建新的cookie
|
{
|
var username = getCookie("username");
|
var password = getCookie("password");
|
//console.info("username"+getCookie("username"));
|
//console.info("password"+getCookie("password"));
|
if (username != null && username != "" && password != null
|
&& password != "") {
|
document.getElementById("user").value = username;
|
document.getElementById("password").value = password;
|
} else {
|
// username = prompt('Please enter your name:', "");
|
// password = prompt('Please enter your name:', "");
|
if (username != null && username != "" && password != null
|
&& password != "") {
|
setCookie('username', username, 'password', password, 30);
|
}
|
}
|
}
|
|
function cleanCookie(c_name, p_name) { // 使cookie过期
|
document.cookie = c_name + "=" + ";" + p_name + "="
|
+ ";expires=Thu, 01-Jan-70 00:00:01 GMT";
|
//console.info("删除成功");
|
}
|
|
//深复制一个对象(改变新对象的值,原对象的值不变)
|
var deepCopy= function(source) {
|
var result={};
|
for (var key in source) {
|
console.info(key);
|
result[key] = typeof source[key]==='object'?deepCopy(source[key]): source[key];
|
}
|
return result;
|
};
|
|
|
|
var CapType_Rest = 0; //当查询剩余容量时传递
|
var CapType_Real = 1; //当查询实际容量时传递
|
var STDAH; //标纯容量
|
var MonomerVolType; //电池电压类型
|
// 获取标纯电流
|
function GetFDCurrent(stdcap,hourrate)
|
{
|
var res = 0.055;
|
switch(hourrate)
|
{
|
case 1: res = 0.514; break;
|
case 2: res = 0.306; break;
|
case 3: res = 0.250; break;
|
case 4: res = 0.200; break;
|
case 5: res = 0.166; break;
|
case 6: res = 0.146; break;
|
case 7: res = 0.131; break;
|
case 8: res = 0.118; break;
|
case 9: res = 0.108; break;
|
case 10: res = 0.100; break;
|
case 20: res = 0.055; break;
|
default: res = 0.055; break;
|
}
|
|
return (stdcap * res);
|
}
|
|
// 获取放电小时率 stdah:标纯容量 current:当前电流
|
function GetHourRate(stdah,current)
|
{
|
var index = 0;
|
var value=[5.14, 3.06, 2.50, 2.00, 1.66, 1.46, 1.31, 1.18, 1.08, 1.00, 0.55, 0.40];
|
var res;
|
current = Math.abs(current);
|
res = current/(stdah/10);
|
if(res >= 5.14) return 1;
|
else if(res <= 0.55) return 20;
|
else
|
{
|
for(var index=0; index<10; index++)
|
{
|
if((res<=value[index]) && (res>value[index+1]))
|
break;
|
else continue;
|
}
|
if((value[index]-res) < (res-value[index+1]))
|
{
|
return (index+1);
|
}
|
else
|
{
|
if(index+2 > 10) return (20);
|
else return (index+2);
|
}
|
}
|
}
|
|
function N_TO_10H(n_H)
|
{
|
switch(n_H)
|
{
|
case 1 : return(1/0.55);
|
case 2 : return(1/0.61);
|
case 3 : return(1/0.75);
|
case 4 : return(1/0.79);
|
case 5 : return(1/0.833);
|
case 6 : return(1/0.876);
|
case 7 : return(1/0.917);
|
case 8 : return(1/0.944);
|
case 9 : return(1/0.974);
|
case 10: return(1/1);
|
case 20: return(1/1.1);
|
}
|
return 1.0;
|
}
|
|
//获取剩余容量 STDAH:标称容量 HourRate:放电小时率 SumAH:测试容量 MaxMonomerVol:最大电池电压 MonomerVol:当前电池组的最低单体电压
|
//MonomerVolType:电池标称电压 CapType:容量类型(定值是常量)
|
function GetMonomerCap(STDAH,HourRate,SumAH,MaxMonomerVol,
|
MonomerVol,MonomerVolType,CapType)
|
{
|
if((MaxMonomerVol - MonomerVolType*0.9) <= 0)
|
return 0;
|
if(SumAH < 0)
|
SumAH *= (-1);
|
var tmp_cap;
|
tmp_cap = MonomerVol - MonomerVolType * 0.9;
|
tmp_cap *= (STDAH - SumAH * N_TO_10H(HourRate));
|
var dt_vol = MaxMonomerVol - MonomerVolType*0.9;
|
if(dt_vol < 0.01)
|
dt_vol = 0.01;
|
tmp_cap = tmp_cap/dt_vol;
|
if(tmp_cap < 0)
|
tmp_cap = 0;
|
|
if(CapType == CapType_Rest)
|
return tmp_cap;
|
else if(CapType == CapType_Real)
|
return (tmp_cap + SumAH * N_TO_10H(HourRate));
|
else
|
return ((tmp_cap + SumAH * N_TO_10H(HourRate))*100 / STDAH);
|
}
|
|
/* 获取电池组续航时间
|
* 续航时长=实际容量/(放电小时率*实际电流(45))
|
* @param int moncapstd 电池组标称容量
|
* @param int realcap 电池组实际容量
|
* @param int curr53 实时电流(53)
|
*
|
*/
|
function getGruopEndurTimeLong(moncapstd, realcap, curr53) {
|
var endurTimeLong = 0;
|
if(curr53 != 0) {
|
var real_curr45 = curr53*53/45;
|
var hourRate = N_TO_10H(GetHourRate(moncapstd, real_curr45));
|
endurTimeLong = realcap/(hourRate*real_curr45);
|
}
|
|
return endurTimeLong;
|
}
|
|
//获取后备时间
|
function GetRestTimeSecond(restcap,curr)
|
{
|
var tmp_curr = Math.abs(curr);
|
if(tmp_curr < 0.1)
|
tmp_curr = 0.1;
|
|
var rest_time = ((restcap / tmp_curr) * 3600);
|
if(rest_time > (99*3600))
|
rest_time = (99*3600);
|
return rest_time;
|
}
|
|
// 增大和减小容器
|
function changeEleHt(ele, ele_fir_ht, ele_sec_ht, status) {
|
if(status == 0) {
|
ele.height(ele_fir_ht + ele_sec_ht);
|
status = 1;
|
}else {
|
ele.height(ele_sec_ht);
|
status = 0;
|
}
|
return status;
|
}
|
|
//将秒转化成00M00H类型
|
function formatTime1(value) {
|
var theTime = parseInt(value);// 秒
|
var theTime1 = 0;// 分
|
var theTime2 = 0;// 小时
|
|
if(theTime >= 60) {
|
theTime1 = parseInt(theTime/60);
|
theTime = parseInt(theTime%60);
|
// alert(theTime1+"-"+theTime);
|
if(theTime1 >= 60) {
|
theTime2 = parseInt(theTime1/60);
|
theTime1 = parseInt(theTime1%60);
|
}
|
}
|
var result = "";
|
if(theTime1 >= 0) {
|
result =(theTime1<10?"0":"")+parseInt(theTime1)+"M"+result;
|
}
|
if(theTime2 >= 0) {
|
result =(theTime2<10?"0":"")+parseInt(theTime2)+"H"+result;
|
}
|
return result;
|
}
|
|
//将秒转化成时:分:秒
|
function formatSeconds(value) {
|
if(value > 0){
|
|
}else{
|
value = 0;
|
}
|
var theTime = parseInt(value);// 秒
|
var theTime1 = 0;// 分
|
var theTime2 = 0;// 小时
|
// alert(theTime);
|
if(theTime >= 60) {
|
theTime1 = parseInt(theTime/60);
|
theTime = parseInt(theTime%60);
|
//alert(theTime1+"-"+theTime);
|
if(theTime1 >= 60) {
|
theTime2 = parseInt(theTime1/60);
|
theTime1 = parseInt(theTime1%60);
|
}
|
}
|
var result = (theTime<10?"0":"")+parseInt(theTime);
|
if(theTime1 >= 0) {
|
result =(theTime1<10?"0":"")+parseInt(theTime1)+":"+result;
|
}
|
if(theTime2 >= 0) {
|
result =(theTime2<10?"0":"")+parseInt(theTime2)+":"+result;
|
}
|
//console.info(result);
|
return result;
|
}
|
|
//格式化时间
|
Date.prototype.format =function(format)
|
{
|
var o = {
|
"M+" : this.getMonth()+1, //month
|
"d+" : this.getDate(), //day
|
"h+" : this.getHours(), //hour
|
"m+" : this.getMinutes(), //minute
|
"s+" : this.getSeconds(), //second
|
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
|
"S" : this.getMilliseconds() //millisecond
|
};
|
if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
|
(this.getFullYear()+"").substr(4- RegExp.$1.length));
|
for(var k in o)if(new RegExp("("+ k +")").test(format))
|
format = format.replace(RegExp.$1,
|
RegExp.$1.length==1? o[k] :
|
("00"+ o[k]).substr((""+ o[k]).length));
|
return format;
|
};
|
/**
|
*
|
* @param {} p 需要拷贝的对象或数组
|
* @param {} c (拷贝对象时:new Object() 拷贝数组时:new Array())
|
* @return {} 拷贝后的对象(包括对象和数组)
|
*/
|
function deepCopy(p, c) {
|
var c = c || {};
|
for (var i in p) {
|
if (typeof p[i] === 'object') {
|
c[i] = (p[i].constructor === Array) ? [] : {};
|
deepCopy(p[i], c[i]);
|
} else {
|
c[i] = p[i];
|
}
|
}
|
return c;
|
}
|
|
|
//根据电池组id查询机历卡信息
|
function findBattinfByBattGroupId(BattGroupId){
|
$.post("BattInfAction_findByBattGroupId","bif.BattGroupId="+BattGroupId,function(data){
|
//data=eval("("+data+")");
|
data=data.result;
|
data=eval("("+data+")");
|
//console.info(data);
|
if(data.code==1){
|
if(data.data.length>0){
|
data=data.data[0];
|
document.getElementById("StationId").innerHTML=data.StationId; //机房id
|
document.getElementById("StationName").innerHTML=data.StationName; //机房名称
|
document.getElementById("StationIP").innerHTML=data.StationIp; //机房ip
|
document.getElementById("batt_group_id").innerHTML=data.BattGroupId; //电池组ip
|
|
document.getElementById("BattGroupName").innerHTML=data.BattGroupName; //电池组名称
|
document.getElementById("BattGroupNum").innerHTML=data.GroupIndexInFBSDevice+1; //电池组序号
|
document.getElementById("BattProducer").innerHTML=data.BattProducer; //电池品牌
|
document.getElementById("BattModel").innerHTML=data.BattModel; //电池型号
|
document.getElementById("MonCapStd").innerHTML=data.MonCapStd; //标称容量
|
document.getElementById("MonVolStd").innerHTML=(data.MonVolStd).toFixed(1); //标称电压
|
document.getElementById("MonResStd").innerHTML=data.MonResStd.toFixed(3); //标称内阻
|
//document.getElementById("MonSerStd").innerHTML=data.MonSerStd.toFixed(0); //标称内阻
|
document.getElementById("MonTmpStd").innerHTML=data.MonTmpStd.toFixed(1); //标称温度
|
document.getElementById("MonCount").innerHTML=data.MonCount; //单体数量
|
document.getElementById("BattInUseDate").innerHTML=data.BattInUseDate; //投入使用时间
|
if(data.BattGuarantDayCount>0){
|
//$("#BattGuarantDayCount").text(data.BattGuarantDayCount); //保修年限
|
}else{
|
//$("#BattGuarantDayCount").text("已超过保修"+Math.abs(data.BattGuarantDayCount)+"天"); //保修年限
|
}
|
document.getElementById("BattFloatCurrent").innerHTML=data.BattFloatCurrent; //电池浮充电流阀值
|
document.getElementById("FloatVolLevel").innerHTML=data.FloatVolLevel; //电池均充电压阀值
|
document.getElementById("FBSDeviceName").innerHTML=data.FBSDeviceName; //设备名称
|
document.getElementById("FBSDeviceId").innerHTML=data.FBSDeviceId; //设备Id
|
//console.info(data);
|
document.getElementById("FBSDeviceIp").innerHTML=data.FbsDeviceIp; //设备Ip
|
document.getElementById("GroupIndexInFBSDevice").innerHTML=data.GroupIndexInFBSDevice; //Bindex
|
document.getElementById("installUser").innerHTML= data.install_user; // 安装人员
|
|
//显示电池组机历卡
|
$('#card_infor').show();
|
$('#allShade').show();
|
}
|
}
|
});
|
}
|
|
//根据stationid查询基站的信息
|
function findStationInfoByStation(temp){
|
//console.info(JSON.stringify(temp));
|
$.ajax({
|
type:"post",
|
url: "Battinf_exAction!serchByCondition",
|
async:true,
|
dataType:'json',
|
data:"json="+JSON.stringify(temp),
|
success: function(data){
|
var model = eval('('+data.result+')');
|
//console.log(model);
|
if(model.code == 1 && model.data.length>0){
|
var station = model.data[0];
|
//console.info(station);
|
$('#station_stationid_ex').text(temp.StationId_ex); //站点id
|
$('#station_stationname').text(station.stationName); //机房名称
|
$('#station_stationid').text(station.stationId); //机房名称
|
$('#station_affiliation').text(station.affiliation); //所属组织
|
$('#station_dataSources').text(station.dataSources); //数据来源
|
$('#station_stationType').text(station.stationType); //站址类型
|
$('#station_jinweidu').text("经度:" + station.longitude+";纬度:"+station.latitude); //经纬度
|
$('#station_stationAddr').text(station.stationAddr); //所在地址
|
$('#station_stationstate').text("站址等级:"+station.stationLevel+";维护状态:"+station.maintenanceState+";封锁状态:"+(station.blockedState==0?'否':'是')); //机房状态
|
$('#station_maintenanceCompany').text(station.maintenanceCompany); //维护单位
|
$('#station_stationscenario').text("业务场景:"+station.businessScenario+";覆盖场景:"+station.CoverScenario+";站址地形:"+station.siteTerrain); //站址场景
|
$('#station_stationproperty').text("产权性质:"+station.propertyRights+";(原)产权单位:"+station.propertyUnit+";是否共享:"+(station.isShare==1?'是':'否')); //站址产权
|
$('#station_useUnit').text(station.useUnit); //使用单位
|
$('#station_siteCode').text(station.siteCode); //物理站址编码
|
$('#station_historySiteCode').text(station.historySiteCode); //历史物理站址编码
|
$('#station_siteInternalNumber').text(station.siteInternalNumber); //站址内部编号
|
$('#station_sitePinyinReferred').text(station.sitePinyinReferred); //站址拼音简称
|
$('#station_siteChineseReferred').text(station.siteChineseReferred); //中文简称
|
$('#station_isOpenBusiness').text(station.isOpenBusiness); //是否开通业务
|
$('#station_schoolPersonnel').text(station.schoolPersonnel); //录入人员
|
$('#station_entryTime').text(station.entryTime); //录入时间
|
$('#station_modifyPeople').text(station.modifyPeople); //修改人
|
$('#station_modifyTime').text(station.modifyTime); //修改时间
|
$('#station_note').text(station.note); //备注
|
$('#station_receiveorvalidity').text("站址接收标记:"+(station.siteReceivesMark==1?'是':'否')+";是否有效:"+(station.siteValidity==1?'是':'否')); //备注
|
$('#station_siteNameCMCC').text(station.siteNameCMCC); //移动站址名称
|
$('#station_siteNameCTC').text(station.siteNameCTC); //联通站址名称
|
$('#station_siteNameCUCC').text(station.siteNameCUCC); //电信站址名称
|
$('#station_producer').text(station.producer); //品牌
|
$('#station_lastTimeLong').text(station.lastTimeLong); //续航测算时长
|
$('#station_lastTimeType').text(station.lastTimeType); //续航测算类别
|
$('#station_lastTimeDate').text(station.lastTimeDate); //续航发生时间
|
$('#station_shareInfo').text(station.shareInfo); //共享情况
|
$('#station_electPower').text("移动购买:"+(station.electPowerCMCC==1?'是':'否')+";电信购买:"+(station.electPowerCTC==1?'是':'否')+";联通购买:"+(station.electPowerCUCC==1?'是':'否')); //共享情况
|
$('#station_isCanElectPower').text(station.isCanElectPower==1?'是':'否'); //是否具备发电条件
|
$('#station_upperStationRoute').text(station.upperStationRoute); //上站路程
|
$('#station_upperStationDifficult').text(station.upperStationDifficult); //上站难易程度
|
$('#station_clienteleErrorService').text(station.clienteleErrorService); //客户问题库未完成蓄电池维修
|
|
}
|
}
|
});
|
}
|
|
|
//根据num获取故障类型和故障排除方法
|
function getTypeBynum(num,list){
|
if(num>=0 && list!=undefined && list.length>0){
|
for(var i=0;i<list.length;i++){
|
if(list[i].num==num){
|
return list[i];
|
}
|
}
|
}
|
return undefined;
|
}
|
|
var brdnType=[
|
{num:0,type:'漏液'},
|
{num:1,type:'单体电压过低'},
|
{num:2,type:'单体电压过高'},
|
{num:3,type:'电池反极'},
|
{num:4,type:'电池温度过高'},
|
{num:5,type:'电池变形'},
|
{num:6,type:'其他'}
|
];
|
var brdnRemove=[
|
{num:0,type:'整组更换'},
|
{num:1,type:'单节更换'},
|
{num:2,type:'活化'}
|
];
|
|
// 根据点击的位置显示内容
|
function setPosition(container, xLeft, yTop) {
|
container.find('a').css('white-space','nowrap');
|
// 上下位置
|
var scrnHt = $(window).height(); // 获取屏幕的高度
|
var yBottom = scrnHt - yTop; // 获取点击位置距离屏幕底部的距离
|
var conHt = container.height();
|
if(yBottom < conHt) {
|
var shiftY = conHt -yBottom;
|
container.offset(function(n, c) {
|
var newPos = new Object();
|
newPos.top = c.top - shiftY-2;
|
newPos.left = c.left;
|
return newPos;
|
});
|
}
|
|
// 左右位置
|
var scrnWidth = $(window).width();
|
var xRight = scrnWidth - xLeft;
|
var conWidth = container.width();
|
if(xRight < conWidth) {
|
var shiftX = conWidth -xRight;
|
container.offset(function(n, c) {
|
var newPos = new Object();
|
newPos.left = c.left - shiftX-2;
|
newPos.top = c.top;
|
return newPos;
|
});
|
}
|
}
|
|
//生成整体遮罩层()
|
function createAllMask(ele,opcy){
|
var __Ht=ele.height();
|
var __div=$('<div class="mask"></div>');
|
ele.prepend(__div);
|
//定义遮罩层的样式
|
ele.children('.mask').css({
|
// 'display':'block',
|
'position':'absolute',
|
'width':'100%',
|
'height':__Ht+'px',
|
'left':'0',
|
'top':'0',
|
'z-index':'9999999',
|
'opacity':opcy,
|
'background-color':'#000'
|
});
|
}
|
|
//获取连接中的指定参数
|
function getQueryString(name) {
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
var r = window.location.search.substr(1).match(reg);
|
if (r != null) {
|
return decodeURI(r[2]);
|
}
|
return null;
|
}
|
|
function createEleWarning(num, muted){
|
//清理告警框
|
$('body').children('#eleWarning').remove();
|
var __divCon=$('<div id="eleWarning"></div>'); //告警容器
|
var __divHeadCon=$('<div class="warning-head"></div>'); //告警头部容器
|
var __divHeadImg=$('<div class="warning-img"></div>'); //告警图片
|
var __divHeadOut=$('<div class="warning-out">x</div>'); //告警退出
|
var __divClear=$('<div class="clear"></div>'); //清除浮动
|
__divHeadCon.append(__divHeadImg);
|
__divHeadCon.append(__divHeadOut);
|
__divHeadCon.append(__divClear);
|
__divCon.append(__divHeadCon);
|
|
/* 告警的内容*/
|
var __divContentCon=$('<div class="warning-content"></div>'); //告警内容容器
|
/* 告警的音频*/
|
var __divAudio=$('<audio autoplay="autoplay"></audio>');
|
// 判断是否静音
|
if(muted) {
|
__divAudio=$('<audio autoplay="autoplay" muted></audio>');
|
}
|
var __divSourceWav=$('<source src="sound/warnings.wav" type="audio/wav" />');
|
var __divSourceMp3=$('<source src="sound/warnings.mp3" type="audio/mpeg" />');
|
__divAudio.append(__divSourceWav);
|
__divAudio.append(__divSourceMp3);
|
|
|
var __divContentTxt=$('<div class="warning-txt">出现了新告警:<span class="caret"><a href="elewarn.jsp" target="_blank">'+num+'</a></span></div>'); //告警内容
|
__divContentCon.append(__divContentTxt);
|
__divContentCon.append(__divAudio);
|
__divCon.append(__divContentCon);
|
$('body').append(__divCon);
|
}
|
|
|
|
//点击x清除告警框
|
$(document).ready(function(){
|
//点击x清除告警框
|
$('body').on('click','#eleWarning .warning-head .warning-out',function(){
|
$('body').children('#eleWarning').remove();
|
});
|
});
|
|
var totalAlm_num=Number.POSITIVE_INFINITY;
|
//查询告警数
|
function searchAlm(isShowVoice){
|
// 判断是否显示右下角的告警提示框
|
if(!isShowVoice) {
|
self.setTimeout("searchAlm()",10000);
|
return;
|
}
|
// 请求后台查询最新出现的告警个数
|
$.post("Battalarm_dataAction!serchRealTime",null,function(data){
|
model=eval("("+data.result+")");
|
if(model.code==1){
|
$('#batt_alarm_num .num').text(model.sum);
|
if(totalAlm_num<model.sum){
|
var voiceStatus = checkPageVoiceStatus();
|
createEleWarning(model.sum-totalAlm_num, !voiceStatus);
|
}
|
totalAlm_num=model.sum;
|
|
// 5秒后关闭面板
|
setTimeout(function() {
|
$('body').children('#eleWarning').remove();
|
}, 5000);
|
|
self.setTimeout("searchAlm()",10000);
|
}
|
});
|
}
|
|
/*从多维数组中获取最大值*/
|
function getMaxFromArr(arr) {
|
var newArray = arr.join(",").split(",");
|
return Math.max.apply({},newArray);
|
}
|
|
/*从多维数组中获取最小值*/
|
function getMinFromArr (arr) {
|
var newArray = arr.join(",").split(",");
|
return Math.min.apply({},newArray);
|
}
|
|
//日历
|
/**
|
* Calendar
|
*
|
* @param beginYear
|
* 1990
|
* @param endYear
|
* 2010
|
* @param language
|
* 0(zh_cn)|1(en_us)|2(en_en)|3(zh_tw)
|
* @param patternDelimiter
|
* "-"
|
* @param date2StringPattern
|
* "yyyy-MM-dd"
|
* @param string2DatePattern
|
* "ymd"
|
* @version 1.0 build 2006-04-01
|
* @version 1.1 build 2006-12-17
|
* @author KimSoft (jinqinghua [at] gmail.com) NOTE! you can use it free, but
|
* keep the copyright please IMPORTANT:you must include this script file
|
* inner html body elment
|
*/
|
function Calendar(beginYear, endYear, language, patternDelimiter,
|
date2StringPattern, string2DatePattern) {
|
this.beginYear = beginYear || 1970;
|
this.endYear = endYear || 2100;
|
this.language = language || 0;
|
this.patternDelimiter = patternDelimiter || "-";
|
this.date2StringPattern = date2StringPattern
|
|| Calendar.language["date2StringPattern"][this.language].replace(
|
/\-/g, this.patternDelimiter);
|
this.string2DatePattern = string2DatePattern
|
|| Calendar.language["string2DatePattern"][this.language];
|
|
this.dateControl = null;
|
this.panel = this.getElementById("__calendarPanel");
|
this.iframe = window.frames["__calendarIframe"];
|
this.form = null;
|
|
this.date = new Date();
|
this.year = this.date.getFullYear();
|
this.month = this.date.getMonth();
|
|
this.colors = {
|
"bg_cur_day" : "#00CC33",
|
"bg_over" : "#EFEFEF",
|
"bg_out" : "#FFCC00"
|
};
|
};
|
|
Calendar.language = {
|
"year" : [ "\u5e74", "", "", "\u5e74" ],
|
"months" : [
|
[ "\u4e00\u6708", "\u4e8c\u6708", "\u4e09\u6708", "\u56db\u6708",
|
"\u4e94\u6708", "\u516d\u6708", "\u4e03\u6708",
|
"\u516b\u6708", "\u4e5d\u6708", "\u5341\u6708",
|
"\u5341\u4e00\u6708", "\u5341\u4e8c\u6708" ],
|
[ "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP",
|
"OCT", "NOV", "DEC" ],
|
[ "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP",
|
"OCT", "NOV", "DEC" ],
|
[ "\u4e00\u6708", "\u4e8c\u6708", "\u4e09\u6708", "\u56db\u6708",
|
"\u4e94\u6708", "\u516d\u6708", "\u4e03\u6708",
|
"\u516b\u6708", "\u4e5d\u6708", "\u5341\u6708",
|
"\u5341\u4e00\u6708", "\u5341\u4e8c\u6708" ] ],
|
"weeks" : [
|
[ "\u65e5", "\u4e00", "\u4e8c", "\u4e09", "\u56db", "\u4e94",
|
"\u516d" ],
|
[ "Sun", "Mon", "Tur", "Wed", "Thu", "Fri", "Sat" ],
|
[ "Sun", "Mon", "Tur", "Wed", "Thu", "Fri", "Sat" ],
|
[ "\u65e5", "\u4e00", "\u4e8c", "\u4e09", "\u56db", "\u4e94",
|
"\u516d" ] ],
|
"clear" : [ "\u6e05\u7a7a", "Clear", "Clear", "\u6e05\u7a7a" ],
|
"today" : [ "\u4eca\u5929", "Today", "Today", "\u4eca\u5929" ],
|
"close" : [ "\u5173\u95ed", "Close", "Close", "\u95dc\u9589" ],
|
"date2StringPattern" : [ "yyyy-MM-dd", "yyyy-MM-dd", "yyyy-MM-dd",
|
"yyyy-MM-dd" ],
|
"string2DatePattern" : [ "ymd", "ymd", "ymd", "ymd" ]
|
};
|
|
|
Calendar.prototype.draw = function() {
|
calendar = this;
|
|
var _cs = [];
|
_cs[_cs.length] = '<form id="__calendarForm" name="__calendarForm" method="post">';
|
_cs[_cs.length] = '<table id="__calendarTable" width="100%" border="0" cellpadding="3" cellspacing="1" align="center">';
|
_cs[_cs.length] = ' <tr>';
|
_cs[_cs.length] = ' <th><input class="l" name="goPrevMonthButton" type="button" id="goPrevMonthButton" value="<" \/><\/th>';
|
_cs[_cs.length] = ' <th colspan="5"><select class="year" name="yearSelect" id="yearSelect"><\/select><select class="month" name="monthSelect" id="monthSelect"><\/select><\/th>';
|
_cs[_cs.length] = ' <th><input class="r" name="goNextMonthButton" type="button" id="goNextMonthButton" value=">" \/><\/th>';
|
_cs[_cs.length] = ' <\/tr>';
|
_cs[_cs.length] = ' <tr>';
|
for ( var i = 0; i < 7; i++) {
|
_cs[_cs.length] = '<th class="theader">';
|
_cs[_cs.length] = Calendar.language["weeks"][this.language][i];
|
_cs[_cs.length] = '<\/th>';
|
}
|
_cs[_cs.length] = '<\/tr>';
|
for ( var i = 0; i < 6; i++) {
|
_cs[_cs.length] = '<tr align="center">';
|
for ( var j = 0; j < 7; j++) {
|
switch (j) {
|
case 0:
|
_cs[_cs.length] = '<td class="sun"> <\/td>';
|
break;
|
case 6:
|
_cs[_cs.length] = '<td class="sat"> <\/td>';
|
break;
|
default:
|
_cs[_cs.length] = '<td class="normal"> <\/td>';
|
break;
|
}
|
}
|
_cs[_cs.length] = '<\/tr>';
|
}
|
_cs[_cs.length] = ' <tr>';
|
_cs[_cs.length] = ' <th colspan="3"><input type="button" class="b" name="selectTodayButton" id="selectTodayButton" \/><\/th>';
|
_cs[_cs.length] = ' <th colspan="1"><input type="button" class="b" name="clearButton" id="clearButton" \/><\/th>';
|
_cs[_cs.length] = ' <th colspan="3"><input type="button" class="b" name="closeButton" id="closeButton" \/><\/th>';
|
_cs[_cs.length] = ' <\/tr>';
|
_cs[_cs.length] = '<\/table>';
|
_cs[_cs.length] = '<\/form>';
|
|
this.iframe.document.body.innerHTML = _cs.join("");
|
this.form = this.iframe.document.forms["__calendarForm"];
|
this.form.clearButton.style.visibility = "hidden";
|
this.form.clearButton.value = Calendar.language["clear"][this.language];
|
|
this.form.selectTodayButton.value = Calendar.language["today"][this.language];
|
this.form.closeButton.value = Calendar.language["close"][this.language];
|
|
this.form.goPrevMonthButton.onclick = function() {
|
calendar.goPrevMonth(this);
|
};
|
this.form.goNextMonthButton.onclick = function() {
|
calendar.goNextMonth(this);
|
};
|
this.form.yearSelect.onchange = function() {
|
calendar.update(this);
|
};
|
this.form.monthSelect.onchange = function() {
|
calendar.update(this);
|
};
|
|
this.form.clearButton.onclick = function() {
|
calendar.dateControl.value = "";
|
calendar.hide();
|
};
|
this.form.closeButton.onclick = function() {
|
calendar.hide();
|
};
|
this.form.selectTodayButton.onclick = function() {
|
var today = new Date();
|
calendar.date = today;
|
calendar.year = today.getFullYear();
|
calendar.month = today.getMonth();
|
calendar.dateControl.value = today.format(calendar.date2StringPattern);
|
calendar.hide();
|
};
|
};
|
|
Calendar.prototype.bindYear = function() {
|
var ys = this.form.yearSelect;
|
ys.length = 0;
|
for ( var i = this.beginYear; i <= this.endYear; i++) {
|
ys.options[ys.length] = new Option(i
|
+ Calendar.language["year"][this.language], i);
|
}
|
};
|
|
Calendar.prototype.bindMonth = function() {
|
var ms = this.form.monthSelect;
|
ms.length = 0;
|
for ( var i = 0; i < 12; i++) {
|
ms.options[ms.length] = new Option(
|
Calendar.language["months"][this.language][i], i);
|
}
|
};
|
|
Calendar.prototype.goPrevMonth = function(e) {
|
if (this.year == this.beginYear && this.month == 0) {
|
return;
|
}
|
this.month--;
|
if (this.month == -1) {
|
this.year--;
|
this.month = 11;
|
}
|
this.date = new Date(this.year, this.month, 1);
|
this.changeSelect();
|
this.bindData();
|
};
|
|
Calendar.prototype.goNextMonth = function(e) {
|
if (this.year == this.endYear && this.month == 11) {
|
return;
|
}
|
this.month++;
|
if (this.month == 12) {
|
this.year++;
|
this.month = 0;
|
}
|
this.date = new Date(this.year, this.month, 1);
|
this.changeSelect();
|
this.bindData();
|
};
|
|
Calendar.prototype.changeSelect = function() {
|
var ys = this.form.yearSelect;
|
var ms = this.form.monthSelect;
|
for ( var i = 0; i < ys.length; i++) {
|
if (ys.options[i].value == this.date.getFullYear()) {
|
ys[i].selected = true;
|
break;
|
}
|
}
|
for ( var i = 0; i < ms.length; i++) {
|
if (ms.options[i].value == this.date.getMonth()) {
|
ms[i].selected = true;
|
break;
|
}
|
}
|
};
|
|
Calendar.prototype.update = function(e) {
|
this.year = e.form.yearSelect.options[e.form.yearSelect.selectedIndex].value;
|
this.month = e.form.monthSelect.options[e.form.monthSelect.selectedIndex].value;
|
this.date = new Date(this.year, this.month, 1);
|
this.changeSelect();
|
this.bindData();
|
};
|
|
Calendar.prototype.bindData = function() {
|
var calendar = this;
|
var dateArray = this.getMonthViewDateArray(this.date.getFullYear(),
|
this.date.getMonth());
|
var tds = this.getElementsByTagName("td", this.getElementById(
|
"__calendarTable", this.iframe.document));
|
for ( var i = 0; i < tds.length; i++) {
|
tds[i].style.backgroundColor = calendar.colors["bg_over"];
|
tds[i].onclick = null;
|
tds[i].onmouseover = null;
|
tds[i].onmouseout = null;
|
tds[i].innerHTML = dateArray[i] || " ";
|
if (i > dateArray.length - 1)
|
continue;
|
if (dateArray[i]) {
|
tds[i].onclick = function() {
|
if (calendar.dateControl) {
|
calendar.dateControl.value = new Date(calendar.date
|
.getFullYear(), calendar.date.getMonth(),
|
this.innerHTML).format(calendar.date2StringPattern);
|
}
|
calendar.hide();
|
};
|
tds[i].onmouseover = function() {
|
this.style.backgroundColor = calendar.colors["bg_out"];
|
};
|
tds[i].onmouseout = function() {
|
this.style.backgroundColor = calendar.colors["bg_over"];
|
};
|
var today = new Date();
|
if (today.getFullYear() == calendar.date.getFullYear()) {
|
if (today.getMonth() == calendar.date.getMonth()) {
|
if (today.getDate() == dateArray[i]) {
|
tds[i].style.backgroundColor = calendar.colors["bg_cur_day"];
|
tds[i].onmouseover = function() {
|
this.style.backgroundColor = calendar.colors["bg_out"];
|
};
|
tds[i].onmouseout = function() {
|
this.style.backgroundColor = calendar.colors["bg_cur_day"];
|
};
|
}
|
}
|
}
|
}// end if
|
}// end for
|
};
|
|
Calendar.prototype.getMonthViewDateArray = function(y, m) {
|
var dateArray = new Array(42);
|
var dayOfFirstDate = new Date(y, m, 1).getDay();
|
var dateCountOfMonth = new Date(y, m + 1, 0).getDate();
|
for ( var i = 0; i < dateCountOfMonth; i++) {
|
dateArray[i + dayOfFirstDate] = i + 1;
|
}
|
return dateArray;
|
};
|
|
Calendar.prototype.show = function(dateControl, popuControl) {
|
if (this.panel.style.visibility == "visible") {
|
this.panel.style.visibility = "hidden";
|
}
|
if (!dateControl) {
|
throw new Error("arguments[0] is necessary!");
|
}
|
this.dateControl = dateControl;
|
popuControl = popuControl || dateControl;
|
|
this.draw();
|
this.bindYear();
|
this.bindMonth();
|
if (dateControl.value.length > 0) {
|
this.date = new Date(dateControl.value.toDate(this.patternDelimiter,
|
this.string2DatePattern));
|
this.year = this.date.getFullYear();
|
this.month = this.date.getMonth();
|
}
|
this.changeSelect();
|
this.bindData();
|
|
var xy = this.getAbsPoint(popuControl);
|
this.panel.style.left = xy.x + "px";
|
this.panel.style.top = (xy.y + dateControl.offsetHeight) + "px";
|
this.panel.style.visibility = "visible";
|
|
};
|
|
Calendar.prototype.hide = function() {
|
//console.info($("#__calendarPanel input").is('focus'));
|
this.panel.style.visibility = "hidden";
|
this.panel.style.top = '-9999px';
|
};
|
|
Calendar.prototype.getElementById = function(id, object) {
|
object = object || document;
|
return document.getElementById ? object.getElementById(id) : document
|
.all(id);
|
};
|
|
Calendar.prototype.getElementsByTagName = function(tagName, object) {
|
object = object || document;
|
return document.getElementsByTagName ? object.getElementsByTagName(tagName)
|
: document.all.tags(tagName);
|
};
|
|
Calendar.prototype.getAbsPoint = function(e) {
|
|
// var x = e.offsetLeft;
|
// var y = e.offsetTop;
|
// while (e = e.offsetParent) {
|
// x += e.offsetLeft;
|
// y += e.offsetTop;
|
// }
|
var yScroll;
|
if (self.pageYOffset) {
|
yScroll = self.pageYOffset;
|
} else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
|
yScroll = document.documentElement.scrollTop;
|
} else if (document.body) {// all other Explorers
|
yScroll = document.body.scrollTop;
|
}
|
var x,y;
|
oRect = e.getBoundingClientRect();
|
x=oRect.left;
|
y=oRect.top;
|
return {
|
"x" : x,
|
"y" : (y+yScroll)
|
};
|
};
|
|
/**
|
* @param d
|
* the delimiter
|
* @param p
|
* the pattern of your date
|
* @author meizz
|
* @author kimsoft add w+ pattern
|
*/
|
Date.prototype.format = function(style) {
|
var o = {
|
"M+" : this.getMonth() + 1, // month
|
"d+" : this.getDate(), // day
|
"h+" : this.getHours(), // hour
|
"m+" : this.getMinutes(), // minute
|
"s+" : this.getSeconds(), // second
|
"w+" : "\u65e5\u4e00\u4e8c\u4e09\u56db\u4e94\u516d".charAt(this
|
.getDay()), // week
|
"q+" : Math.floor((this.getMonth() + 3) / 3), // quarter
|
"S" : this.getMilliseconds()
|
// millisecond
|
};
|
if (/(y+)/.test(style)) {
|
style = style.replace(RegExp.$1, (this.getFullYear() + "")
|
.substr(4 - RegExp.$1.length));
|
}
|
for ( var k in o) {
|
if (new RegExp("(" + k + ")").test(style)) {
|
style = style.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]
|
: ("00" + o[k]).substr(("" + o[k]).length));
|
}
|
}
|
return style;
|
};
|
|
/**
|
* @param d
|
* the delimiter
|
* @param p
|
* the pattern of your date
|
* @rebuilder kimsoft
|
* @version build 2006.12.15
|
*/
|
String.prototype.toDate = function(delimiter, pattern) {
|
delimiter = delimiter || "-";
|
pattern = pattern || "ymd";
|
var a = this.split(delimiter);
|
var y = parseInt(a[pattern.indexOf("y")], 10);
|
// remember to change this next century ;)
|
if (y.toString().length <= 2)
|
y += 2000;
|
if (isNaN(y))
|
y = new Date().getFullYear();
|
var m = parseInt(a[pattern.indexOf("m")], 10) - 1;
|
var d = parseInt(a[pattern.indexOf("d")], 10);
|
if (isNaN(d))
|
d = 1;
|
return new Date(y, m, d);
|
};
|
|
document
|
.writeln('<div id="__calendarPanel" style="position:absolute;visibility:hidden;z-index:99999999;background-color:#FFFFFF;border:1px solid #666666;width:200px;height:216px;top:-999px;">');
|
document
|
.writeln('<iframe name="__calendarIframe" id="__calendarIframe" width="100%" height="100%" scrolling="no" frameborder="0" style="margin:0px;"><\/iframe>');
|
var __ci = window.frames['__calendarIframe'];
|
__ci.document
|
.writeln('<!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd">');
|
__ci.document.writeln('<html xmlns="http:\/\/www.w3.org\/1999\/xhtml">');
|
__ci.document.writeln('<head>');
|
__ci.document
|
.writeln('<meta http-equiv="Content-Type" content="text\/html; charset=utf-8" \/>');
|
__ci.document.writeln('<title>Web Calendar(UTF-8) Written By KimSoft<\/title>');
|
__ci.document.writeln('<style type="text\/css">');
|
__ci.document.writeln('<!--');
|
__ci.document.writeln('body {font-size:12px;margin:0px;text-align:center;}');
|
__ci.document.writeln('form {margin:0px;}');
|
__ci.document.writeln('select {font-size:12px;background-color:#EFEFEF;}');
|
__ci.document
|
.writeln('table {border:0px solid #CCCCCC;background-color:#FFFFFF}');
|
__ci.document
|
.writeln('th {font-size:12px;font-weight:normal;background-color:#FFFFFF;}');
|
__ci.document
|
.writeln('th.theader {font-weight:normal;background-color:#666666;color:#FFFFFF;width:24px;}');
|
__ci.document.writeln('select.year {width:64px;}');
|
__ci.document.writeln('select.month {width:60px;}');
|
__ci.document.writeln('td {font-size:12px;text-align:center;}');
|
__ci.document.writeln('td.sat {color:#0000FF;background-color:#EFEFEF;}');
|
__ci.document.writeln('td.sun {color:#FF0000;background-color:#EFEFEF;}');
|
__ci.document.writeln('td.normal {background-color:#EFEFEF;}');
|
__ci.document
|
.writeln('input.l {border: 1px solid #CCCCCC;background-color:#EFEFEF;width:20px;height:20px;}');
|
__ci.document
|
.writeln('input.r {border: 1px solid #CCCCCC;background-color:#EFEFEF;width:20px;height:20px;}');
|
__ci.document
|
.writeln('input.b {border: 1px solid #CCCCCC;background-color:#EFEFEF;width:100%;height:20px;}');
|
__ci.document.writeln('-->');
|
__ci.document.writeln('<\/style>');
|
__ci.document.writeln('<\/head>');
|
__ci.document.writeln('<body>');
|
__ci.document.writeln('<\/body>');
|
__ci.document.writeln('<\/html>');
|
__ci.document.close();
|
document.writeln('<\/div>');
|
var calendar = new Calendar();
|
// -->
|
|
// 设置日历位置
|
function showCalendar(param) {
|
new Calendar().show(param);
|
var winWidth = $(window).width();
|
|
var offsetLeft = $('#__calendarPanel').offset().left;
|
var calendarWidth = $('#__calendarPanel').width();
|
|
var fullWidth = offsetLeft + calendarWidth;
|
|
if(fullWidth > winWidth) {
|
$('#__calendarPanel').css('left', winWidth - 205+"px");
|
}
|
}
|
|
|
// 正则验证英文名称
|
function pregEnName(enName) {
|
if(enName == undefined || enName.trim().length == 0) {
|
return '不能为空';
|
}
|
var pattern = /^[a-zA-Z0-9]+$/i;
|
if(pattern.test(enName)) {
|
return '输入合法';
|
}else {
|
return '格式不正确';
|
}
|
}
|
|
// 正则验证密码
|
function pregPwd(pwd) {
|
if(pwd == undefined || pwd.trim().length == 0) {
|
return '不能为空';
|
}
|
var pattern = /^[a-zA-Z0-9!@#$%^&*?.]+$/;
|
if(pattern.test(pwd)) {
|
return '输入合法';
|
}else {
|
return '格式不正确';
|
}
|
}
|
|
/*****************常用判断数据类型*****************/
|
|
//是否为数字
|
function isNumber(s) {
|
return !isNaN(s);
|
}
|
|
// 是否为字符串
|
function isString(s) {
|
return typeof s === 'string';
|
}
|
|
// 是否为布尔类型
|
function isBoolean(s) {
|
return typeof s === 'boolean';
|
}
|
|
// 判断是否为函数
|
function isFunction(s) {
|
return typeof s === 'function';
|
}
|
// 判断是否为空
|
function isNull(s) {
|
return typeof s === 'null';
|
}
|
|
// 判断是否为未定义
|
function isUndefined(s) {
|
return typeof s === 'undefined';
|
}
|
|
// 判断是否为数组
|
function isArray(s) {
|
return s instanceof Array;
|
}
|
|
// 判断是否为对象
|
function isObject(s) {
|
return (typeof s === 'object' && !isArray(s));
|
}
|
|
//使用XMLHttpRequest的方式获取模板页
|
function getTpl(url) {
|
var xmlhttp; // 实例化XMLHttpRequest对象
|
if(window.XMLHttpRequest) {
|
xmlhttp = new XMLHttpRequest();
|
}else {
|
xmlhttp = new ActiveXObject('Mocrosoft.XMLHTTP');
|
}
|
|
// 设置请求
|
xmlhttp.open('GET', url, false);
|
|
// 发送请求
|
xmlhttp.send();
|
|
var tpl;
|
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
tpl = xmlhttp.responseText;
|
}else {
|
tpl = "";
|
}
|
|
return tpl;
|
}
|