📄 liveframework.js
字号:
var __Web_Runtime=Web.Runtime=new function()
{var objRuntime=this,blnIE=Web.Browser._isIE,blnPLTTraced=false,dtInitTime;this.culture=document.documentElement.getAttribute("web:culture")||"en-US";this.readyStateType=Type.createSimpleEnum("Uninitialized","Init","InitComplete");this._readyState=this.readyStateType.Uninitialized;this.oninit=new Type.DOMEvent(true);this.onunload=new Type.DOMEvent(true);this.onplttrace=new Type.DOMEvent(true);function UnwirePage()
{if(blnIE)
window.detachEvent("onstop",UnwirePage);window.detachEvent("onunload",UnwirePage);objRuntime.onunload.fire(null);__Web_Utility.Script._list=null;if(Web.Memory&&Web.Memory._clearHandlers)
Web.Memory._clearHandlers();__Web_Runtime.oninit=__Web_Runtime.onunload=__Web_Runtime.onplttrace=null;if(Web.Browser._isIE)
{try
{document.execCommand("BackgroundImageCache",false,false);}
catch(ex)
{}
}
if(Web.TraceData&&Web.TraceData.Disable!='1'&&!Web.Browser.isMozilla())
{window.detachEvent("onerror",Web.Error.Submit);}
CollectGarbage();Web=null;}
function VerifyHookupsCalled()
{if(blnIE)
window.detachEvent("onstop",UnwirePage);if(objRuntime._readyState==__Web_Runtime.readyStateType.Uninitialized)
{__Web_Runtime.init();}
window.detachEvent("onload",VerifyHookupsCalled);}
function InternalPLTTrace(isInit)
{if(blnPLTTraced==false&&Web.TraceData&&Web.TraceData.Disable!="1"&&(!isInit||Web.TraceData.SkipInitPLT!="1")&&objRuntime._readyState==objRuntime.readyStateType.InitComplete)
{blnPLTTraced=true;try
{if(Math.floor(Math.random()*1001)<=parseInt(Web.TraceData.PLTRate))
{var _now=(new Date()).getTime();var _pltTarget=Web.TraceData.Target+"&ec=0&it="+(_now-dtInitTime)+"&hft="+((typeof(Live)!='undefined'&&Live.HeaderRenderTime)?(_now-Live.HeaderRenderTime):"");Web.Network.createRequest(Web.Network.Type.Image,_pltTarget,null,null,Web.Utility.Prioritizer.Priorities.Lowest).execute();__Web_Runtime.onplttrace.fire(_pltTarget);}
}
catch(ex)
{}
}
}
window.attachEvent("onload",VerifyHookupsCalled);window.attachEvent("onunload",UnwirePage);if(blnIE)
window.attachEvent("onstop",UnwirePage);this.DoPLTTrace=function()
{InternalPLTTrace(false);}
this.init=function()
{var _rst=objRuntime.readyStateType;if(objRuntime._readyState==_rst.Uninitialized)
{dtInitTime=(new Date()).getTime();objRuntime._readyState=_rst.Init;objRuntime.oninit.fire();objRuntime._readyState=_rst.InitComplete;InternalPLTTrace(true);}
else
throw new Error("Page already initialized.");}
}
__Web_Runtime.HostName="Microsoft";__Web_Runtime.MaxThreadLock=150;registerNamespace("Web.Utility");var __Web_Utility=Web.Utility=
{_FindUrl:function(p_arCol,p_strProp,p_strMatch)
{if(p_strMatch)
{var iCount=p_arCol.length,strSource=__Web_Utility.resolveUrl(p_strMatch).toLowerCase(),i=0;for(i=0;i<iCount;i++)
{var strCompare=p_arCol[i].getAttribute(p_strProp);if(strCompare)
{strCompare=__Web_Utility.resolveUrl(strCompare).toLowerCase();if(strCompare==strSource)
{return p_arCol[i];}
}
}
}
return null;},
CSS:{findElement:function(p_strSrc)
{return __Web_Utility._FindUrl(_get("link"),"href",p_strSrc);}
},
Script:{getElement:function(p_strSrc)
{var _rl=__Web_Utility.resolveUrl;if(!this._list)
{this._list={};var i=0,arrScripts=document.scripts,iCount=arrScripts.length;for(i=0;i<iCount;i++)
{var elScript=arrScripts[i];this._list[_rl(elScript.src).toLowerCase()]=elScript;}
}
return this._list[_rl(p_strSrc).toLowerCase()];},
attachScript:function(p_elAttachScript,p_elAttachElement,p_fnCallback)
{var r=Web.Network.createRequest(Web.Network.Type.script,p_elAttachScript.src,null,p_fnCallback);r.execute();},
_list:null
},
Prioritizer:function()
{var pList={},__Web_Utility_Prioritizer_Priorities=__Web_Utility.Prioritizer.Priorities;this.push=function(obj,priority)
{if(!priority)priority=__Web_Utility_Prioritizer_Priorities.Medium;if(pList[priority])
pList[priority].unshift(obj);else
throw new Error("Error: Invalid Priority Specified");}
this.queue=function(obj,priority)
{if(!priority)priority=__Web_Utility_Prioritizer_Priorities.Medium;if(pList[priority])
pList[priority].queue(obj);else
throw new Error("Error: Invalid Priority Specified");}
this.dequeue=function()
{for(var p in pList)
{var obj=pList[p];if(obj.length>0)
return obj.dequeue();}
return null;}
this.removeItem=function(obj)
{var bRemoved=false;for(var p in pList)
{bRemoved=pList[p].remove(obj)||bRemoved;}
return bRemoved;}
this.findByProperty=function(p_strProperty,p_strValue)
{for(var p in pList)
{var objQ=pList[p];for(var item in objQ)
{if(objQ[item][p_strProperty]==p_strValue)
return objQ[item];}
}
return null;}
this.getList=function()
{return pList;}
this.clear=function()
{for(var p in __Web_Utility_Prioritizer_Priorities.getValues())
{pList[p]=[];}
}
this.clear();return this;},
extractHost:function(p_strUrl,p_blnIncludePrototcol)
{var sUrl=String(p_strUrl);var re=p_blnIncludePrototcol
?this.extractHost.reProtocolAndHost
:this.extractHost.reHost;return sUrl.search(re)<0
?''
:RegExp.$1;},
resolveUrl:function(str,strSource)
{if(str==null)return "";if(str.indexOf("{")>=0)
{str=str.replace("{culture}",__Web_Runtime.culture);if((typeof Live!="undefined")&&Live&&Live.Themes)
{str=str.replace("{theme.url}",Live.Themes.ThemeUrl);}
if(__Web_Runtime.baseUrl)
{str=str.replace("{framework.base}",__Web_Runtime.baseUrl);}
}
if(!strSource)
{if(!__Web_Utility.resolveUrl.Base)
{var elBases=_get("base");if(elBases.length>0&&elBases[0].href!="")
strSource=__Web_Utility.resolveUrl.Base=elBases[0].href;else
{var tmp=location.protocol+"//"+location.host+location.pathname;strSource=__Web_Utility.resolveUrl.Base=tmp.substring(0,tmp.lastIndexOf("/")+1);}
}
else
strSource=__Web_Utility.resolveUrl.Base;}
else
{strSource=strSource.substring(0,strSource.lastIndexOf("/")+1);}
if(str.startsWith("/"))str=location.protocol+"//"+location.host+str;if(str.indexOf("//")==-1)str=strSource+str;function DeleteDoubleDots(p_strPath)
{while(DeleteDoubleDots.reDoubleDot.test(p_strPath))
{p_strPath=p_strPath.replace(DeleteDoubleDots.reDoubleDot,"");}
return(p_strPath);}
DeleteDoubleDots.reDoubleDot=/\/[^\/]*\/\.\./;return DeleteDoubleDots(str);},
loadSources:function(p_astrSources,p_astrStyles,p_astrXml,p_astrImages,p_ePriority,p_fncAsyncCallback,p_objContext)
{var __Web_Network_Type=__Web_Network.Type;function SourcesRetrieved(p_htScripts)
{var aelXml=[],iCount=p_htScripts.length,i=0;for(i=0;i<iCount;i++)
{var objItem=p_htScripts[i];if(objItem.resource)
{switch(objItem.type)
{case __Web_Network_Type.XML:
case __Web_Network_Type.XMLGet:
case __Web_Network_Type.XMLPost:
aelXml.push(objItem);}
}
}
p_fncAsyncCallback(aelXml,p_objContext);}
if(p_astrSources.length===0&&p_astrStyles.length===0&&p_astrXml.length===0)
{p_fncAsyncCallback(null,p_objContext);}
else
{var objRequest=__Web_Network.createBatch(p_ePriority),blnFetch=false;function Check(p_eType,p_fncCheck)
{return function(i)
{if(i!=""&&(p_fncCheck==null||!p_fncCheck(i)))
{blnFetch=true;objRequest.add(p_eType,i,i.name,null);}
}
}
p_astrSources.forEach(Check(__Web_Network_Type.Script,Web.Browser.isMozilla()?null:__Web_Utility.Script.getElement),this);p_astrStyles.forEach(Check(__Web_Network_Type.CSS,__Web_Utility.CSS.findElement),this);p_astrXml.forEach(Check(__Web_Network_Type.XML,null),this);p_astrImages.forEach(Check(__Web_Network_Type.Image,null),this);if(blnFetch)
{objRequest.execute(SourcesRetrieved);}
else
{objRequest=null;p_fncAsyncCallback(null,p_objContext);}
}
},
applyFunctionOverArray:function(p_fnc,p_a,p_fncAsyncCallback)
{var i=0,length=p_a.length;function RunNext()
{if(i<length)
{p_fnc(p_a[i++]);window.setTimeout(RunNext,1);}
else
{if(p_fncAsyncCallback)
p_fncAsyncCallback();}
}
if(p_fncAsyncCallback)
{RunNext();}
else
{p_a.forEach(p_fnc);}
}
}
__Web_Utility.Prioritizer.Priorities=__Web_Enum.create("High","Medium","Low","Lowest");__Web_Utility.extractHost.reHost=/^(?:http|https|ftp):\/\/([-.a-z0-9]+(?::[0-9]+)?)(?:\/|$)/i;__Web_Utility.extractHost.reProtocolAndHost=/^((?:http|https|ftp):\/\/[-.a-z0-9]+(?::[0-9]+)?)(?:\/|$)/i;var __Web_Network=Web.Network=new function()
{var objNetwork=this,objDomains={},strCurrentDomain=__Web_Utility.extractHost(document.location.href,false),blnRegister=false,_wc=__Web_Event.create,iStream=0,arrStream,blnImagesChecked=false,intImagesCount=0;this.defaultTimeout=null;this.oninvoke=_wc();this.onfinished=_wc();this.onabort=_wc();this.onhttperror=_wc();this.onprofile=_wc();this.onerror=_wc();this.ontimeout=_wc();this.onrequest=_wc();this._streamUpdate=function(id,w,state,contents)
{if(arrStream[id])
{arrStream[id](w,state,contents);}
}
this.RegisterBaseDomain=function()
{if(blnRegister)return;var strDomain=strCurrentDomain;if(strDomain.indexOf(":")>0)
{strDomain=strDomain.substring(0,strDomain.indexOf(":"));}
var idx=strDomain.indexOf(".");if(idx>0)
{document.domain=strDomain;try
{while(idx>=0)
{strDomain=strDomain.substring(idx+1);if(strDomain!="com")
{document.domain=strDomain;idx=strDomain.indexOf(".");}
else
idx=-1;}
}
catch(ex)
{}
}
blnRegister=true;}
this.registerProxy=function(w)
{var strProxyDomain=__Web_Utility.extractHost(w.location.href,false);objDomains[strProxyDomain]._assignProxy(w);}
function RunList(p_strDomain)
{var m_this=this;var intActive=0;var blnProxy=false,objProxy,elProxy;var objList={};var _wp=__Web_Utility.Prioritizer;var objParallel=new _wp();var objSerializer=new _wp();var __ce=_ce;var boolSerRequest=false;var m_objRuntime=this;var blnIsIE=Web.Browser._isIE;var _dbg=Web.Debug.enabled;var _isMoz=Web.Browser.isMozilla();function FetchImage(o)
{var img=new Image();img.onload=doImgCallback;img.onerror=img.onabort=doError;img.blnError=false;img.src=o.url;if(intImagesCount==2)
doImgCallback()
else
if(!blnImagesChecked&&blnIsIE)
o.timer=setTimeout(checkDisabled,1100);function checkDisabled()
{if(img.readyState=="uninitialized"&&!img.blnError)
intImagesCount++;doImgCallback();}
function doError()
{img.blnError=true;doImgCallback();}
function doImgCallback()
{if(blnIsIE&&img.readyState!="uninitialized")
blnImagesChecked=true;if(o&&o.timer)
{clearTimeout(o.timer);o.timer=null;}
img.onerror=img.onabort=img.onload=null;Finished(img,o);}
return img;}
function FetchCSS(o)
{var el=__Web_Utility.CSS.findElement(o.url);if(!el)
{if(o.context&&o.context.pool)
{el=o.context.pool;el.href=o.url;}
else
{el=__ce("link");el.rel="stylesheet";el.type="text/css";el.href=o.url;_dh.appendChild(el);}
el.onreadystatechange=doCSSCallback;if(Web.Browser.isMozilla()||Web.Browser.isOpera())
{el.readyState="complete";}
doCSSCallback();}
else
{Finished(el,o);}
function doCSSCallback()
{if(el&&el.onreadystatechange&&("loaded"==el.readyState||"complete"==el.readyState))
{el.onreadystatechange=null;Finished(el,o);}
}
return el;}
function FetchScript(o)
{var strUrl=__Web_Utility.resolveUrl(o.url).toLowerCase();var el=__Web_Utility.Script.getElement(strUrl);if(!el)
{el=__ce("script");if(!blnIsIE)
{el.onload=el.onerror=doJSCallback;el.readyState="loaded";__Web_Utility.Script._list[strUrl]=el;_dh.appendChild(el);}
else
el.onreadystatechange=doJSCallback;el.src=o.url;}
else
{if(!blnIsIE)
{el.readyState="complete";if(el.onload==null)
{doJSCallback();}
else
{if(el.callbacks==null)
el.callbacks=[];el.callbacks.push(doJSCallback);}
}
else
{Finished(el,o);}
}
function doJSCallback()
{if(el&&("loaded"==el.readyState||"complete"==el.readyState))
{el.onreadystatechange=el.onload=el.onerror=null;if(blnIsIE&&!(o.flags&__Web_Network.Flags.CACHEONLY))
{_dh.appendChild(el);__Web_Utility.Script._list[strUrl]=el;}
else
if(el.callbacks)
{for(var i=0;i<el.callbacks.length;i++)
el.callbacks[i]();el.callbacks=null;}
Finished(el,o);}
}
return el;}
function FetchStream(o)
{var el=_ce("iframe"),_ss=Web.Network.StreamState;el.style.display="none";document.body.insertAdjacentElement("afterBegin",el);o.streamIndex=(iStream++);if(o.timeout)
o.timer=setTimeout(TimedOut,o.timeout);else
o.timer=setTimeout(TimedOut,5000);el.src=o.url+"#domain="+document.domain+"&id="+o.streamIndex;if(!arrStream)
{arrStream=[];}
arrStream[o.streamIndex]=doCallback;if(!o.context)o.context={};function TimedOut()
{o.timer=null;doCallback(null,Web.Network.StreamState.Timeout,null);}
function DoBatch()
{if(o.context.batchData!=null)
{if(o.batchTimeout)
{clearTimeout(o.batchTimeout);}
doCallback(o.page,Web.Network.StreamState.BatchUpdate,null);o.context.batchData=null;if(o.context.batchTimer)
o.batchTimeout=setTimeout(DoBatch,o.context.batchTimer);}
}
function doCallback(objPage,objState,objRoot)
{if(o.timer)
{clearTimeout(o.timer);o.timer=null;}
o.context.data=objRoot;o.context.state=o.context.batchData?_ss.BatchUpdate:objState;if(objState==Web.Network.StreamState.Loading&&(o.context.batchTimer||o.context.batchCount))
{if(o.context.batchTimer!=null)
{o.batchTimeout=setTimeout(DoBatch,o.context.batchTimer);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -