|Subject:JavaScriptFramework
|Author:meizz
|Created:2005-02-27
|Version:2006-08-31
|-----------------------------------
|MSN:huangfr@msn.comQQ:112889082Copyright(c)meizz
|http://www.meizz.com/jsframework/MIT-stylelicense
|Theabovecopyrightnoticeandthispermissionnoticeshallbe
|includedinallcopiesorsubstantialportionsoftheSoftware
*---------------------------------------------------------------------------*/
window.System=function(){this.setHashCode();}
System.debug=false;//false
System._codebase={};
try
{
if(window!=parent&&parent.System&&parent.System._codebase)
System._codebase=parent.System._codebase;
elseif("undefined"!=typeofopener&&opener.System&&opener.System._codebase)
System._codebase=opener.System._codebase;
elseif("undefined"!=typeofdialogArguments&&dialogArguments.System)
System._codebase=dialogArguments.System._codebase;
}
catch(ex){}
System.MISSING_ARGUMENT="Missingargument";
System.ARGUMENT_PARSE_ERROR="Theargumentcannotbeparsed";
System.NOT_SUPPORTED_XMLHTTP="YourbrowserdonotsupportXMLHttp";
System.FILE_NOT_FOUND="Filenotfound";
System.MISCODING="MaybefileencodingisnotANSIorUTF-8";
System.NAMESPACE_ERROR="nonstandardnamespace";
System.hashCounter=0;
System.currentVersion="20060831";
vart=document.getElementsByTagName("SCRIPT");
t=(System.scriptElement=t[t.length-1]).src.replace(//g,"/");
System.extend=function(d,s){for(variins)d[i]=s[i];returnd;};
System.path=(t.lastIndexOf("/")<0)?".":t.substring(0,t.lastIndexOf("/"));
System.getUniqueId=function(){return"mz_"+(System.hashCounter++).toString(36);};
System.toHashCode=function(e)
{
if("undefined"!=typeofe.hashCode)returne.hashCode;
returne.hashCode=System.getUniqueId();
};
System.supportsXmlHttp=function()
{
return"object"==typeof(System._xmlHttp||(System._xmlHttp=newXMLHttpRequest()));
};
System._getPrototype=function(namespace,argu)
{
if("undefined"==typeofSystem._prototypes[namespace])returnnewSystem();
for(vara=[],i=0;i
};
System.ie=navigator.userAgent.indexOf("MSIE")>0&&!window.opera;
System.ns=navigator.vendor=="Netscape";
System.alert=function(msg){if(System.debug)alert(msg);};
System._parseResponseText=function(s)
{
if(null==s||"uFFFD"==s.charAt(0)){System.alert(System.MISCODING);return"";}
if("xef"==s.charAt(0))s=s.substr(3);//forfirefox
returns.replace(/(^|n)s*//+s*((Using|Import|Include)(("|'))/g,"$1$2");
};
if(window.ActiveXObject&&(System.ie||!window.XMLHttpRequest))
{
window.XMLHttpRequest=function()
{
varmsxmls=['MSXML3','MSXML2','Microsoft'];
for(vari=0;i
System._xmlHttp="mz";thrownewError(System.NOT_SUPPORTED_XMLHTTP);
}
}
System.load=function(namespace,path)
{
try
{
if(System.supportsXmlHttp()){path=System._mapPath(namespace,path);
varx=System._xmlHttp;x.open("GET",path,false);x.send(null);
if(x.readyState==4)
{
if(x.status==0||/^file:/i.test(path))
returnSystem._parseResponseText(x.responseText);
elseif(x.status==200)returnSystem._parseResponseText(x.responseText);
elseif(x.status==404)System.alert(namespace+"n"+System.FILE_NOT_FOUND);
elsethrownewError(x.status+":"+x.statusText);}
}elseSystem.alert(System.NOT_SUPPORTED_XMLHTTP);
}
catch(ex){System.alert(namespace+"n"+ex.message);}return"";
};
System._eval=function(namespace,path)
{
//alert("System._eval(""+namespace+"")=rn"+System._codebase[namespace]);
try{if(window.execScript)window.execScript(System._codebase[namespace]);else
{
varscript=document.createElement("SCRIPT");script.type="text/javascript";
script.innerHTML="eval(System._codebase['"+namespace+"']);";
document.getElementsByTagName("HEAD")[0].appendChild(script);
setTimeout(function(){script.parentNode.removeChild(script)},99);
}}catch(ex){System.alert("Syntaxerroronload"+namespace);}
System._existences[namespace]=System._mapPath(namespace,path);
};
System._exist=function(namespace,path)
{
if("undefined"==typeofSystem._existences[namespace])returnfalse;
returnSystem._existences[namespace]==System._mapPath(namespace,path);
};
System._mapPath=function(namespace,path)
{
if("string"==typeofpath&&path.length>3)returnpath;
varp=System.path+"/"+namespace.replace(/./g,"/")+".js";
returnp+(("undefined"==typeofpath||path)?"":"?t="+Math.random());
};
window.Using=function(namespace,path,rename)
{
if(System._exist(namespace,path)){
vars=window[namespace.substr(namespace.lastIndexOf(".")+1)];
if(s!=System._prototypes[namespace])s=System._prototypes[namespace];return}
varcode=namespace+".";if(!/((^|.)[w$]+)+$/.test(namespace))
thrownewError(namespace+System.NAMESPACE_ERROR);
for(vari=code.indexOf(".");i>-1;i=code.indexOf(".",i+1)){
vare=code.substring(0,i),s=(e.indexOf(".")==-1)?"window[""+e+""]":e;
if(e&&"undefined"==typeof(s)){
eval(s+"=function(){returnSystem._getPrototype(""+e+"",arguments)}");}}
if("undefined"==typeofpath&&"string"==typeofSystem._codebase[namespace])
{
System._eval(namespace,path);}else{if(code=System.load(namespace,path)){
e="$"+System.getUniqueId()+"__id"+newDate().getTime()+"$";
s="function"+e+"(){rn"+code+";rnSystem._prototypes['";
code=namespace.substr(namespace.lastIndexOf(".")+1);
s+=namespace+"']=window['"+(rename||code)+"']="+code+";rn}"+e+"();";
System._codebase[namespace]=s;s="";System._eval(namespace,path);}
}
};
window.Import=function(namespace,path,rename){Using(namespace,path,rename)};
window.Instance=function(hashCode){returnSystem._instances[hashCode]};
window.Include=function(namespace,path)
{
if(System._exist(namespace,path))return;
varcode;if(!/((^|.)[w$]+)+$/.test(namespace))
thrownewError(namespace+System.NAMESPACE_ERROR);
if("undefined"==typeofpath&&"string"==typeof(System._codebase[namespace]))
{
System._eval(namespace,path);}elseif(System.supportsXmlHttp()){
if(code=System.load(namespace,path)){System._codebase[namespace]=code;
System._eval(namespace,path);}}else{
varscript=document.createElement("SCRIPT");script.type="text/javascript";
script.src=System._existences[namespace]=System._mapPath(namespace,path);
document.getElementsByTagName("HEAD")[0].appendChild(script);
setTimeout(function(){script.parentNode.removeChild(script)},99);
}
};
Function.READ=1;Function.WRITE=2;Function.READ_WRITE=3;
Function.prototype.addProperty=function(name,initValue,r_w)
{
varcapital=name.charAt(0).toUpperCase()+name.substr(1);
r_w=r_w||Function.READ_WRITE;name="_"+name;varp=this.prototype;
if("undefined"!=typeofinitValue)p[name]=initValue;
if(r_w&Function.READ)p["get"+capital]=function(){returnthis[name];};
if(r_w&Function.WRITE)p["set"+capital]=function(v){this[name]=v;};
};
Function.prototype.Extends=function(SuperClass,ClassName)
{
varop=this.prototype,i,p=this.prototype=newSuperClass();
if(ClassName)p._className=ClassName;for(iinop)p[i]=op[i];
if(p.hashCode)deleteSystem._instances[p.hashCode];returnp;
};
System._instances={};
System._prototypes=
{
"System":System,
"System.Object":System,
"System.Event":System.Event
};
System._existences=
{
"System":System._mapPath("System"),
"System.Event":System._mapPath("System.Event"),
"System.Object":System._mapPath("System.Object")
};
t=System.Extends(Object,"System");System.Object=System;
t.decontrol=function(){vart;if(t=this.hashCode)deleteSystem._instances[t]};
t.addEventListeners=function(type,handle)
{
if("function"!=typeofhandle)
thrownewError(this+"addEventListener:"+handle+"isnotafunction");
if(!this._listeners)this._listeners={};
varid=System.toHashCode(handle),t=this._listeners;
if("object"!=typeoft[type])t[type]={};t[type][id]=handle;
};
t.removeEventListener=function(type,handle)
{
if(!this._listeners)this._listeners={};vart=this._listeners;
if(!t[type])return;varid=System.toHashCode(handle);
if(t[type][id])deletet[type][id];if(t[type])deletet[type];
};
t.dispatchEvent=function(evt)
{
if(!this._listeners)this._listeners={};
vari,t=this._listeners,p=evt.type;
evt.target=evt.srcElement=evt.target||evt.srcElement||this;
evt.currentTarget=this;if(this[p])this[p](evt);
if("object"==typeoft[p])for(iint[p])t[p][i].call(null,evt);
deleteevt.target;deleteevt.currentTarget;deleteevt.srcElement;
returnevt.returnValue;
};
t.setHashCode=function()
{
System._instances[(this.hashCode=System.getUniqueId())]=this;
};
t.getHashCode=function()
{
if(!this.hashCode)this.setHashCode();returnthis.hashCode;
};
t.toString=function(){return"[object"+(this._className||"Object")+"]";};
System.Event=function(type){this.type=type;};
t=System.Event.Extends(System,"System.Event");
t.returnValue=true;t.cancelBubble=false;
t.target=t.currentTarget=t.srcElement=null;
t.stopPropagation=function(){this.cancelBubble=true;};
t.preventDefault=function(){this.returnValue=false;};
if(System.ie&&!System.debug)Include("System.Plugins.IE");//IEUserData
if(window.opera)Include("System.Plugins.Opera");//Operasupport
Include("System.Global");
演示效果
本地下载