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

📄 core.web.js

📁 echo3 很炫的ajax框架技术 js 演示demo ajax j2ee 里面有jsp演示代码
💻 JS
📖 第 1 页 / 共 5 页
字号:
                // Set Content-Type, if supplied.        if (this._contentType && (usingActiveXObject || this._xmlHttpRequest.setRequestHeader)) {            this._xmlHttpRequest.setRequestHeader("Content-Type", this._contentType);        }        // Execute request.        this._xmlHttpRequest.send(this._messageObject ? this._messageObject : null);    },        /**     * Disposes of the connection.  This method must be invoked when the connection      * will no longer be used/processed.     */    dispose: function() {        this._listenerList = null;        this._messageObject = null;        this._xmlHttpRequest = null;        this._disposed = true;        this._requestHeaders = null;    },        /**     * Returns a header from the received response.     * @param {String} header the header to retrieve     */    getResponseHeader: function(header) {        return this._xmlHttpRequest ? this._xmlHttpRequest.getResponseHeader(header) : null;    },        /**     * Returns all the headers of the response.     * @param {String} header the header to retrieve     */    getAllResponseHeaders: function() {        return this._xmlHttpRequest ? this._xmlHttpRequest.getAllResponseHeaders() : null;    },        /**     * Returns the response status code of the HTTP connection, if available.     *      * @return the response status code     * @type Integer     */    getStatus: function() {        return this._xmlHttpRequest ? this._xmlHttpRequest.status : null;    },        /**     * Returns the response as text.     * This method may only be invoked from a response handler.     *     * @return the response, as text     * @type String     */    getResponseText: function() {        return this._xmlHttpRequest ? this._xmlHttpRequest.responseText : null;    },        /**     * Returns the response as an XML DOM.     * This method may only be invoked from a response handler.     *     * @return the response, as an XML DOM     * @type Document     */    getResponseXml: function() {        return this._xmlHttpRequest ? this._xmlHttpRequest.responseXML : null;    },        /**     * Event listener for <code>readystatechange</code> events received from     * the <code>XMLHttpRequest</code>.     */    _processReadyStateChange: function() {        if (this._disposed) {            return;        }                if (this._xmlHttpRequest.readyState == 4) {            var responseEvent;            try {                // 0 included as a valid response code for non-served applications.                var valid = !this._xmlHttpRequest.status ||                          (this._xmlHttpRequest.status >= 200 && this._xmlHttpRequest.status <= 299);                responseEvent = {type: "response", source: this, valid: valid};            } catch (ex) {                responseEvent = {type: "response", source: this, valid: false, exception: ex};            }                        Core.Web.Scheduler.run(Core.method(this, function() {                this._listenerList.fireEvent(responseEvent);                this.dispose();            }));        }    },        /**     * Removes a response listener to be notified when a response is received from the connection.     *      * @param {Function} l the listener to remove     */    removeResponseListener: function(l) {        this._listenerList.removeListener("response", l);    },        /**     * Sets a header in the request.     *      * @param {String} header the header to retrieve     * @param {String} value the value of the header     */    setRequestHeader: function(header, value) {        if (!this._requestHeaders) {            this._requestHeaders = { };        }         this._requestHeaders[header] = value;    }});/** * Image-related utilities. * @class */Core.Web.Image = {        /**     * Work object for monitorImageLoading() method.     */    _Monitor: Core.extend({        /** Reference to _processImageLoad method. */        _processImageLoadRef: null,                /** Currently enqueued runnable. */        _queuedRunnable: null,                /** Listener to notify of successful image loadings. */        _listener: null,                /** Minimum Listener callback interval. */        _interval: null,                /** The number of images to be loaded. */        _count: 0,                /**         * Creates a new image monitor.         *          * @param {Element} element the root element which may (or may not) contain IMG elements         * @param {Function} listener the method to invoke when images are loaded         * @param {Number} interval the minimum time interval at which to notify the listener of successfully loaded images         */        $construct: function(element, listener, interval) {            this._listener = listener;            this._interval = interval || 2000;            this._processImageLoadRef = Core.method(this, this._processImageLoad);            var imgs = element.getElementsByTagName("img");            this._count = imgs.length;            for (var i = 0; i < this._count; ++i) {                if (!imgs[i].complete && (Core.Web.Env.QUIRK_UNLOADED_IMAGE_HAS_SIZE ||                         (!imgs[i].height && !imgs[i].style.height))) {                    Core.Web.DOM.addEventListener(imgs[i], "load", this._processImageLoadRef, false);                }            }        },                /**         * Process an image loading event.         *          * @param e the event object         */        _processImageLoad: function(e) {            e = e ? e : window.event;            Core.Web.DOM.removeEventListener(Core.Web.DOM.getEventTarget(e), "load", this._processImageLoadRef, false);            --this._count;                        if (this._queuedRunnable && this._count === 0) {                Core.Web.Scheduler.remove(this._queuedRunnable);                this._queuedRunnable = null;            }                        if (!this._queuedRunnable) {                this._queuedRunnable = Core.Web.Scheduler.run(Core.method(this, function() {                    this._queuedRunnable = null;                    this._listener();                }), this._count === 0 ? 0 : this._interval);            }        }    }),        /**     * Registers a listener to receive notifications as image size information becomes available.     * Registers "load" listeners on images which are children of the specified element, invoking the specified listener     * zero or more times as the images load.  If all images are already loaded (e.g., they were cached) or have specified      * sizes, the listener may never be invoked.  If the images take some time to load, the listener may be invoked multiple times.     *      * @param {Element} element the root element which may (or may not) contain IMG elements     * @param {Function} l the method to invoke when images are loaded.     * @param {Number} interval the maximum time interval at which the listener should be invoked (default value is 50ms,      *        the listener will be invoked immediately once all images have loaded)     */    monitor: function(element, l, interval) {        var monitor = new Core.Web.Image._Monitor(element, l, interval);    }};/** * Utilities for dynamically loading additional script libraries. * @class */Core.Web.Library = {    /**     * Set of loaded libraries (keys are library urls, value is true when library has been loaded).     */    _loadedLibraries: { },        /**     * A representation of a group of libraries to be loaded at the same time.     * Libraries will be retrieved asynchronously, and then installed once ALL the libraries have     * been retrieved.  Installation will be done in the order in which the add() method was     * invoked to add libraries to the group (without regard for the order in which the      * HTTP server returns the library code).     */    Group: Core.extend({            /** Listener storage. */        _listenerList: null,                /**         * Array of libraries to be loaded.         * @type Array         */        _libraries: null,                /** Number of libraries which have been loaded. */        _loadedCount: 0,                /** Number of libraries to load. */        _totalCount: 0,            /**         * Creates a new library group.         * @constructor          */        $construct: function() {            this._listenerList = new Core.ListenerList();            this._libraries = [];        },                /**         * Adds a library to the library group.         * Libraries which have previously been loaded will not be loaded again.         *         * @param {String} libraryUrl the URL from which to retrieve the library.         */        add: function(libraryUrl) {            if (Core.Web.Library._loadedLibraries[libraryUrl]) {                // Library already loaded: ignore.                return;            }                        var libraryItem = new Core.Web.Library._Item(this, libraryUrl);            this._libraries.push(libraryItem);        },                /**         * Adds a listener to be notified when all libraries in the group have been loaded.         *         * @param {Function} l the listener to add         */        addLoadListener: function(l) {            this._listenerList.addListener("load", l);        },                /**         * Notifies listeners of completed library loading.         */        _fireLoadEvent: function() {            this._listenerList.fireEvent({type: "load", source: this});        },                /**         * Determines if this library group contains any new (not previously loaded)         * libraries.         *          * @return true if any new libraries exist         * @type Boolean         */        hasNewLibraries: function() {            return this._libraries.length > 0;        },                /**         * Installs all libraries in the group.         * This method is invoked once all libraries have been successfully         * retrieved.  It will invoke any registered load listeners         * once the libraries have been installed.         */        _install: function() {            for (var i = 0; i < this._libraries.length; ++i) {                try {                    this._libraries[i]._install();                } catch (ex) {                    throw new Error("Exception installing library \"" + this._libraries[i]._url + "\"; " + ex);                }            }            this._fireLoadEvent();        },                /**         * Event listener invoked when a single library has been successfully retrieved.         * When all libraries have been retrieved, this method will invoke _install().         */        _notifyRetrieved: function() {            ++this._loadedCount;            if (this._loadedCount == this._totalCount) {                this._install();            }        },                /**         * Initializes library loading.  When this method is invoked         * the libraries will be asynchronously loaded.  This method         * will return before the libraries have been loaded.         * Once this method has been invoked, add() may no longer         * be invoked.         */        load: function() {            this._totalCount = this._libraries.length;            for (var i = 0; i < this._libraries.length; ++i) {                this._libraries[i]._retrieve();            }        },                /**         * Removes a listener from being notified when all libraries in the group have been loaded.         *         * @param {Function} l the listener to remove         */        removeLoadListener: function(l) {            this._listenerList.removeListener("load", l);        }

⌨️ 快捷键说明

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