
/**//*---------------------------------------------------------------------------*
|Subject:JavaScriptFramework
|Author:meizz
|Created:2005-02-27
|Version:2007-06-06
|-----------------------------------
|MSN:huangfr@msn.comQQ:112889082Copyright(c)meizz
|http://www.meizz.com/jsframework/MIT-stylelicense
|Theabovecopyrightnoticeandthispermissionnoticeshallbe
|includedinallcopiesorsubstantialportionsoftheSoftware
*---------------------------------------------------------------------------*/
if(typeof(System)!="function"&&typeof(Using)!="function")
...{
varS=window.System=function()
...{
this.setHashCode();
}
S.debug=false;//false
S.currentVersion="20070606";

S._codebase=...{};
try
...{
if(window!=parent&&parent.System&&parent.System._codebase)
S._codebase=parent.System._codebase;
elseif(typeof(opener)!="undefined"&&opener.System&&opener.System._codebase)
S._codebase=opener.System._codebase;
elseif(typeof(dialogArguments)!="undefined"&&dialogArguments.System)
S._codebase=dialogArguments.System._codebase;
}
catch(ex)
...{}
vart=document.getElementsByTagName("SCRIPT");
t=(S.scriptElement=t[t.length-1]).src.replace(/\/g,"/");
S.extend=function(d,s)
...{
for(variins)
d[i]=s[i];
returnd;
};
S.path=(t.lastIndexOf("/")<0)?".":t.substring(0,t.lastIndexOf("/"));
S.resourcePath=S.path+"/System/_resource";
S.hashCounter=0;
S.NOT_SUPPORTED_XMLHTTP="YourbrowserdonotsupportXMLHttp";
S.getUniqueId=function()
...{
return"mz_"+(System.hashCounter++).toString(36);
};
S.toHashCode=function(e)
...{
if(typeof(e.hashCode)!="undefined")
...{
returne.hashCode;
}
return(e.hashCode=System.getUniqueId());
};
S.supportsXmlHttp=function()
...{
return"object"==typeof(System.xhr||(System.xhr=newXMLHttpRequest()));
};
S._getPrototype=function(ns,argu)
...{
if(typeof(System._prototypes[ns])=="undefined")
returnnewSystem();
for(vara=[],i=0;i<argu.length;i++)
a[i]="argu["+i+"]";
returneval("new(System._prototypes['"+ns+"'])("+a.join(",")+")");
};
S.ie=navigator.userAgent.indexOf("MSIE")>0&&!window.opera;
S.alert=function(msg)
...{
if(System.debug)
alert(msg);
};
S._userdata=(System.ie&&!System.debug);S._parseResponse=function(ns,s)
...{
if(s==null||s.charAt(0)=="�")
...{
System.alert("Maybefileencodingisn'tANSIorUTF-8");return""
}
if(s.charAt(0)=="ï")s=s.substr(3);//forfirefox
s=s.replace(/(^| )s*//+s*((Using|Import|Include)(("|'))/g,"$1$2");
if(System._userdata)
System.saveUserData(ns,s);
returns;
};
if(!window.XMLHttpRequest&&window.ActiveXObject)
{
window.XMLHttpRequest=function()
{
for(vari=0,a=['MSXML3','MSXML2','Microsoft'];i<a.length;i++)
{
try
{
returnnewActiveXObject(a[i]+'.XMLHTTP')
}
catch(ex){}
}
System.xhr="mz";
thrownewError(System.NOT_SUPPORTED_XMLHTTP);
}
}
S.load=function(namespace,path)
{
varx,ns=namespace,S=System;
path=S._mapPath(ns,path);
if(S._userdata&&/.js$/i.test(path)&&(x=S.loadUserData(ns)))
return(S._codebase[ns]="//fromuserdata "+x);
try
...{
if(S.supportsXmlHttp())
...{
x=S.xhr;
x.open("GET",path,false);
x.send(null);
if(x.readyState==4)
...{
if(x.status==0||/^file:/i.test(path))
returnS._parseResponse(ns,x.responseText);
elseif(x.status==200)
returnS._parseResponse(ns,x.responseText);
elseif(x.status==404)
S.alert(ns+" Filenotfound");
else
thrownewError(x.status+":"+x.statusText);
}
}
elseS.alert(S.NOT_SUPPORTED_XMLHTTP);
}
catch(ex)
...{
S.alert(ns+" "+ex.message);
}
return"";
};
S._exist=function(ns,path)
...{
if(typeof(System._existences[ns])=="undefined")
returnfalse;
returnSystem._existences[ns]==System._mapPath(ns,path);
};
S._mapPath=function(ns,path)
...{
if(typeof(path)=="string"&&path.length>3)
returnpath;
varp=System.path+"/"+ns.replace(/./g,"/")+".js";
returnp+((typeof(path)=="undefined"||path)?"":"?t="+Math.random());
};
window.Using=function(namespace,path,rename)
...{
varN=namespace,C=N.substr(N.lastIndexOf(".")+1),S=System,i=S._prototypes;
if(S._exist(N,path))
...{
if(window[C]!=i[N])
window[C]=i[N];
return
}
if(!/((^|.)[w_$]+)+$/.test(N))
thrownewError(N+"nonstandardnamespace")
for(vars,e,c=N+".",i=c.indexOf(".");i>-1;i=c.indexOf(".",i+1))
...{
e=c.substring(0,i);
s=(e.indexOf(".")==-1)?"window['"+e+"']":e;
if(e&&typeof(eval(s))==
本文介绍了JavaScript框架的基本组件和功能实现方式,包括系统初始化、路径映射、资源加载等关键环节,并探讨了不同浏览器环境下XMLHttpRequest的支持情况。
6722

被折叠的 条评论
为什么被折叠?



