⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client_master.js

📁 一种.net实现ajax方法的类库
💻 JS
📖 第 1 页 / 共 4 页
字号:
var SVG_NS = "http://www.w3.org/2000/svg";var XLINK_NS = "http://www.w3.org/1999/xlink";function printfire(){    if (document.createEvent)    {        printfire.args = arguments;        var ev = document.createEvent("Events");        ev.initEvent("printfire", false, true);        if( dispatchEvent ) dispatchEvent(ev);    }}dojo.require("dojo.event");dojo.require("dojo.lfx.html");dojo.require("dojo.xml.Parse"); dojo.require("dojo.widget.*");var emerge_post_load;var $ = document.getElementById;var Log, LogPane_Log;function log(aMessage){    //GBLTut_ConsoleService.logStringMessage('My_Extension: ' + aMessage);    //consoleService.logStringMessage(aMessage);    //alert( aMessage );    if( Log != null )		Log.AppendText( aMessage + "<BR>" );	else if( LogPane_Log != null )		LogPane_Log.AppendText( aMessage + "<BR>" );	//alert( aMessage );}Function.prototype.toName = function() {    var sConstructor = this.toString();     var aMatch = sConstructor.match( /\s*function (.*)\(/ );     if( aMatch && aMatch[1] ) return aMatch[1]; else return null;}Function.prototype.inherits = function (parent) {    var parentCnName = parent.toName();    var parentObj = parent.prototype;    for( var k in parentObj )        this.prototype[k] = parentObj[k];    var d = 0;    var p = parentObj;    //var d = 0, p = (this.prototype = new parent());    this.prototype[parentCnName] = parent;    this.prototype.uber = function uber(name) {        var f, r, t = d, v = parent.prototype;        if (t) {            while (t) {                v = v.constructor.prototype;                t -= 1;            }            f = v[name];        } else {            f = p[name];            if (f == this[name]) {                f = v[name];            }        }        d += 1;        r = f.apply(this, Array.prototype.slice.apply(arguments, [1]));        d -= 1;        return r;    }    this.prototype.uberArgs = function uberArgs(name, args) {        var f, r, t = d, v = parent.prototype;        if (t) {            while (t) {                v = v.constructor.prototype;                t -= 1;            }            f = v[name];        } else {            f = p[name];            if (f == this[name]) {                f = v[name];            }        }        d += 1;        r = f.apply(this, args);        d -= 1;        return r;    }    return this;}function buildRoot(url){    return url.substr(0,url.lastIndexOf("/")+1);}function getRoot(){    return buildRoot(document.location.href);}function getSchemeAndDomain(){    return location.protocol + '//' + location.host + '/';}function loadUri(uri){    dojo.hostenv.loadUri(uri);}function Send( id, evt, arg ){	var sepChar = '?';	if( document.location.href.indexOf('?') > 0 )		sepChar = '&';	var url = document.location.href;	url = url.substring(0,url.indexOf('#')) + sepChar + "widget=" + id + "&event=" + evt	var method = "get";	if( arg == 0 || ( arg && arg != "undefined" ) )	{		method = "post";	}		//dojo.debug("sending to " + url);	dojo.io.bind({        url: url,        method: method,        content: arg || arg == 0 ? {arg:escape(arg)} : null,        load: function(type, evaldObj){ /*alert(evaldObj); eval(evaldObj) */},        mimetype: "text/javascript"    });    //dojo.debug("done.");}function AddBack(id){	 dojo.undo.browser.addToHistory({	    back: function() { Send("root","Back");},	    forward: function() { Send("root","Forward");},	    changeUrl: id	 });}function Widget( args ) //id, baseElem, className, appearEffect ){    try    {        for( var k in args )        if( (args[ k ] || args[k] == 0 ) && ! ( args[k] == '' && this[k]) )            this[ k ] = args[ k ];    if( this.elemType )    {        if( ! this.elemNS )            this.elem = document.createElement(this.elemType);        else            this.elem = document.createElementNS(this.elemNS, this.elemType);        this.elem.id = this.id;        if( this.className )        {            try            {                this.elem.className = this.className;            }            catch(e)            {                this.elem.setAttribute("class",this.className);            }        }        if( this.elemArgs ) this.SetElem(this.elemArgs);        if( this.styles ) this.SetStyle( this.styles );       }    this.args = args;    if( this.parent )    {        this.parent.AddWidget( this );        if( this.parent.OnChildAdded )            this.parent.OnChildAdded(this);    }    if( this.onDelayedMouseOver )    {        //this.elem.onmouseover = this.OnDelayedMouseOver.bindAsEventListener(this);        dojo.event.connect( this.elem, "onmouseover", this, "OnDelayedMouseOver" );    }    if( this.onReceiveDrop )    {        dojo.require("dojo.dnd.*");        this.dropTarget = new dojo.dnd.HtmlDropTarget(this.elem, ["*"]);        //this.dropTarget.onDrop = this.OnReceiveDrop.bindAsEventListener(this);        this.dropTarget.onDrop = null;        dojo.event.connect( this.dropTarget, "onDrop", this, "OnReceiveDrop" );        dojo.event.connect( this.dropTarget, "onDragOver", this, "OnDragOver" );        dojo.event.connect( this.dropTarget, "onDragOut", this, "OnDragOut" );    }    if( this.onClick )    {        dojo.event.connect( this.elem, "onclick", this, "Click" );    }    window[this.id] = this;    }    catch(e){dojo.debug("error setting up " + args.id + ": " + e.message ); }    }var Click = Widget.prototype.Click = function (evt){//    dojo.debug("click element:" + this.elem);    if( this.elem.getScreenCTM )    {        var newPoint = Svg.applyMatrix( {x:evt.clientX,y:evt.clientY}, this.elem.getScreenCTM().inverse() )        this.arg = Math.round(newPoint.x) + "," + Math.round(newPoint.y);            }    Send( this.id, this.evt?this.evt : "OnClick", this.arg );	if( evt && evt.preventBubble ) evt.preventBubble();}Widget.prototype.OnChanged = function (){	Send( this.id, this.evt?this.evt : "OnChanged", this.GetValue() );}Widget.prototype.SetElem = function(args){    for( var k in args )        this.elem.setAttribute(k, args[k]);}Widget.prototype.OnDragOver = function(){    this.elem.setAttribute("class","dropHighlight");}Widget.prototype.OnDragOut = function(){    this.elem.setAttribute("class",this.className);}Widget.prototype.MakeDragSource = function (dragArg){    dojo.require("dojo.lang");    this.dragSource = new dojo.dnd.HtmlDragSource(this.elem, "*")    this.dragSource.dragClass = "popUp";    this.dragSource.dragArg = dragArg;}Widget.prototype.OnReceiveDrop = function(evt){    Send( this.id, "OnReceiveDrop", evt.dragSource.dragArg);    this.elem.setAttribute("class",this.className);}Widget.prototype.OnDelayedMouseOver = function(evt){    this.mouseX = evt.pageX;    this.mouseY = evt.pageY;    this.timeoutid = dojo.lang.setTimeout( this, this.OnDelayReached, 200 );    dojo.event.connect( this.elem, "onmouseout", this, "OnDelayedMouseOut" );    //this.elem.onmouseout = this.OnDelayedMouseOut.bindAsEventListener(this);}Widget.prototype.OnDelayReached = function(){    Send( this.id, "OnDelayedMouseOver", this.mouseX + "," + this.mouseY );    if( this.onDelayedMouseOut )        dojo.event.connect( this.elem, "onmouseout", this, "OnDelayedMouseOutSend" );        //this.elem.onmouseout = this.OnDelayedMouseOutSend.bindAsEventListener(this);}Widget.prototype.OnDelayedMouseOut = function(){    clearTimeout( this.timeoutid );}Widget.prototype.SetRollingDelay = function( id, func, time ){    if( this[id] ) clearTimeout( this[id] );    this[id] = dojo.lang.setTimeout( this, func, time );}Widget.prototype.OnDelayedMouseOutSend = function(){   Send( this.id, "OnDelayedMouseOut", "" );}Widget.prototype.AddWidget = function( child ){    if( ! this.widgets ) { this.widgets = []; }    this.widgets[ this.widgets.length] = child;}Widget.prototype.Focus = function(){    this.elem.focus();}Widget.prototype.SetAttribute = function(attribute,value){    //dojo.debug(dojo.string.paramString( "setting %{att} to %{val} on %{widget}", {att:attribute,val:value,widget:this.id} ) );    this.elem.setAttribute( attribute, value );}Widget.prototype.SetStyle = function(pairing){    //dojo.debug(dojo.string.paramString( "setting %{att} to %{val} on %{widget}", {att:attribute,val:value,widget:this.id} ) );    for( var k in pairing )        this.elem.style[k] = pairing[k];}Widget.prototype.SetSvgStyle = function( newStyle ){    this.elem.setAttribute("style",newStyle);}var Effect = {};Widget.prototype.Render = function ( index ){    if( this.appearEffect )    {        Element.setOpacity( this.elem, 0.0 );    }    if( index >= 0 )	{		this.baseElem.insertBefore( this.elem, this.baseElem.childNodes[ index ] )	}	else	{		this.baseElem.appendChild( this.elem );	}   // new Effect.Opacity( this.id, {duration:3.0, transition: Effect.Transitions.linear, from: 0.0, to: 0.9 } );			if( this.appearEffect )	{	    if( Effect[ this.appearEffect ] )	        Effect[this.appearEffect]( this.id );	    else	        eval( this.appearEffect );	}}Widget.prototype.Show = function () {    //Effect.Appear( this.id );    this.elem.style.display = this.oldDisplay ? this.oldDisplay : "";}Widget.prototype.Hide = function () {    this.oldDisplay = this.elem.style.display;    this.elem.style.display = "none";}Widget.prototype.FadeShow = function(duration){   dojo.lfx.html.fadeShow(this.elem,duration | 2000) }Widget.prototype.FadeHide = function(duration){   dojo.lfx.html.fadeHide(this.elem,duration | 2000) }Widget.prototype.FadeOutAndIn = function(outDuration,inDuration){   _this = this;   dojo.lfx.html.fadeOut(this.elem,outDuration,function() { _this.FadeShow(inDuration); } ) }Widget.prototype.Remove = function () {    if( this.elem.parentNode )        this.elem.parentNode.removeChild( this.elem );    else if( this.elem.style )        this.elem.style.setAttribute("display","none");}function cloneObj(source){    var dest = {};    for( var k in source )    {        dest[k] = source[k];    }    return dest;}function blend(base,addin){    for( var k in addin )        base[k]=addin[k];}Widget.prototype.Clone = function (cloneArgs){    var args = cloneObj(this.args);    args.parent = null;    if( cloneArgs ) blend( args, cloneArgs );    if( ! cloneArgs || ! cloneArgs.id ) args.id += "_";    var newWidget = new this.constructor(args);    if( this.widgets )    {        for( var i = 0; i < this.widgets.length; i++ )        {            var child = this.widgets[i];            args = cloneObj(child.args);            args.parent = newWidget;            args.id = newWidget.id + "_" + child.id;            var newChild = new child.constructor(args);            newChild.baseElem = newWidget.elem;            newChild.Render();        }    }    /*    for( var k in this )    {        if( k == "elem" )        {            newWidget.elem = this.elem.cloneNode(true);            newWidget.elem.id = this.elem.id + "_";        }        else if( this[k] && this[k]["Clone"] && this[k]["Clone"].constructor == Function )        {            newWidget[k] = this[k].Clone();        }        else        {            newWidget[k] = this[k];        }    }*/    return newWidget;}var Image = function Image(args){    this.elemType = "IMG";    Widget.call(this, args);}Image.inherits( Widget );Image.prototype.SetElem_ = function(args){    if( args.src )    {        //dojo.debug(this.elem.src);        if( this.elem.src == '' )            this.elem.src = args.src;        else        {            var newImage = document.createElement("IMG");            newImage.src = args.src;            _this = this;            newImage.widget = this;            newImage.onload = function() { alert(this.widget.elem);this.widget.elem.src = this.src; this.widget.FadeShow(2000); }        }    }    else    {        this.uber("SetElem", args );    }}ImageButton.inherits( Image );function ImageButton(args){    Image.call(this,args);    //this.elem.onclick = Click.bindAsEventListener(this);    }function SetAttribute( widget, attribute, value ){    widget.SetAttribute(attribute,value);	}function getObj( o ){	var str = "";	for( var k in o )	{		try		{			dojo.debug(k + ": " + o[k]);		}		catch(e)		{		}	}	return str;}Button.inherits( Widget );function Button( args ){    this.elemType = "INPUT";    this.Widget(args);	this.elem.type = "button";	this.elem.value = this.label;	this.elem.arg = this.arg;}Button.prototype.SetText = function( html ){	//this.textNode.data = newText;	this.elem.value = html;}LinkButton.inherits( Widget );function LinkButton( args ){	this.elemType = "A";	args.onClick = 1;	this.Widget(args);	this.elem.innerHTML = args.label;	this.elem.setAttribute("href","javascript:void(1)");}LinkButton.prototype.SetText = function( html ){	this.elem.innerHTML = html;}Link.inherits(Widget);function Link( args ){	this.elemType = "A";	this.Widget(args);	this.elem.innerHTML = args.label;	this.elem.setAttribute("href",args.url);}TextBox.inherits( Widget );function TextBox( args )//id, baseElem, className, defaultValue, isPassword, isDisabled, rows, cols ){	    this.elemType = "INPUT";        if( args.isRich )    {        this.elemType = "DIV";            }	if( args.rows > 1 || args.isCodeView )	{	    this.elemType = "TEXTAREA";	}	this.Widget( args );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -