Javascript tree control script code _ javascript skills

Source: Internet
Author: User
Very nice js tree menu /*---------------------------------------------------------------------------*\
| Subject: JavaScript Framework
| Author: meizz
| Created: 2005-02-27
| Version: 2006-08-11
| -----------------------------------
| MSN: huangfr@msn.com QQ: 112889082
| Http://www.meizz.com Copyright (c) meizz MIT-style license
| The above copyright notice and this permission notice shall be
| Included in all copies or substantial portions of the Software
\*---------------------------------------------------------------------------*/

Window. System = function () {this. setHashCode ();}

System. debug = true; // false
System. _ codebase = {};
Try
{
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 = "Missing argument ";
System. ARGUMENT_PARSE_ERROR = "The argument cannot be parsed ";
System. NOT_SUPPORTED_XMLHTTP = "Your browser do not support XMLHttp ";
System. FILE_NOT_FOUND = "File not found ";
System. MISCODING = "Maybe file encoding is not ANSI or UTF-8 ";
System. NAMESPACE_ERROR = "nonstandard namespace ";

System. hashCounter = 0;
System. currentVersion = "20060811 ";
Var t = document. getElementsByTagName ("SCRIPT ");
T = (System. scriptElement = t [t. length-1]). src. replace (// \/g ,"/");
System. in1_ate = function (d, s) {for (var I in s) d [I] = s [I]; return d ;};
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 "! = 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 return eval ("new (System. _ prototypes ['"+ namespace +"']) ("+. join (",") + ")");
};
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); // for 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 '], ex;
For (var I = 0; I Try {return new ActiveXObject (msxmls [I] + '. xmlhttp')} catch (ex ){}
System. _ xmlHttp = "mz"; throw new Error (System. NOT_SUPPORTED_XMLHTTP );
}
}
System. load = function (namespace, path)
{
Try
{
If (System. supportsXmlHttp () {path = System. _ mapPath (namespace, path );
Var x = System. _ xmlHttp; x. open ("GET", path, 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 );
Else throw new Error (x. status + ":" + x. statusText );}
} Else System. _ alert (System. NOT_SUPPORTED_XMLHTTP );
}
Catch (ex) {System. _ alert (namespace + "\ n" + ex. message);} return "";
};
System. _ eval = function (namespace, path)
{
// Alert ("System. _ eval (\" "+ namespace +" \ ") = \ r \ n" + System. _ codebase [namespace]);
Trypolicif({execscript=window.exe cScript (System. _ codebase [namespace]); else
{
Var script = 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 ("Syntax error on load" + namespace );}
System. _ existences [namespace] = System. _ mapPath (namespace, path );
};
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. toLowerCase ();
Var p = (System. path + "/" + namespace. replace (/\./g, "/") + ". js? 6.1.3 "). toLowerCase ();
Return p + ("undefined" = typeof path | path )? "":"? T = "+ Math. random ());
};

Window. Using = function (namespace, path, rename)
{
If (System. _ exist (namespace, path )){
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 ))
Throw new 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 )? "Window [\" "+ 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 (namespace, path )){
E = "$" + System. getUniqueId () + "_ id" + new Date (). getTime () + "$ ";
S = "function" + e + "() {\ r \ n" + code + "; \ r \ nSystem. _ prototypes ['";
Code = namespace. substr (namespace. lastIndexOf (".") + 1 );
S + = namespace + "'] = window ['" + (rename | code) + "'] =" + code + "; \ r \ n} "+ e + "();";
System. _ codebase [namespace] = s; s = ""; System. _ eval (namespace, path );}
}
};
Window. Import = function (namespace, path, rename) {Using (namespace, path, rename )};
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 ))
Throw new Error (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; name = "_" + name; 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"); System. Object = System;
T. decontrol = function () {var t; if (t = this. hashCode) delete System. _ instances [t]};
T. addEventListeners = function (type, handle)
{
If ("function "! = Typeof handle)
Throw new Error (this + "addEventListener:" + handle + "is not a function ");
If (! This. _ listeners) this. _ listeners = {};
Var id = System. toHashCode (handle), t = this. _ listeners;
If ("object "! = Typeof t [type]) t [type] ={}; t [type] [id] = handle;
};
T. removeEventListener = function (type, handle)
{
If (! This. _ listeners) this. _ listeners = {}; var t = this. _ listeners;
If (! T [type]) return; var id = System. toHashCode (handle );
If (t [type] [id]) delete t [type] [id]; if (t [type]) delete t [type];
};
T. dispatchEvent = function (evt)
{
If (! This. _ listeners) this. _ listeners = {};
Var I, t = this. _ listeners, p = evt. type;
Evt.tar get = evt. srcElement = this; if (this [p]) this [p] (evt );
If ("object" = typeof t [p]) for (I in t [p]) t [p] [I]. call (this, evt );
Delete evt.tar get; delete evt. srcElement; return evt. returnValue;
};
T. setHashCode = function ()
{
System. _ instances [(this. hashCode = System. getUniqueId ()] = this;
};
T. getHashCode = function ()
{
If (! This. hashCode) this. setHashCode (); return 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.tar get = 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 support
Include ("System. Global ");

Mztreeview2.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.