📄 liveframework.js
字号:
o.page=objPage;}
if(objState==_ss.Complete||objState==_ss.Timeout)
{delete arrStream[o.streamIndex];if(o.batchTimeout)
{o.page=null;clearTimeout(o.batchTimeout)
}
if(o.context.batchData&&o.callback)
{o.callback(objPage,o.context);}
o.context.state=objState;Finished(objPage,o);el.removeNode(true);el=null;}
else if(objState==_ss.BatchUpdate)
{if(o.callback)
o.callback(objPage,o.context);}
else
{if(o.context.batchTimer||o.context.batchCount)
{if(objState==_ss.Flush)
{DoBatch();}
else
{if(!o.context.batchData)o.context.batchData=[];if(objRoot)
o.context.batchData.push(objRoot);if(o.context.batchCount&&(o.context.batchData.length==o.context.batchCount))
{DoBatch();}
}
}
else
if(o.callback)
o.callback(objPage,o.context)
}
}
return el;}
function FetchXML(o,method)
{var xml=new XMLHttpRequest();objNetwork.oninvoke.fire(o);if(method)
{xml.open("POST",o.url,true);if(blnIsIE)
{xml.setRequestHeader("Accept-Encoding","gzip, deflate");}
}
else
{xml.open("GET",o.url,true);}
if(o.headers)
{for(var h in o.headers)
{xml.setRequestHeader(h,o.headers[h]);}
}
xml.onreadystatechange=doXMLCallback;if(o.timeout)
o.timer=setTimeout(TimedOut,o.timeout);try
{if(o.postString||_isMoz)
xml.send(o.postString);else
xml.send();}
catch(ex)
{objNetwork.onhttperror.fire(xml);if(o&&o.timer)
clearTimeout(o.timer);doXMLCallback(true);}
function doXMLCallback(p_blnForce)
{if(xml&&(p_blnForce||4==xml.readyState))
{xml.onreadystatechange=Function.emptyFunction;if(o&&o.timer)
clearTimeout(o.timer);Finished(xml,o);xml=o=null;}
}
function TimedOut()
{if(o)
{try
{xml.onreadystatechange=Function.emptyFunction;xml.abort();}
catch(ex){};{Finished(null,o);}
}
xml=o=null;}
return xml;}
var _ma=__Web_Network.MAXACTIVE;function Continue()
{var o;if(intActive<_ma&&(!blnProxy||(blnProxy&&objProxy)))
{if(!boolSerRequest)
{o=objSerializer.dequeue();if(o)boolSerRequest=true;}
if(!o)
{o=objParallel.dequeue();}
if(o)
{intActive++;var _wnt=__Web_Network.Type;switch(o.type)
{case _wnt.XMLGet:
case _wnt.XML:
case _wnt.XMLPost:
if(blnProxy&&o.proxy)
o.executing=objProxy.fetchXML(o,objNetwork,m_objRuntime,Finished);else
{o.executing=FetchXML(o,__Web_Network.Type.XMLPost==o.type);}
break;case _wnt.Image:
o.executing=FetchImage(o);break;case _wnt.Script:
o.executing=FetchScript(o);break;case _wnt.CSS:
o.executing=FetchCSS(o);break;case _wnt.Stream:
o.executing=FetchStream(o);break;default:
intActive--;}
}
}
}
function Finished(el,obj)
{var bRetry=false;var boolNotify=obj.flags&__Web_Network.Flags.NOTIFY;if(_isMoz)
{switch(obj.type)
{case __Web_Network.Type.XMLGet:
case __Web_Network.Type.XML:
case __Web_Network.Type.XMLPost:
el=Web.Browser._Private.cleanupFirefox(el,obj);break;}
}
if(obj.flags&__Web_Network.Flags.SERIALIZE)
{boolSerRequest=false;}
intActive--;var objKey=objList[obj.key];if(objKey)
{var objItem=objKey.pop();while(objItem)
{if(objItem.callback)
{if(!_dbg)
{try
{objItem.callback(el,objItem.context);}
catch(ex)
{}
}
else
objItem.callback(el,objItem.context);}
boolNotify=boolNotify||(objItem.flags&__Web_Network.Flags.NOTIFY);bRetry=bRetry||(objItem.context&&objItem.context.bRetry);if(!bRetry)
{objItem=objItem.callback=objItem.context=objItem.executing=null;}
objItem=objKey.pop();}
delete objList[obj.key];}
obj.executing=el=null;if(bRetry==true)
{m_this.add(obj);}
else
{obj.pool=null;}
obj=null;if(boolNotify)
Web.Accessibility.notify();Continue();}
function IndexInList(objCheck)
{var boolMatch=false,intIndex=0,objCheckList=objList[objCheck.key];if(objCheckList)
{var iCount=objCheckList.length;while(!boolMatch&&objCheckList&&intIndex<iCount)
{var objItem=objCheckList[intIndex];boolMatch=objItem&&(objItem.callback==objCheck.callback);if(!boolMatch)
intIndex++;}
}
return((boolMatch)?intIndex:-1);}
function AbortRequest(objMatch)
{objMatch.callback=null;if(objMatch.executing)
{if(objMatch.flags&__Web_Network.Flags.SERIALIZE)
{boolSerRequest=false;}
objNetwork.onabort.fire(objMatch);if(objMatch.timer)
clearTimeout(objMatch.timer);switch(objMatch.type)
{case __Web_Network.Type.XML:
case __Web_Network.Type.XMLPost:
case __Web_Network.Type.XMLGet:
objMatch.executing.onreadystatechange=Function.emptyFunction;objMatch.executing.abort();break;case __Web_Network.Type.Image:
case __Web_Network.Type.Script:
case __Web_Network.Type.CSS:
objMatch.onerror=objMatch.onload=objMatch.onreadystatechange=objMatch.onabort=null;try
{objMatch.executing.removeAttribute("src");objMatch.executing.href="";}
catch(ex){}
break;case __Web_Network.Type.Stream:
objMatch.executing.removeNode(true);objMatch.executing=null;if(objMatch.context.batchTimeout)
clearTimeout(batchTimeout)
delete arrStream[objMatch.streamIndex];break;}
if(objMatch.timer)
clearTimeout(objMatch.timer);intActive--;}
objMatch.context=objMatch.executing=null;}
this.generateProxy=function()
{if(!blnRegister)
objNetwork.RegisterBaseDomain();var bGenerateProxy=false;if(!blnProxy&&p_strDomain.endsWith(document.domain))
{bGenerateProxy=true;}
else if(p_strDomain.indexOf(":")>0)
{if(p_strDomain.substring(0,p_strDomain.indexOf(":")).endsWith(document.domain))
{bGenerateProxy=true;}
}
if(bGenerateProxy)
{blnProxy=true;elProxy=_ce("iframe");elProxy.style.display="none";elProxy.src=location.protocol+"//"+p_strDomain+"/xmlProxy.htm?vn="+RuntimeVersion+"&domain="+document.domain;document.body.insertAdjacentElement("afterBegin",elProxy);}
}
this._assignProxy=function(w)
{objProxy=w;Continue();}
this.abort=function(obj)
{function Remove(obj)
{var objItem;if(objList[obj.key])
{var intIndex=IndexInList(obj);if(intIndex>-1)
objItem=objList[obj.key].splice(intIndex,1)[0];}
return objItem;}
var objMatch=Remove(obj);while(objMatch!=null)
{AbortRequest(objMatch);objMatch=Remove(obj);}
if(objList[obj.key]&&objList[obj.key].length==0)
delete objList[obj.key];Continue();}
function AbortObjectKey(p_objList,p_strKey)
{var o=p_objList[p_strKey];if(o)
{var objItem=o.pop();while(objItem)
{AbortRequest(objItem);objItem=o.pop();}
}
delete p_objList[p_strKey];}
this.abortGroup=function(p_strGroup)
{var objFound=objParallel.findByProperty("strGroup",p_strGroup);while(objFound)
{objParallel.removeItem(objFound);objFound=objParallel.findByProperty("strGroup",p_strGroup);}
objFound=objSerializer.findByProperty("strGroup",p_strGroup);while(objFound)
{objSerializer.removeItem(objFound);objFound=objSerializer.findByProperty("strGroup",p_strGroup);}
for(var key in objList)
{var blnAbort=false,intItem=0;while(intItem<objList[key].length&&!blnAbort)
{if(objList[key][intItem].strGroup==p_strGroup)
{blnAbort=true;break;}
intItem++;}
if(blnAbort)
{AbortObjectKey(objList,key);}
}
}
this.abortAll=function(p_boolRestart)
{if(p_boolRestart)
{objParallel.clear();objSerializer.clear();blnProxy=false;try
{if(elProxy&&elProxy.removeNode)
elProxy.removeNode(true);}
catch(ex){}
objProxy=elProxy=null;}
for(var strKey in objList)
{AbortObjectKey(objList,strKey);}
objList={};}
this.add=function(obj)
{var boolQueue=false,_typ=obj.type,_wnt=__Web_Network.Type;if(objList[obj.key])
{var intIndex=IndexInList(obj);boolQueue=(intIndex==-1);}
else
{objList[obj.key]=[];boolQueue=true;var objStack=(obj.flags&__Web_Network.Flags.SERIALIZE)?objSerializer:objParallel;if(_typ==_wnt.XML||_typ==_wnt.XMLGet||_typ==_wnt.XMLPost||_typ==_wnt.Stream)
{objStack.push(obj,obj.priority);}
else
{objStack.queue(obj,obj.priority);}
}
if(boolQueue)
{objList[obj.key].push(obj);Continue();}
}
}
function Request(p_enumNetworkType,p_strUrl,p_objContext,p_fnCallback,p_enumPriority,p_postString,p_objHeaders,p_enumFlags,p_intTimeout,p_strTag,p_blnProxy,p_objAuth)
{this.type=p_enumNetworkType;var strSource=this.url=__Web_Utility.resolveUrl(p_strUrl);this.context=p_objContext;this.callback=p_fnCallback;this.priority=p_enumPriority;this.postString=p_postString;this.strGroup=p_strTag;this.domain=__Web_Utility.extractHost(this.url,false);this.proxy=!!p_blnProxy&&(this.domain!=strCurrentDomain);this.auth=p_objAuth;var strList="";for(var h in p_objHeaders)
{strList+=h+":"+p_objHeaders[h];}
this.strHeaders=strList;this.key=this.url+"?"+(this.postString||"")+"!"+strList;if((p_enumFlags&__Web_Network.Flags.DUPLICATE)||p_enumNetworkType==Web.Network.Type.Stream)
{this.key+="!"+(Request.DupCounter++);}
this.headers=p_objHeaders;this.flags=p_enumFlags;this.executing=null;this.timeout=p_intTimeout;objNetwork.onrequest.fire(this);if(strSource!=this.url)
{this.url=__Web_Utility.resolveUrl(this.url);this.domain=__Web_Utility.extractHost(this.url,false);}
if(this.domain=="")this.domain="local";if(!objDomains[this.domain])
{objDomains[this.domain]=new RunList(this.domain);}
if(this.proxy)
{objDomains[this.domain].generateProxy();}
}
Request.DupCounter=0;this.abortAll=function(p_blnUnload)
{for(var rl in objDomains)
{objDomains[rl].abortAll(p_blnUnload);}
}
this.abortGroup=function(p_strTag)
{for(var strDomain in objDomains)
{objDomains[strDomain].abortGroup(p_strTag);}
}
this.createRequest=function(p_enumNetworkType,p_strUrl,p_objContext,p_fnCallback,p_enumPriority,p_strPostArgs,p_objHeaders,p_enumFlags,p_intTimeout,p_strTag,p_blnProxy,p_objAuth)
{var objRequest={},boolExecuting=false,objPrivRequest=new Request(p_enumNetworkType,p_strUrl,p_objContext,p_fnCallback,p_enumPriority,p_strPostArgs,p_objHeaders,p_enumFlags,p_intTimeout,p_strTag,p_blnProxy,p_objAuth);function DoAuth(p_blnAuth)
{if(p_objAuth.isAuthenticated())
objDomains[objPrivRequest.domain].add(objPrivRequest);else
throw new Error("Authentication Failure");}
objRequest.execute=function()
{if(!boolExecuting)
{if(!p_objAuth||p_objAuth.isAuthenticated())
{objDomains[objPrivRequest.domain].add(objPrivRequest);boolExecuting=true;}
else
{p_objAuth.onauthenticate.attach(DoAuth);p_objAuth.authenticate();}
}
}
objRequest.isExecuting=function()
{return boolExecuting;}
objRequest.abort=function()
{objDomains[objPrivRequest.domain].abort(objPrivRequest);boolExecuting=false;}
return objRequest;}
this.createBatch=function(p_enumPriority,p_objContext)
{var objBatch={},arrBatch=[],fnCallback,boolExecuting=false,boolLockSection=false,intReceiveCount=0;function CheckComplete()
{if(!boolLockSection&&arrBatch.length==intReceiveCount)
{if(fnCallback)
fnCallback(arrBatch,p_objContext);intReceiveCount=0;boolExecuting=false;}
}
objBatch.add=function(p_enumNetworkType,p_strUrl,p_objContext,p_strPostArgs,p_objHeaders,p_enumFlags,p_blnProxy)
{var iCount=arrBatch.length;if(!p_objContext)
p_objContext={_counter:iCount};else
{if(!(p_objContext instanceof Object))
{p_objContext=new p_objContext.constructor(p_objContext);}
p_objContext._counter=iCount;}
arrBatch.push(objNetwork.createRequest(p_enumNetworkType,p_strUrl,p_objContext,BatchItemReceived,p_enumPriority,p_strPostArgs,p_objHeaders,p_enumFlags,null,null,p_blnProxy));arrBatch[iCount].type=p_enumNetworkType;arrBatch[iCount].context=p_objContext;}
function BatchItemReceived(p_elResource,p_objContext)
{arrBatch[p_objContext._counter].resource=p_elResource;intReceiveCount++;CheckComplete();}
objBatch.execute=function(p_fnCallback)
{fnCallback=p_fnCallback;if(!boolExecuting)
{boolExecuting=boolLockSection=true;var iCount=arrBatch.length;for(var intIndex=0;intIndex<iCount;intIndex++)
{arrBatch[intIndex].execute();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -