/*------------------------------------------------ ---------------------------*
| 主题:JavaScript 框架
| 作者: meizz
| 创建时间:2005-02-27
| 版本:2006-08-31
|------------------------------------------------
| MSN: huangfr@msn.com QQ:112889082 版权所有(c) meizz
| http://www.meizz.com/jsframework/ MIT 风格许可证
| 上述版权声明和本许可声明应为
| 包含在软件的所有副本或大部分中
*------------------------------------ ---------------------------------------*/
window.System = function(){this.setHashCode();}
System.debug=false; // false
System._codebase={};
尝试
{
if (window!=parent && parent.System && parent.System._codebase)
System._codebase = parent.System._codebase;
else if ("undefined"!=typeof opener&&opener.System&&opener.System._codebase)
System._codebase = opener.System._codebase;
else if ("undefined"!=typeof dialogArguments && dialogArguments.System)
System._codebase = dialogArguments.System._codebase;
}
catch(ex){}
System.MISSING_ARGUMENT="缺少参数";
System.ARGUMENT_PARSE_ERROR="无法解析参数";
System.NOT_SUPPORTED_XMLHTTP="您的浏览器不支持 XMLHttp";
System.FILE_NOT_FOUND="未找到文件";
System.MISCODING="也许文件编码不是 ANSI 或 UTF-8";
System.NAMESPACE_ERROR="非标准命名空间";
System.hashCounter=0;
System.currentVersion="20060831";
var t=document.getElementsByTagName("SCRIPT");
t=(System.scriptElement=t[t.length-1]).src.replace(/\/g, "/");
System.extend=function(d,s){for(var i in s)d[i]=s[i];return d;};
System.path=(t.lastIndexOf("/")System.getUniqueId=function(){return "mz_" (System.hashCounter ).toString(36);};
System.toHashCode=function(e)
{
if("undefined"!=typeof e.hashCode) return e.hashCode;
return e.hashCode=System.getUniqueId();
};
System.supportsXmlHttp=function()
{
return "object"==typeof(System._xmlHttp||(System._xmlHttp=new XMLHttpRequest()));
};
System._getPrototype=function(namespace, argu)
{
if("undefined"==typeof System._prototypes[namespace])return new System();
for(var a=[], 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=函数
{
if (null==s||"uFFFD"==s.charAt(0)){System.alert(System.MISCODING);return " ";}
if ("xef"==s.charAt(0))s=s.substr(3); // 对于 firefox
return s.replace(/(^|n)s*// s*((Using|Import|Include)(("|'))/g,"$1$2");
};
if(window.ActiveXObject && (System.ie || !window.XMLHttpRequest))
{
window.XMLHttpRequest = function()
{
var msxmls =['MSXML3','MSXML2','Microsoft'];
for(var i=0;i
System._xmlHttp="mz"; 抛出新错误(System.NOT_SUPPORTED_XMLHTTP);
}
}
System.load = 函数(命名空间,路径)
{
尝试
{
if(System.supportsXmlHttp()){path=System._mapPath(namespace, path);
var x=System._xmlHttp; x.open("GET",路径,false); x.send(null);
if (x.readyState==4)
{
if(x.status==0||/^file:/i.test(path))
return System._parseResponseText(x .responseText);
else if(x.status==200)return System._parseResponseText(x.responseText);
else if(x.status==404)System.alert(namespace "n" System.FILE_NOT_FOUND);
否则抛出新的错误(x.status ": " x.statusText);}
} else System.alert(System.NOT_SUPPORTED_XMLHTTP);
}
catch(ex){System.alert(namespace "n" ex.message);}return "";
};
System._eval = 函数(命名空间,路径)
{
//alert("System._eval("" 命名空间 "")=rn" System._codebase[命名空间]);
尝试{if(window.execScript)window.execScript(System._codebase[namespace]);else
{
var script=document.createElement("SCRIPT");script.type="text/ JavaScript";
script.innerHTML="eval(System._codebase['" 命名空间 "']);";
document.getElementsByTagName("HEAD")[0].appendChild(script);
setTimeout(function(){script.parentNode.removeChild(script)},99);
}}catch(ex){System.alert("加载时出现语法错误" 命名空间);}
System._existences[namespace]=System._mapPath(namespace, 路径);
};
System._exist = function(namespace, path)
{
if("undefined"==typeof System._existences[namespace]) return false;
return System._existences[namespace]==System._mapPath(namespace,path);
};
System._mapPath = function(namespace, path)
{
if("string"==typeof path && path.length>3) return path;
var p=System.path "/" namespace.replace(/./g,"/") ".js";
return p (("undefined"==typeof path||path) ? "" : "?t=" Math.random());
};
window.Using = 函数(命名空间、路径、重命名)
{
if(System._exist(命名空间, 路径)){
var s=window[namespace.substr(namespace) .lastIndexOf(".") 1)];
if(s!=System._prototypes[namespace])s=System._prototypes[namespace];return}
var code=namespace "."; if(!/((^|.)[w$] ) $/.test(namespace))
抛出新的 Error(namespace System.NAMESPACE_ERROR);
for(var i=code.indexOf("."); i>-1; i=code.indexOf(".", i 1)){
var e=code.substring(0,i ), s=(e.indexOf(".")==-1) ? "窗口["" e ""]":e;
if(e&&"undefined"==typeof(s)){
eval(s "=function(){return System._getPrototype("" e "", arguments)}");}}
if("undefined"==typeof path &&"string"==typeof System._codebase[namespace])
{
System._eval(namespace, path);}else{if(code=System.load) (命名空间,路径)){
e = "$" System.getUniqueId() "__id" new Date().getTime() "$";
s = "function " e "(){rn" code ";rnSystem._prototypes['";
code=namespace.substr(namespace.lastIndexOf(".") 1);
s = 命名空间 "']=window['" (重命名||代码) "']=" 代码 ";rn}" e "();";
System._codebase[namespace]=s;s="";System._eval(namespace, path);}
}
};
window.Import=function(命名空间,路径,重命名){使用(命名空间,路径,重命名)};
window.Instance=function(hashCode){return System._instances[hashCode]};
window.Include=function(namespace, path)
{
if(System._exist(namespace, path)) return;
var code;if(!/((^|.)[w$] ) $/.test(namespace))
抛出新的错误(namespace System.NAMESPACE_ERROR);
if("undefined"==typeof path&&"string"==typeof(System._codebase[namespace]))
{
System._eval(namespace, path);}else if(System.supportsXmlHttp()){
if(code=System.load(namespace, path)){System._codebase[namespace]=code;
System._eval(namespace, path);}}else{
var script=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)
{
var capital=name.charAt(0).toUpperCase() name.substr(1);
r_w=r_w||Function.READ_WRITE; 名称=“_”名称; var p=this.prototype;
if("undefined"!=typeof initValue) p[name]=initValue;
if(r_w&Function.READ) p["get" capital]=function(){return this[name];};
if(r_w&Function.WRITE) p["set" capital]=function(v){this[name]=v;};
};
Function.prototype.Extends=function(SuperClass,ClassName)
{
var op=this.prototype, i, p=this.prototype=new SuperClass();
if(ClassName)p._className=ClassName; for(i in op)p[i]=op[i];
if(p.hashCode)delete System._instances[p.hashCode];return p;
};
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"); 系统.对象=系统;
t.decontrol=function(){var t;if(t=this.hashCode)delete System._instances[t]};
t.addEventListeners=函数(类型,句柄)
{
if("function"!=typeof handle)
抛出新错误(此“addEventListener:”句柄“不是函数”) ;
if(!this._listeners) this._listeners={};
var id=System.toHashCode(handle), t=this._listeners;
if("object"!=typeof t[type]) t[type]={}; t[类型][id]=句柄;
};
t.removeEventListener=函数(类型,句柄)
{
if(!this._listeners)this._listeners={}; var t=this._listeners;
if(!t[type]) 返回; var id=System.toHashCode(句柄);
if(t[type][id])删除 t[type][id];if(t[type])删除 t[type];
};
t.dispatchEvent=function(evt)
{
if(!this._listeners)this._listeners={};
var i, t =this._listeners, p =evt.type;
evt.target=evt.srcElement=evt.target||evt.srcElement||this;
evt.currentTarget=this; 如果(这个[p])这个[p](evt);
if("object"==typeof t[p]) for(i in t[p]) t[p][i].call(null, evt);
删除 evt.target;删除 evt.currentTarget;删除 evt.srcElement;
返回 evt.returnValue;
};
t.setHashCode=function()
{
System._instances[(this.hashCode=System.getUniqueId())]=this;
};
t.getHashCode=function()
{
if(!this.hashCode)this.setHashCode(); 返回 this.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"); //IE UserData
if(window.opera) Include("System.Plugins.Opera"); //Opera 支持
Include("System.Global");
演示效果
本地下载