📄 utility.js
字号:
}
return re;
}
//传回国历 y年某m+1月的天数
function solarDays(y,m) {
var solarMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
if(m==1)
return(((y%4 == 0) && (y%100 != 0) || (y%400 == 0))? 29: 28)
else
return(solarMonth[m])
}
function NextPage(objSelf,url,func)
{
this.obj=objSelf;
this.url=url;
this.func=func;
}
NextPage.prototype.AllPage=0;//总页数
NextPage.prototype.CurrPage=0;//当前页码
NextPage.prototype.PageSize=15;//单页数
NextPage.prototype.begin=function(pIndex,data)
{
if(data)
{
this.data=data;
this.data+='&PageSize='+this.PageSize;
this.data+='&allCount=1';
}
switch(pIndex)
{
case -1://最后一页
pIndex=this.AllPage;
break;
case -2://上一页
pIndex=this.CurrPage-1;
break;
case -3://下一页
pIndex=this.CurrPage+1;
break;
case undefined://空值回到首页
pIndex=this.CurrPage;
break;
}
if(pIndex<1 || (pIndex>this.AllPage && this.AllPage>0))return;//防止翻页翻过头
this.CurrPage=pIndex;//设置当前页
var d=this.data+'&PageIndex='+ pIndex;
Msg.Show(' <img src="../system/loading.gif" align="absmiddle" />正在获取数据中');
xmlHttp=CreateXmlHttp("POST",this.url,true);
xmlHttp.setRequestHeader("Content-Length",d.length);
xmlHttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
obj=this;
xmlHttp.onreadystatechange = function(){obj.end(obj);};
xmlHttp.send(d);
}
NextPage.prototype.end=function(o)
{
if(xmlHttp.readyState!=4)return;
var re=xmlHttp.status;
switch(re)
{
case 711:
parent.OpenWin.Login();
Msg.Close();
return;
case 712:
Msg.timeClose(xmlHttp.responseText,3);
return;
}
var node=xmlHttp.responseXML;
if(node.getElementsByTagName("Total")[0])
o.AllPage=Math.ceil(node.getElementsByTagName("Total")[0].childNodes[0].data/o.PageSize);
var getValue=function(id,i)
{
return (node.getElementsByTagName(id)[i].childNodes[0]) ? node.getElementsByTagName(id)[i].childNodes[0].data :'无';
}
var re=/£/ig ;
re.multiline = true;
eval(this.func);
var iner='';
for(var i=1;i<=o.AllPage;i++)
iner+='<a href="#" '+(o.CurrPage==i ? 'style="font-weight:bold"' : '')+' onclick="'+o.obj+'.begin('+i+');">'+i+'</a> ';
document.getElementById('Onces_'+o.id).innerHTML=iner;
Msg.Close();
}
NextPage.prototype.Link=function(id)
{
this.id=id;
return '<a href="#" onclick="'+this.obj+'.begin(1);">首页</a> <a href="#" onclick="'+this.obj+'.begin(-2);">上一页</a> <span id="Onces_'+id+'"></span> <a href="#" onclick="'+this.obj+'.begin(-3);">下一页</a> <a href="#" onclick="'+this.obj+'.begin(-1);">尾页</a>';
}
function setTitle(v,a)
{
if(a!=null)v=document.title +a;
document.title =v;
//document.getElementById('ContentTitle').innerHTML=v;
}
/*键盘监听
KeyBoard.AddEventListener("x",function(){alert('test');},{altKey:true});
KeyBoard.BeginListener();
*/
var KeyBoard={
ListenerCollection:new Object(),
AddEventListener:function(keyCode,fun,ctrlKeyState){
if(typeof(keyCode)=="number")keyCode=String.fromCharCode(keyCode).toUpperCase();
else keyCode=keyCode.toUpperCase();
this.ListenerCollection["f"+keyCode]=fun;
this.ListenerCollection["c"+keyCode]=ctrlKeyState;
},
RemoveEventListener:function(keyCode){
if(this.ListenerCollection["f"+keyCode])delete this.ListenerCollection["f"+keyCode];
if(this.ListenerCollection["c"+keyCode])delete this.ListenerCollection["c"+keyCode];
},
KeyCheck:function(){
if(!IsIE())event=SearchEvent();
var kCode=String.fromCharCode(IsIE()?event.keyCode:event.which).toUpperCase();
if(KeyBoard.ListenerCollection["f"+kCode]){
var keyState=KeyBoard.ListenerCollection["c"+kCode];
if(keyState){
if(keyState.ctrlKey)if(!event.ctrlKey)return false;
if(keyState.shiftKey)if(!event.shiftKey)return false;
if(keyState.altKey)if(!event.altKey)return false;
}
try{KeyBoard.ListenerCollection["f"+kCode]();}catch(ex){throw("Delegate Method Fail");}
}
},
BeginListener:function(){
AddEventListener(document,"onkeydown",this.KeyCheck);
},
EndListener:function(){
RemoveEventListener(document,"onkeydown",this.KeyCheck);
}
}
///////////////end键盘事件
//处理PNG透明问题
function correctPNG()
{
for(var i=0; i<document.images.length; i++)
{
var img = document.images[i]
var LW=img.width
var LH=img.height
var imgName = img.src.toUpperCase()
if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
{
img.style.filter+="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+img.src+", sizingmethod=scale);"
img.src="transparent.gif"
img.width=LW
img.height=LH
}
}
}
var xmlHttp;
function executPost(data,page,yb,ybFun)
{
if(yb==null)yb=false;
xmlHttp=CreateXmlHttp("POST",page,yb);
xmlHttp.setRequestHeader("Content-Length",data.length);
xmlHttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
if(yb)
{
xmlHttp.onreadystatechange = eval(ybFun);
xmlHttp.send(data);
return;
}else
xmlHttp.send(data);
return xmlHttp;
}
var Msg=
{
Info:'',
isMsg:false,
Func:null,
Show:function(msg,n)
{
var z=createElement("div",{'id':'MsgBu','class':'MsgBu'});
z.style.width=document.documentElement.clientWidth+'px';
z.style.height=document.documentElement.scrollHeight+'px';
document.body.appendChild(z);
var b=createElement("div",{'id':'MsgWin','class':'MsgWin'},null,msg);
b.style.left=Math.floor((document.documentElement.offsetWidth-250)/2)+'px';
b.style.top=Math.floor(document.documentElement.clientHeight/2-60+document.documentElement.scrollTop)+'px';
this.Func=null;
document.body.appendChild(b);
this.Info=msg;
this.isMsg=true;
if(n)setTimeout('Msg.Close();',1000*n);
},
reShow:function()
{
if(!Msg.isMsg)return;
Msg.Close();
Msg.Show(Msg.Info);
},
upShow:function(newInfo)
{
document.getElementById('MsgWin').innerHTML=newInfo;
},
timeClose:function(newInfo,n)
{
if(newInfo)document.getElementById('MsgWin').innerHTML=newInfo;
if(!n)n=2;
setTimeout('Msg.Close();',1000*n);
},
Close:function()
{
document.body.removeChild(document.getElementById('MsgBu'));
document.body.removeChild(document.getElementById('MsgWin'));
this.isMsg=false;
this.Info='';
eval(this.Func);
}
}
var Opt=
{
Info:'',
isMsg:false,
Show:function(msg,w,h)
{
if(this.isMsg)return;
var z=createElement("div",{'id':'OptWin','class':'MsgBu'});
z.style.width=document.documentElement.clientWidth+'px';
z.style.height=document.documentElement.scrollHeight+'px';
document.body.appendChild(z);
var b=createElement("div",{'id':'OptWin1','class':'OptWin'},null,msg);
b.style.left=Math.floor((document.documentElement.clientWidth-w)/2)-15+'px';
b.style.top=Math.floor(document.documentElement.clientHeight-h)/2.3+'px';
b.style.width=w+'px';
b.style.height=h+'px';
document.body.appendChild(b);
this.Info=msg;
this.isMsg=true;
},
Close:function()
{
document.body.removeChild(document.getElementById('OptWin'));
document.body.removeChild(document.getElementById('OptWin1'));
this.isMsg=false;
this.Info='';
}
}
//居中的窗口
function Open(src,w,h){
var t = (window.screen.availHeight-30-h)/2;
var l = (window.screen.availWidth-10-w)/2;
var win= window.open(src,'','location=no,height='+h+',width='+w+',top='+t+',left='+l+',model=yes,scrollbars=yes');
return win;
}
//给FIREFOX加window.event
function __firefox(){
HTMLElement.prototype.__defineGetter__("runtimeStyle", __element_style);
window.constructor.prototype.__defineGetter__("event", __window_event);
Event.prototype.__defineGetter__("srcElement", __event_srcElement);
}
function __element_style(){
return(this.style);
}
function __window_event(){
return(__window_event_constructor());
}
function __event_srcElement(){
return this.target;
}
function __window_event_constructor(){
if(document.all)
return(window.event);
var _caller=__window_event_constructor.caller;
while(_caller!=null){
var _argument=_caller.arguments[0];
if(_argument){
var _temp=_argument.constructor;
if(_temp.toString().indexOf("Event")!=-1)
return(_argument);
}
_caller=_caller.caller;
}
return(null);
}
if(window.addEventListener){
__firefox();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -