| // Contents of jquery.js |
| |
| /*! |
| * jQuery JavaScript Library v1.3.2 |
| * |
| * Copyright (c) 2009 John Resig, http://jquery.com/ |
| * |
| * Permission is hereby granted, free of charge, to any person obtaining |
| * a copy of this software and associated documentation files (the |
| * "Software"), to deal in the Software without restriction, including |
| * without limitation the rights to use, copy, modify, merge, publish, |
| * distribute, sublicense, and/or sell copies of the Software, and to |
| * permit persons to whom the Software is furnished to do so, subject to |
| * the following conditions: |
| * |
| * The above copyright notice and this permission notice shall be |
| * included in all copies or substantial portions of the Software. |
| * |
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| * |
| * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009) |
| * Revision: 6246 |
| */ |
| |
| |
| //jquery.js |
| (function(){ |
| var |
| // Will speed up references to window, and allows munging its name. |
| window = this, |
| // Will speed up references to undefined, and allows munging its name. |
| undefined, |
| // Map over jQuery in case of overwrite |
| _jQuery = window.jQuery, |
| // Map over the $ in case of overwrite |
| _$ = window.$, |
| |
| jQuery = window.jQuery = window.$ = function( selector, context ) { |
| // The jQuery object is actually just the init constructor 'enhanced' |
| return new jQuery.fn.init( selector, context ); |
| }, |
| |
| // A simple way to check for HTML strings or ID strings |
| // (both of which we optimize for) |
| quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/, |
| // Is it a simple selector |
| isSimple = /^.[^:#\[\.,]*$/; |
| |
| jQuery.fn = jQuery.prototype = { |
| init: function( selector, context ) { |
| // Make sure that a selection was provided |
| selector = selector || document; |
| |
| // Handle $(DOMElement) |
| if ( selector.nodeType ) { |
| this[0] = selector; |
| this.length = 1; |
| this.context = selector; |
| return this; |
| } |
| // Handle HTML strings |
| if ( typeof selector === "string" ) { |
| // Are we dealing with HTML string or an ID? |
| var match = quickExpr.exec( selector ); |
| |
| // Verify a match, and that no context was specified for #id |
| if ( match && (match[1] || !context) ) { |
| |
| // HANDLE: $(html) -> $(array) |
| if ( match[1] ) |
| selector = jQuery.clean( [ match[1] ], context ); |
| |
| // HANDLE: $("#id") |
| else { |
| var elem = document.getElementById( match[3] ); |
| |
| // Handle the case where IE and Opera return items |
| // by name instead of ID |
| if ( elem && elem.id != match[3] ) |
| return jQuery().find( selector ); |
| |
| // Otherwise, we inject the element directly into the jQuery object |
| var ret = jQuery( elem || [] ); |
| ret.context = document; |
| ret.selector = selector; |
| return ret; |
| } |
| |
| // HANDLE: $(expr, [context]) |
| // (which is just equivalent to: $(content).find(expr) |
| } else |
| return jQuery( context ).find( selector ); |
| |
| // HANDLE: $(function) |
| // Shortcut for document ready |
| } else if ( jQuery.isFunction( selector ) ) |
| return jQuery( document ).ready( selector ); |
| |
| // Make sure that old selector state is passed along |
| if ( selector.selector && selector.context ) { |
| this.selector = selector.selector; |
| this.context = selector.context; |
| } |
| |
| return this.setArray(jQuery.isArray( selector ) ? |
| selector : |
| jQuery.makeArray(selector)); |
| }, |
| |
| // Start with an empty selector |
| selector: "", |
| |
| // The current version of jQuery being used |
| jquery: "1.3.2", |
| |
| // The number of elements contained in the matched element set |
| size: function() { |
| return this.length; |
| }, |
| |
| // Get the Nth element in the matched element set OR |
| // Get the whole matched element set as a clean array |
| get: function( num ) { |
| return num === undefined ? |
| |
| // Return a 'clean' array |
| Array.prototype.slice.call( this ) : |
| |
| // Return just the object |
| this[ num ]; |
| }, |
| |
| // Take an array of elements and push it onto the stack |
| // (returning the new matched element set) |
| pushStack: function( elems, name, selector ) { |
| // Build a new jQuery matched element set |
| var ret = jQuery( elems ); |
| |
| // Add the old object onto the stack (as a reference) |
| ret.prevObject = this; |
| |
| ret.context = this.context; |
| |
| if ( name === "find" ) |
| ret.selector = this.selector + (this.selector ? " " : "") + selector; |
| else if ( name ) |
| ret.selector = this.selector + "." + name + "(" + selector + ")"; |
| |
| // Return the newly-formed element set |
| return ret; |
| }, |
| |
| // Force the current matched set of elements to become |
| // the specified array of elements (destroying the stack in the process) |
| // You should use pushStack() in order to do this, but maintain the stack |
| setArray: function( elems ) { |
| // Resetting the length to 0, then using the native Array push |
| // is a super-fast way to populate an object with array-like properties |
| this.length = 0; |
| Array.prototype.push.apply( this, elems ); |
| |
| return this; |
| }, |
| |
| // Execute a callback for every element in the matched set. |
| // (You can seed the arguments with an array of args, but this is |
| // only used internally.) |
| each: function( callback, args ) { |
| return jQuery.each( this, callback, args ); |
| }, |
| |
| // Determine the position of an element within |
| // the matched set of elements |
| index: function( elem ) { |
| // Locate the position of the desired element |
| return jQuery.inArray( |
| // If it receives a jQuery object, the first element is used |
| elem && elem.jquery ? elem[0] : elem |
| , this ); |
| }, |
| |
| attr: function( name, value, type ) { |
| var options = name; |
| |
| // Look for the case where we're accessing a style value |
| if ( typeof name === "string" ) |
| if ( value === undefined ) |
| return this[0] && jQuery[ type || "attr" ]( this[0], name ); |
| |
| else { |
| options = {}; |
| options[ name ] = value; |
| } |
| |
| // Check to see if we're setting style values |
| return this.each(function(i){ |
| // Set all the styles |
| for ( name in options ) |
| jQuery.attr( |
| type ? |
| this.style : |
| this, |
| name, jQuery.prop( this, options[ name ], type, i, name ) |
| ); |
| }); |
| }, |
| |
| css: function( key, value ) { |
| // ignore negative width and height values |
| if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 ) |
| value = undefined; |
| return this.attr( key, value, "curCSS" ); |
| }, |
| |
| text: function( text ) { |
| if ( typeof text !== "object" && text != null ) |
| return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
| |
| var ret = ""; |
| |
| jQuery.each( text || this, function(){ |
| jQuery.each( this.childNodes, function(){ |
| if ( this.nodeType != 8 ) |
| ret += this.nodeType != 1 ? |
| this.nodeValue : |
| jQuery.fn.text( [ this ] ); |
| }); |
| }); |
| |
| return ret; |
| }, |
| |
| wrapAll: function( html ) { |
| if ( this[0] ) { |
| // The elements to wrap the target around |
| var wrap = jQuery( html, this[0].ownerDocument ).clone(); |
| |
| if ( this[0].parentNode ) |
| wrap.insertBefore( this[0] ); |
| |
| wrap.map(function(){ |
| var elem = this; |
| |
| while ( elem.firstChild ) |
| elem = elem.firstChild; |
| |
| return elem; |
| }).append(this); |
| } |
| |
| return this; |
| }, |
| |
| wrapInner: function( html ) { |
| return this.each(function(){ |
| jQuery( this ).contents().wrapAll( html ); |
| }); |
| }, |
| |
| wrap: function( html ) { |
| return this.each(function(){ |
| jQuery( this ).wrapAll( html ); |
| }); |
| }, |
| |
| append: function() { |
| return this.domManip(arguments, true, function(elem){ |
| if (this.nodeType == 1) |
| this.appendChild( elem ); |
| }); |
| }, |
| |
| prepend: function() { |
| return this.domManip(arguments, true, function(elem){ |
| if (this.nodeType == 1) |
| this.insertBefore( elem, this.firstChild ); |
| }); |
| }, |
| |
| before: function() { |
| return this.domManip(arguments, false, function(elem){ |
| this.parentNode.insertBefore( elem, this ); |
| }); |
| }, |
| |
| after: function() { |
| return this.domManip(arguments, false, function(elem){ |
| this.parentNode.insertBefore( elem, this.nextSibling ); |
| }); |
| }, |
| |
| end: function() { |
| return this.prevObject || jQuery( [] ); |
| }, |
| |
| // For internal use only. |
| // Behaves like an Array's method, not like a jQuery method. |
| push: [].push, |
| sort: [].sort, |
| splice: [].splice, |
| |
| find: function( selector ) { |
| if ( this.length === 1 ) { |
| var ret = this.pushStack( [], "find", selector ); |
| ret.length = 0; |
| jQuery.find( selector, this[0], ret ); |
| return ret; |
| } else { |
| return this.pushStack( jQuery.unique(jQuery.map(this, function(elem){ |
| return jQuery.find( selector, elem ); |
| })), "find", selector ); |
| } |
| }, |
| |
| clone: function( events ) { |
| // Do the clone |
| var ret = this.map(function(){ |
| if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { |
| // IE copies events bound via attachEvent when |
| // using cloneNode. Calling detachEvent on the |
| // clone will also remove the events from the orignal |
| // In order to get around this, we use innerHTML. |
| // Unfortunately, this means some modifications to |
| // attributes in IE that are actually only stored |
| // as properties will not be copied (such as the |
| // the name attribute on an input). |
| var html = this.outerHTML; |
| if ( !html ) { |
| var div = this.ownerDocument.createElement("div"); |
| div.appendChild( this.cloneNode(true) ); |
| html = div.innerHTML; |
| } |
| |
| return jQuery.clean([html.replace(/ jQuery\d+="(?:\d+|null)"/g, "").replace(/^\s*/, "")])[0]; |
| } else |
| return this.cloneNode(true); |
| }); |
| |
| // Copy the events from the original to the clone |
| if ( events === true ) { |
| var orig = this.find("*").andSelf(), i = 0; |
| |
| ret.find("*").andSelf().each(function(){ |
| if ( this.nodeName !== orig[i].nodeName ) |
| return; |
| |
| var events = jQuery.data( orig[i], "events" ); |
| |
| for ( var type in events ) { |
| for ( var handler in events[ type ] ) { |
| jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); |
| } |
| } |
| |
| i++; |
| }); |
| } |
| |
| // Return the cloned set |
| return ret; |
| }, |
| |
| filter: function( selector ) { |
| return this.pushStack( |
| jQuery.isFunction( selector ) && |
| jQuery.grep(this, function(elem, i){ |
| return selector.call( elem, i ); |
| }) || |
| |
| jQuery.multiFilter( selector, jQuery.grep(this, function(elem){ |
| return elem.nodeType === 1; |
| }) ), "filter", selector ); |
| }, |
| |
| closest: function( selector ) { |
| var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, |
| closer = 0; |
| |
| return this.map(function(){ |
| var cur = this; |
| while ( cur && cur.ownerDocument ) { |
| if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { |
| jQuery.data(cur, "closest", closer); |
| return cur; |
| } |
| cur = cur.parentNode; |
| closer++; |
| } |
| }); |
| }, |
| |
| not: function( selector ) { |
| if ( typeof selector === "string" ) |
| // test special case where just one selector is passed in |
| if ( isSimple.test( selector ) ) |
| return this.pushStack( jQuery.multiFilter( selector, this, true ), "not", selector ); |
| else |
| selector = jQuery.multiFilter( selector, this ); |
| |
| var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; |
| return this.filter(function() { |
| return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; |
| }); |
| }, |
| |
| add: function( selector ) { |
| return this.pushStack( jQuery.unique( jQuery.merge( |
| this.get(), |
| typeof selector === "string" ? |
| jQuery( selector ) : |
| jQuery.makeArray( selector ) |
| ))); |
| }, |
| |
| is: function( selector ) { |
| return !!selector && jQuery.multiFilter( selector, this ).length > 0; |
| }, |
| |
| hasClass: function( selector ) { |
| return !!selector && this.is( "." + selector ); |
| }, |
| |
| val: function( value ) { |
| if ( value === undefined ) { |
| var elem = this[0]; |
| |
| if ( elem ) { |
| if( jQuery.nodeName( elem, 'option' ) ) |
| return (elem.attributes.value || {}).specified ? elem.value : elem.text; |
| |
| // We need to handle select boxes special |
| if ( jQuery.nodeName( elem, "select" ) ) { |
| var index = elem.selectedIndex, |
| values = [], |
| options = elem.options, |
| one = elem.type == "select-one"; |
| |
| // Nothing was selected |
| if ( index < 0 ) |
| return null; |
| |
| // Loop through all the selected options |
| for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
| var option = options[ i ]; |
| |
| if ( option.selected ) { |
| // Get the specifc value for the option |
| value = jQuery(option).val(); |
| |
| // We don't need an array for one selects |
| if ( one ) |
| return value; |
| |
| // Multi-Selects return an array |
| values.push( value ); |
| } |
| } |
| |
| return values; |
| } |
| |
| // Everything else, we just grab the value |
| return (elem.value || "").replace(/\r/g, ""); |
| |
| } |
| |
| return undefined; |
| } |
| |
| if ( typeof value === "number" ) |
| value += ''; |
| |
| return this.each(function(){ |
| if ( this.nodeType != 1 ) |
| return; |
| |
| if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) ) |
| this.checked = (jQuery.inArray(this.value, value) >= 0 || |
| jQuery.inArray(this.name, value) >= 0); |
| |
| else if ( jQuery.nodeName( this, "select" ) ) { |
| var values = jQuery.makeArray(value); |
| |
| jQuery( "option", this ).each(function(){ |
| this.selected = (jQuery.inArray( this.value, values ) >= 0 || |
| jQuery.inArray( this.text, values ) >= 0); |
| }); |
| |
| if ( !values.length ) |
| this.selectedIndex = -1; |
| |
| } else |
| this.value = value; |
| }); |
| }, |
| |
| html: function( value ) { |
| return value === undefined ? |
| (this[0] ? |
| this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g, "") : |
| null) : |
| this.empty().append( value ); |
| }, |
| |
| replaceWith: function( value ) { |
| return this.after( value ).remove(); |
| }, |
| |
| eq: function( i ) { |
| return this.slice( i, +i + 1 ); |
| }, |
| |
| slice: function() { |
| return this.pushStack( Array.prototype.slice.apply( this, arguments ), |
| "slice", Array.prototype.slice.call(arguments).join(",") ); |
| }, |
| |
| map: function( callback ) { |
| return this.pushStack( jQuery.map(this, function(elem, i){ |
| return callback.call( elem, i, elem ); |
| })); |
| }, |
| |
| andSelf: function() { |
| return this.add( this.prevObject ); |
| }, |
| |
| domManip: function( args, table, callback ) { |
| if ( this[0] ) { |
| var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(), |
| scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ), |
| first = fragment.firstChild; |
| |
| if ( first ) |
| for ( var i = 0, l = this.length; i < l; i++ ) |
| callback.call( root(this[i], first), this.length > 1 || i > 0 ? |
| fragment.cloneNode(true) : fragment ); |
| |
| if ( scripts ) |
| jQuery.each( scripts, evalScript ); |
| } |
| |
| return this; |
| |
| function root( elem, cur ) { |
| return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ? |
| (elem.getElementsByTagName("tbody")[0] || |
| elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
| elem; |
| } |
| } |
| }; |
| |
| // Give the init function the jQuery prototype for later instantiation |
| jQuery.fn.init.prototype = jQuery.fn; |
| |
| function evalScript( i, elem ) { |
| if ( elem.src ) |
| jQuery.ajax({ |
| url: elem.src, |
| async: false, |
| dataType: "script" |
| }); |
| |
| else |
| jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
| |
| if ( elem.parentNode ) |
| elem.parentNode.removeChild( elem ); |
| } |
| |
| function now(){ |
| return +new Date; |
| } |
| |
| jQuery.extend = jQuery.fn.extend = function() { |
| // copy reference to target object |
| var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; |
| |
| // Handle a deep copy situation |
| if ( typeof target === "boolean" ) { |
| deep = target; |
| target = arguments[1] || {}; |
| // skip the boolean and the target |
| i = 2; |
| } |
| |
| // Handle case when target is a string or something (possible in deep copy) |
| if ( typeof target !== "object" && !jQuery.isFunction(target) ) |
| target = {}; |
| |
| // extend jQuery itself if only one argument is passed |
| if ( length == i ) { |
| target = this; |
| --i; |
| } |
| |
| for ( ; i < length; i++ ) |
| // Only deal with non-null/undefined values |
| if ( (options = arguments[ i ]) != null ) |
| // Extend the base object |
| for ( var name in options ) { |
| var src = target[ name ], copy = options[ name ]; |
| |
| // Prevent never-ending loop |
| if ( target === copy ) |
| continue; |
| |
| // Recurse if we're merging object values |
| if ( deep && copy && typeof copy === "object" && !copy.nodeType ) |
| target[ name ] = jQuery.extend( deep, |
| // Never move original objects, clone them |
| src || ( copy.length != null ? [ ] : { } ) |
| , copy ); |
| |
| // Don't bring in undefined values |
| else if ( copy !== undefined ) |
| target[ name ] = copy; |
| |
| } |
| |
| // Return the modified object |
| return target; |
| }; |
| |
| // exclude the following css properties to add px |
| var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
| // cache defaultView |
| defaultView = document.defaultView || {}, |
| toString = Object.prototype.toString; |
| |
| jQuery.extend({ |
| noConflict: function( deep ) { |
| window.$ = _$; |
| |
| if ( deep ) |
| window.jQuery = _jQuery; |
| |
| return jQuery; |
| }, |
| |
| // See test/unit/core.js for details concerning isFunction. |
| // Since version 1.3, DOM methods and functions like alert |
| // aren't supported. They return false on IE (#2968). |
| isFunction: function( obj ) { |
| return toString.call(obj) === "[object Function]"; |
| }, |
| |
| isArray: function( obj ) { |
| return toString.call(obj) === "[object Array]"; |
| }, |
| |
| // check if an element is in a (or is an) XML document |
| isXMLDoc: function( elem ) { |
| return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || |
| !!elem.ownerDocument && jQuery.isXMLDoc( elem.ownerDocument ); |
| }, |
| |
| // Evalulates a script in a global context |
| globalEval: function( data ) { |
| if ( data && /\S/.test(data) ) { |
| // Inspired by code by Andrea Giammarchi |
| // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html |
| var head = document.getElementsByTagName("head")[0] || document.documentElement, |
| script = document.createElement("script"); |
| |
| script.type = "text/javascript"; |
| if ( jQuery.support.scriptEval ) |
| script.appendChild( document.createTextNode( data ) ); |
| else |
| script.text = data; |
| |
| // Use insertBefore instead of appendChild to circumvent an IE6 bug. |
| // This arises when a base node is used (#2709). |
| head.insertBefore( script, head.firstChild ); |
| head.removeChild( script ); |
| } |
| }, |
| |
| nodeName: function( elem, name ) { |
| return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); |
| }, |
| |
| // args is for internal usage only |
| each: function( object, callback, args ) { |
| var name, i = 0, length = object.length; |
| |
| if ( args ) { |
| if ( length === undefined ) { |
| for ( name in object ) |
| if ( callback.apply( object[ name ], args ) === false ) |
| break; |
| } else |
| for ( ; i < length; ) |
| if ( callback.apply( object[ i++ ], args ) === false ) |
| break; |
| |
| // A special, fast, case for the most common use of each |
| } else { |
| if ( length === undefined ) { |
| for ( name in object ) |
| if ( callback.call( object[ name ], name, object[ name ] ) === false ) |
| break; |
| } else |
| for ( var value = object[0]; |
| i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} |
| } |
| |
| return object; |
| }, |
| |
| prop: function( elem, value, type, i, name ) { |
| // Handle executable functions |
| if ( jQuery.isFunction( value ) ) |
| value = value.call( elem, i ); |
| |
| // Handle passing in a number to a CSS property |
| return typeof value === "number" && type == "curCSS" && !exclude.test( name ) ? |
| value + "px" : |
| value; |
| }, |
| |
| className: { |
| // internal only, use addClass("class") |
| add: function( elem, classNames ) { |
| jQuery.each((classNames || "").split(/\s+/), function(i, className){ |
| if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) |
| elem.className += (elem.className ? " " : "") + className; |
| }); |
| }, |
| |
| // internal only, use removeClass("class") |
| remove: function( elem, classNames ) { |
| if (elem.nodeType == 1) |
| elem.className = classNames !== undefined ? |
| jQuery.grep(elem.className.split(/\s+/), function(className){ |
| return !jQuery.className.has( classNames, className ); |
| }).join(" ") : |
| ""; |
| }, |
| |
| // internal only, use hasClass("class") |
| has: function( elem, className ) { |
| return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; |
| } |
| }, |
| |
| // A method for quickly swapping in/out CSS properties to get correct calculations |
| swap: function( elem, options, callback ) { |
| var old = {}; |
| // Remember the old values, and insert the new ones |
| for ( var name in options ) { |
| old[ name ] = elem.style[ name ]; |
| elem.style[ name ] = options[ name ]; |
| } |
| |
| callback.call( elem ); |
| |
| // Revert the old values |
| for ( var name in options ) |
| elem.style[ name ] = old[ name ]; |
| }, |
| |
| css: function( elem, name, force, extra ) { |
| if ( name == "width" || name == "height" ) { |
| var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; |
| |
| function getWH() { |
| val = name == "width" ? elem.offsetWidth : elem.offsetHeight; |
| |
| if ( extra === "border" ) |
| return; |
| |
| jQuery.each( which, function() { |
| if ( !extra ) |
| val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; |
| if ( extra === "margin" ) |
| val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; |
| else |
| val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; |
| }); |
| } |
| |
| if ( elem.offsetWidth !== 0 ) |
| getWH(); |
| else |
| jQuery.swap( elem, props, getWH ); |
| |
| return Math.max(0, Math.round(val)); |
| } |
| |
| return jQuery.curCSS( elem, name, force ); |
| }, |
| |
| curCSS: function( elem, name, force ) { |
| var ret, style = elem.style; |
| |
| // We need to handle opacity special in IE |
| if ( name == "opacity" && !jQuery.support.opacity ) { |
| ret = jQuery.attr( style, "opacity" ); |
| |
| return ret == "" ? |
| "1" : |
| ret; |
| } |
| |
| // Make sure we're using the right name for getting the float value |
| if ( name.match( /float/i ) ) |
| name = styleFloat; |
| |
| if ( !force && style && style[ name ] ) |
| ret = style[ name ]; |
| |
| else if ( defaultView.getComputedStyle ) { |
| |
| // Only "float" is needed here |
| if ( name.match( /float/i ) ) |
| name = "float"; |
| |
| name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); |
| |
| var computedStyle = defaultView.getComputedStyle( elem, null ); |
| |
| if ( computedStyle ) |
| ret = computedStyle.getPropertyValue( name ); |
| |
| // We should always get a number back from opacity |
| if ( name == "opacity" && ret == "" ) |
| ret = "1"; |
| |
| } else if ( elem.currentStyle ) { |
| var camelCase = name.replace(/\-(\w)/g, function(all, letter){ |
| return letter.toUpperCase(); |
| }); |
| |
| ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; |
| |
| // From the awesome hack by Dean Edwards |
| // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 |
| |
| // If we're not dealing with a regular pixel number |
| // but a number that has a weird ending, we need to convert it to pixels |
| if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { |
| // Remember the original values |
| var left = style.left, rsLeft = elem.runtimeStyle.left; |
| |
| // Put in the new values to get a computed value out |
| elem.runtimeStyle.left = elem.currentStyle.left; |
| style.left = ret || 0; |
| ret = style.pixelLeft + "px"; |
| |
| // Revert the changed values |
| style.left = left; |
| elem.runtimeStyle.left = rsLeft; |
| } |
| } |
| |
| return ret; |
| }, |
| |
| clean: function( elems, context, fragment ) { |
| context = context || document; |
| |
| // !context.createElement fails in IE with an error but returns typeof 'object' |
| if ( typeof context.createElement === "undefined" ) |
| context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
| |
| // If a single string is passed in and it's a single tag |
| // just do a createElement and skip the rest |
| if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) { |
| var match = /^<(\w+)\s*\/?>$/.exec(elems[0]); |
| if ( match ) |
| return [ context.createElement( match[1] ) ]; |
| } |
| |
| var ret = [], scripts = [], div = context.createElement("div"); |
| |
| jQuery.each(elems, function(i, elem){ |
| if ( typeof elem === "number" ) |
| elem += ''; |
| |
| if ( !elem ) |
| return; |
| |
| // Convert html string into DOM nodes |
| if ( typeof elem === "string" ) { |
| // Fix "XHTML"-style tags in all browsers |
| elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ |
| return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ? |
| all : |
| front + "></" + tag + ">"; |
| }); |
| |
| // Trim whitespace, otherwise indexOf won't work as expected |
| var tags = elem.replace(/^\s+/, "").substring(0, 10).toLowerCase(); |
| |
| var wrap = |
| // option or optgroup |
| !tags.indexOf("<opt") && |
| [ 1, "<select multiple='multiple'>", "</select>" ] || |
| |
| !tags.indexOf("<leg") && |
| [ 1, "<fieldset>", "</fieldset>" ] || |
| |
| tags.match(/^<(thead|tbody|tfoot|colg|cap)/) && |
| [ 1, "<table>", "</table>" ] || |
| |
| !tags.indexOf("<tr") && |
| [ 2, "<table><tbody>", "</tbody></table>" ] || |
| |
| // <thead> matched above |
| (!tags.indexOf("<td") || !tags.indexOf("<th")) && |
| [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] || |
| |
| !tags.indexOf("<col") && |
| [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] || |
| |
| // IE can't serialize <link> and <script> tags normally |
| !jQuery.support.htmlSerialize && |
| [ 1, "div<div>", "</div>" ] || |
| |
| [ 0, "", "" ]; |
| |
| // Go to html and back, then peel off extra wrappers |
| div.innerHTML = wrap[1] + elem + wrap[2]; |
| |
| // Move to the right depth |
| while ( wrap[0]-- ) |
| div = div.lastChild; |
| |
| // Remove IE's autoinserted <tbody> from table fragments |
| if ( !jQuery.support.tbody ) { |
| |
| // String was a <table>, *may* have spurious <tbody> |
| var hasBody = /<tbody/i.test(elem), |
| tbody = !tags.indexOf("<table") && !hasBody ? |
| div.firstChild && div.firstChild.childNodes : |
| |
| // String was a bare <thead> or <tfoot> |
| wrap[1] == "<table>" && !hasBody ? |
| div.childNodes : |
| []; |
| |
| for ( var j = tbody.length - 1; j >= 0 ; --j ) |
| if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) |
| tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
| |
| } |
| |
| // IE completely kills leading whitespace when innerHTML is used |
| if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) ) |
| div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild ); |
| |
| elem = jQuery.makeArray( div.childNodes ); |
| } |
| |
| if ( elem.nodeType ) |
| ret.push( elem ); |
| else |
| ret = jQuery.merge( ret, elem ); |
| |
| }); |
| |
| if ( fragment ) { |
| for ( var i = 0; ret[i]; i++ ) { |
| if ( jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
| scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
| } else { |
| if ( ret[i].nodeType === 1 ) |
| ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
| fragment.appendChild( ret[i] ); |
| } |
| } |
| |
| return scripts; |
| } |
| |
| return ret; |
| }, |
| |
| attr: function( elem, name, value ) { |
| // don't set attributes on text and comment nodes |
| if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
| return undefined; |
| |
| var notxml = !jQuery.isXMLDoc( elem ), |
| // Whether we are setting (or getting) |
| set = value !== undefined; |
| |
| // Try to normalize/fix the name |
| name = notxml && jQuery.props[ name ] || name; |
| |
| // Only do all the following if this is a node (faster for style) |
| // IE elem.getAttribute passes even for style |
| if ( elem.tagName ) { |
| |
| // These attributes require special treatment |
| var special = /href|src|style/.test( name ); |
| |
| // Safari mis-reports the default selected property of a hidden option |
| // Accessing the parent's selectedIndex property fixes it |
| if ( name == "selected" && elem.parentNode ) |
| elem.parentNode.selectedIndex; |
| |
| // If applicable, access the attribute via the DOM 0 way |
| if ( name in elem && notxml && !special ) { |
| if ( set ){ |
| // We can't allow the type property to be changed (since it causes problems in IE) |
| if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode ) |
| throw "type property can't be changed"; |
| |
| elem[ name ] = value; |
| } |
| |
| // browsers index elements by id/name on forms, give priority to attributes. |
| if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) |
| return elem.getAttributeNode( name ).nodeValue; |
| |
| // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set |
| // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ |
| if ( name == "tabIndex" ) { |
| var attributeNode = elem.getAttributeNode( "tabIndex" ); |
| return attributeNode && attributeNode.specified |
| ? attributeNode.value |
| : elem.nodeName.match(/(button|input|object|select|textarea)/i) |
| ? 0 |
| : elem.nodeName.match(/^(a|area)$/i) && elem.href |
| ? 0 |
| : undefined; |
| } |
| |
| return elem[ name ]; |
| } |
| |
| if ( !jQuery.support.style && notxml && name == "style" ) |
| return jQuery.attr( elem.style, "cssText", value ); |
| |
| if ( set ) |
| // convert the value to a string (all browsers do this but IE) see #1070 |
| elem.setAttribute( name, "" + value ); |
| |
| var attr = !jQuery.support.hrefNormalized && notxml && special |
| // Some attributes require a special call on IE |
| ? elem.getAttribute( name, 2 ) |
| : elem.getAttribute( name ); |
| |
| // Non-existent attributes return null, we normalize to undefined |
| return attr === null ? undefined : attr; |
| } |
| |
| // elem is actually elem.style ... set the style |
| |
| // IE uses filters for opacity |
| if ( !jQuery.support.opacity && name == "opacity" ) { |
| if ( set ) { |
| // IE has trouble with opacity if it does not have layout |
| // Force it by setting the zoom level |
| elem.zoom = 1; |
| |
| // Set the alpha filter to set the opacity |
| elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) + |
| (parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"); |
| } |
| |
| return elem.filter && elem.filter.indexOf("opacity=") >= 0 ? |
| (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '': |
| ""; |
| } |
| |
| name = name.replace(/-([a-z])/ig, function(all, letter){ |
| return letter.toUpperCase(); |
| }); |
| |
| if ( set ) |
| elem[ name ] = value; |
| |
| return elem[ name ]; |
| }, |
| |
| trim: function( text ) { |
| return (text || "").replace( /^\s+|\s+$/g, "" ); |
| }, |
| |
| makeArray: function( array ) { |
| var ret = []; |
| |
| if( array != null ){ |
| var i = array.length; |
| // The window, strings (and functions) also have 'length' |
| if( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval ) |
| ret[0] = array; |
| else |
| while( i ) |
| ret[--i] = array[i]; |
| } |
| |
| return ret; |
| }, |
| |
| inArray: function( elem, array ) { |
| for ( var i = 0, length = array.length; i < length; i++ ) |
| // Use === because on IE, window == document |
| if ( array[ i ] === elem ) |
| return i; |
| |
| return -1; |
| }, |
| |
| merge: function( first, second ) { |
| // We have to loop this way because IE & Opera overwrite the length |
| // expando of getElementsByTagName |
| var i = 0, elem, pos = first.length; |
| // Also, we need to make sure that the correct elements are being returned |
| // (IE returns comment nodes in a '*' query) |
| if ( !jQuery.support.getAll ) { |
| while ( (elem = second[ i++ ]) != null ) |
| if ( elem.nodeType != 8 ) |
| first[ pos++ ] = elem; |
| |
| } else |
| while ( (elem = second[ i++ ]) != null ) |
| first[ pos++ ] = elem; |
| |
| return first; |
| }, |
| |
| unique: function( array ) { |
| var ret = [], done = {}; |
| |
| try { |
| |
| for ( var i = 0, length = array.length; i < length; i++ ) { |
| var id = jQuery.data( array[ i ] ); |
| |
| if ( !done[ id ] ) { |
| done[ id ] = true; |
| ret.push( array[ i ] ); |
| } |
| } |
| |
| } catch( e ) { |
| ret = array; |
| } |
| |
| return ret; |
| }, |
| |
| grep: function( elems, callback, inv ) { |
| var ret = []; |
| |
| // Go through the array, only saving the items |
| // that pass the validator function |
| for ( var i = 0, length = elems.length; i < length; i++ ) |
| if ( !inv != !callback( elems[ i ], i ) ) |
| ret.push( elems[ i ] ); |
| |
| return ret; |
| }, |
| |
| map: function( elems, callback ) { |
| var ret = []; |
| |
| // Go through the array, translating each of the items to their |
| // new value (or values). |
| for ( var i = 0, length = elems.length; i < length; i++ ) { |
| var value = callback( elems[ i ], i ); |
| |
| if ( value != null ) |
| ret[ ret.length ] = value; |
| } |
| |
| return ret.concat.apply( [], ret ); |
| } |
| }); |
| |
| // Use of jQuery.browser is deprecated. |
| // It's included for backwards compatibility and plugins, |
| // although they should work to migrate away. |
| |
| var userAgent = navigator.userAgent.toLowerCase(); |
| |
| // Figure out what browser is being used |
| jQuery.browser = { |
| version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1], |
| safari: /webkit/.test( userAgent ), |
| opera: /opera/.test( userAgent ), |
| msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), |
| mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) |
| }; |
| |
| jQuery.each({ |
| parent: function(elem){return elem.parentNode;}, |
| parents: function(elem){return jQuery.dir(elem,"parentNode");}, |
| next: function(elem){return jQuery.nth(elem,2,"nextSibling");}, |
| prev: function(elem){return jQuery.nth(elem,2,"previousSibling");}, |
| nextAll: function(elem){return jQuery.dir(elem,"nextSibling");}, |
| prevAll: function(elem){return jQuery.dir(elem,"previousSibling");}, |
| siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);}, |
| children: function(elem){return jQuery.sibling(elem.firstChild);}, |
| contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);} |
| }, function(name, fn){ |
| jQuery.fn[ name ] = function( selector ) { |
| var ret = jQuery.map( this, fn ); |
| |
| if ( selector && typeof selector == "string" ) |
| ret = jQuery.multiFilter( selector, ret ); |
| |
| return this.pushStack( jQuery.unique( ret ), name, selector ); |
| }; |
| }); |
| |
| jQuery.each({ |
| appendTo: "append", |
| prependTo: "prepend", |
| insertBefore: "before", |
| insertAfter: "after", |
| replaceAll: "replaceWith" |
| }, function(name, original){ |
| jQuery.fn[ name ] = function( selector ) { |
| var ret = [], insert = jQuery( selector ); |
| |
| for ( var i = 0, l = insert.length; i < l; i++ ) { |
| var elems = (i > 0 ? this.clone(true) : this).get(); |
| jQuery.fn[ original ].apply( jQuery(insert[i]), elems ); |
| ret = ret.concat( elems ); |
| } |
| |
| return this.pushStack( ret, name, selector ); |
| }; |
| }); |
| |
| jQuery.each({ |
| removeAttr: function( name ) { |
| jQuery.attr( this, name, "" ); |
| if (this.nodeType == 1) |
| this.removeAttribute( name ); |
| }, |
| |
| addClass: function( classNames ) { |
| jQuery.className.add( this, classNames ); |
| }, |
| |
| removeClass: function( classNames ) { |
| jQuery.className.remove( this, classNames ); |
| }, |
| |
| toggleClass: function( classNames, state ) { |
| if( typeof state !== "boolean" ) |
| state = !jQuery.className.has( this, classNames ); |
| jQuery.className[ state ? "add" : "remove" ]( this, classNames ); |
| }, |
| |
| remove: function( selector ) { |
| if ( !selector || jQuery.filter( selector, [ this ] ).length ) { |
| // Prevent memory leaks |
| jQuery( "*", this ).add([this]).each(function(){ |
| jQuery.event.remove(this); |
| jQuery.removeData(this); |
| }); |
| if (this.parentNode) |
| this.parentNode.removeChild( this ); |
| } |
| }, |
| |
| empty: function() { |
| // Remove element nodes and prevent memory leaks |
| jQuery(this).children().remove(); |
| |
| // Remove any remaining nodes |
| while ( this.firstChild ) |
| this.removeChild( this.firstChild ); |
| } |
| }, function(name, fn){ |
| jQuery.fn[ name ] = function(){ |
| return this.each( fn, arguments ); |
| }; |
| }); |
| |
| // Helper function used by the dimensions and offset modules |
| function num(elem, prop) { |
| return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0; |
| } |
| var expando = "jQuery" + now(), uuid = 0, windowData = {}; |
| |
| jQuery.extend({ |
| cache: {}, |
| |
| data: function( elem, name, data ) { |
| elem = elem == window ? |
| windowData : |
| elem; |
| |
| var id = elem[ expando ]; |
| |
| // Compute a unique ID for the element |
| if ( !id ) |
| id = elem[ expando ] = ++uuid; |
| |
| // Only generate the data cache if we're |
| // trying to access or manipulate it |
| if ( name && !jQuery.cache[ id ] ) |
| jQuery.cache[ id ] = {}; |
| |
| // Prevent overriding the named cache with undefined values |
| if ( data !== undefined ) |
| jQuery.cache[ id ][ name ] = data; |
| |
| // Return the named cache data, or the ID for the element |
| return name ? |
| jQuery.cache[ id ][ name ] : |
| id; |
| }, |
| |
| removeData: function( elem, name ) { |
| elem = elem == window ? |
| windowData : |
| elem; |
| |
| var id = elem[ expando ]; |
| |
| // If we want to remove a specific section of the element's data |
| if ( name ) { |
| if ( jQuery.cache[ id ] ) { |
| // Remove the section of cache data |
| delete jQuery.cache[ id ][ name ]; |
| |
| // If we've removed all the data, remove the element's cache |
| name = ""; |
| |
| for ( name in jQuery.cache[ id ] ) |
| break; |
| |
| if ( !name ) |
| jQuery.removeData( elem ); |
| } |
| |
| // Otherwise, we want to remove all of the element's data |
| } else { |
| // Clean up the element expando |
| try { |
| delete elem[ expando ]; |
| } catch(e){ |
| // IE has trouble directly removing the expando |
| // but it's ok with using removeAttribute |
| if ( elem.removeAttribute ) |
| elem.removeAttribute( expando ); |
| } |
| |
| // Completely remove the data cache |
| delete jQuery.cache[ id ]; |
| } |
| }, |
| queue: function( elem, type, data ) { |
| if ( elem ){ |
| |
| type = (type || "fx") + "queue"; |
| |
| var q = jQuery.data( elem, type ); |
| |
| if ( !q || jQuery.isArray(data) ) |
| q = jQuery.data( elem, type, jQuery.makeArray(data) ); |
| else if( data ) |
| q.push( data ); |
| |
| } |
| return q; |
| }, |
| |
| dequeue: function( elem, type ){ |
| var queue = jQuery.queue( elem, type ), |
| fn = queue.shift(); |
| |
| if( !type || type === "fx" ) |
| fn = queue[0]; |
| |
| if( fn !== undefined ) |
| fn.call(elem); |
| } |
| }); |
| |
| jQuery.fn.extend({ |
| data: function( key, value ){ |
| var parts = key.split("."); |
| parts[1] = parts[1] ? "." + parts[1] : ""; |
| |
| if ( value === undefined ) { |
| var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); |
| |
| if ( data === undefined && this.length ) |
| data = jQuery.data( this[0], key ); |
| |
| return data === undefined && parts[1] ? |
| this.data( parts[0] ) : |
| data; |
| } else |
| return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){ |
| jQuery.data( this, key, value ); |
| }); |
| }, |
| |
| removeData: function( key ){ |
| return this.each(function(){ |
| jQuery.removeData( this, key ); |
| }); |
| }, |
| queue: function(type, data){ |
| if ( typeof type !== "string" ) { |
| data = type; |
| type = "fx"; |
| } |
| |
| if ( data === undefined ) |
| return jQuery.queue( this[0], type ); |
| |
| return this.each(function(){ |
| var queue = jQuery.queue( this, type, data ); |
| |
| if( type == "fx" && queue.length == 1 ) |
| queue[0].call(this); |
| }); |
| }, |
| dequeue: function(type){ |
| return this.each(function(){ |
| jQuery.dequeue( this, type ); |
| }); |
| } |
| });/*! |
| * Sizzle CSS Selector Engine - v0.9.3 |
| * Copyright 2009, The Dojo Foundation |
| * Released under the MIT, BSD, and GPL Licenses. |
| * More information: http://sizzlejs.com/ |
| */ |
| (function(){ |
| |
| var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g, |
| done = 0, |
| toString = Object.prototype.toString; |
| |
| var Sizzle = function(selector, context, results, seed) { |
| results = results || []; |
| context = context || document; |
| |
| if ( context.nodeType !== 1 && context.nodeType !== 9 ) |
| return []; |
| |
| if ( !selector || typeof selector !== "string" ) { |
| return results; |
| } |
| |
| var parts = [], m, set, checkSet, check, mode, extra, prune = true; |
| |
| // Reset the position of the chunker regexp (start from head) |
| chunker.lastIndex = 0; |
| |
| while ( (m = chunker.exec(selector)) !== null ) { |
| parts.push( m[1] ); |
| |
| if ( m[2] ) { |
| extra = RegExp.rightContext; |
| break; |
| } |
| } |
| |
| if ( parts.length > 1 && origPOS.exec( selector ) ) { |
| if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { |
| set = posProcess( parts[0] + parts[1], context ); |
| } else { |
| set = Expr.relative[ parts[0] ] ? |
| [ context ] : |
| Sizzle( parts.shift(), context ); |
| |
| while ( parts.length ) { |
| selector = parts.shift(); |
| |
| if ( Expr.relative[ selector ] ) |
| selector += parts.shift(); |
| |
| set = posProcess( selector, set ); |
| } |
| } |
| } else { |
| var ret = seed ? |
| { expr: parts.pop(), set: makeArray(seed) } : |
| Sizzle.find( parts.pop(), parts.length === 1 && context.parentNode ? context.parentNode : context, isXML(context) ); |
| set = Sizzle.filter( ret.expr, ret.set ); |
| |
| if ( parts.length > 0 ) { |
| checkSet = makeArray(set); |
| } else { |
| prune = false; |
| } |
| |
| while ( parts.length ) { |
| var cur = parts.pop(), pop = cur; |
| |
| if ( !Expr.relative[ cur ] ) { |
| cur = ""; |
| } else { |
| pop = parts.pop(); |
| } |
| |
| if ( pop == null ) { |
| pop = context; |
| } |
| |
| Expr.relative[ cur ]( checkSet, pop, isXML(context) ); |
| } |
| } |
| |
| if ( !checkSet ) { |
| checkSet = set; |
| } |
| |
| if ( !checkSet ) { |
| throw "Syntax error, unrecognized expression: " + (cur || selector); |
| } |
| |
| if ( toString.call(checkSet) === "[object Array]" ) { |
| if ( !prune ) { |
| results.push.apply( results, checkSet ); |
| } else if ( context.nodeType === 1 ) { |
| for ( var i = 0; checkSet[i] != null; i++ ) { |
| if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { |
| results.push( set[i] ); |
| } |
| } |
| } else { |
| for ( var i = 0; checkSet[i] != null; i++ ) { |
| if ( checkSet[i] && checkSet[i].nodeType === 1 ) { |
| results.push( set[i] ); |
| } |
| } |
| } |
| } else { |
| makeArray( checkSet, results ); |
| } |
| |
| if ( extra ) { |
| Sizzle( extra, context, results, seed ); |
| |
| if ( sortOrder ) { |
| hasDuplicate = false; |
| results.sort(sortOrder); |
| |
| if ( hasDuplicate ) { |
| for ( var i = 1; i < results.length; i++ ) { |
| if ( results[i] === results[i-1] ) { |
| results.splice(i--, 1); |
| } |
| } |
| } |
| } |
| } |
| |
| return results; |
| }; |
| |
| Sizzle.matches = function(expr, set){ |
| return Sizzle(expr, null, null, set); |
| }; |
| |
| Sizzle.find = function(expr, context, isXML){ |
| var set, match; |
| |
| if ( !expr ) { |
| return []; |
| } |
| |
| for ( var i = 0, l = Expr.order.length; i < l; i++ ) { |
| var type = Expr.order[i], match; |
| |
| if ( (match = Expr.match[ type ].exec( expr )) ) { |
| var left = RegExp.leftContext; |
| |
| if ( left.substr( left.length - 1 ) !== "\\" ) { |
| match[1] = (match[1] || "").replace(/\\/g, ""); |
| set = Expr.find[ type ]( match, context, isXML ); |
| if ( set != null ) { |
| expr = expr.replace( Expr.match[ type ], "" ); |
| break; |
| } |
| } |
| } |
| } |
| |
| if ( !set ) { |
| set = context.getElementsByTagName("*"); |
| } |
| |
| return {set: set, expr: expr}; |
| }; |
| |
| Sizzle.filter = function(expr, set, inplace, not){ |
| var old = expr, result = [], curLoop = set, match, anyFound, |
| isXMLFilter = set && set[0] && isXML(set[0]); |
| |
| while ( expr && set.length ) { |
| for ( var type in Expr.filter ) { |
| if ( (match = Expr.match[ type ].exec( expr )) != null ) { |
| var filter = Expr.filter[ type ], found, item; |
| anyFound = false; |
| |
| if ( curLoop == result ) { |
| result = []; |
| } |
| |
| if ( Expr.preFilter[ type ] ) { |
| match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); |
| |
| if ( !match ) { |
| anyFound = found = true; |
| } else if ( match === true ) { |
| continue; |
| } |
| } |
| |
| if ( match ) { |
| for ( var i = 0; (item = curLoop[i]) != null; i++ ) { |
| if ( item ) { |
| found = filter( item, match, i, curLoop ); |
| var pass = not ^ !!found; |
| |
| if ( inplace && found != null ) { |
| if ( pass ) { |
| anyFound = true; |
| } else { |
| curLoop[i] = false; |
| } |
| } else if ( pass ) { |
| result.push( item ); |
| anyFound = true; |
| } |
| } |
| } |
| } |
| |
| if ( found !== undefined ) { |
| if ( !inplace ) { |
| curLoop = result; |
| } |
| |
| expr = expr.replace( Expr.match[ type ], "" ); |
| |
| if ( !anyFound ) { |
| return []; |
| } |
| |
| break; |
| } |
| } |
| } |
| |
| // Improper expression |
| if ( expr == old ) { |
| if ( anyFound == null ) { |
| throw "Syntax error, unrecognized expression: " + expr; |
| } else { |
| break; |
| } |
| } |
| |
| old = expr; |
| } |
| |
| return curLoop; |
| }; |
| |
| var Expr = Sizzle.selectors = { |
| order: [ "ID", "NAME", "TAG" ], |
| match: { |
| ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, |
| CLASS: /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, |
| NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/, |
| ATTR: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, |
| TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/, |
| CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/, |
| POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/, |
| PSEUDO: /:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/ |
| }, |
| attrMap: { |
| "class": "className", |
| "for": "htmlFor" |
| }, |
| attrHandle: { |
| href: function(elem){ |
| return elem.getAttribute("href"); |
| } |
| }, |
| relative: { |
| "+": function(checkSet, part, isXML){ |
| var isPartStr = typeof part === "string", |
| isTag = isPartStr && !/\W/.test(part), |
| isPartStrNotTag = isPartStr && !isTag; |
| |
| if ( isTag && !isXML ) { |
| part = part.toUpperCase(); |
| } |
| |
| for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { |
| if ( (elem = checkSet[i]) ) { |
| while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} |
| |
| checkSet[i] = isPartStrNotTag || elem && elem.nodeName === part ? |
| elem || false : |
| elem === part; |
| } |
| } |
| |
| if ( isPartStrNotTag ) { |
| Sizzle.filter( part, checkSet, true ); |
| } |
| }, |
| ">": function(checkSet, part, isXML){ |
| var isPartStr = typeof part === "string"; |
| |
| if ( isPartStr && !/\W/.test(part) ) { |
| part = isXML ? part : part.toUpperCase(); |
| |
| for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
| var elem = checkSet[i]; |
| if ( elem ) { |
| var parent = elem.parentNode; |
| checkSet[i] = parent.nodeName === part ? parent : false; |
| } |
| } |
| } else { |
| for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
| var elem = checkSet[i]; |
| if ( elem ) { |
| checkSet[i] = isPartStr ? |
| elem.parentNode : |
| elem.parentNode === part; |
| } |
| } |
| |
| if ( isPartStr ) { |
| Sizzle.filter( part, checkSet, true ); |
| } |
| } |
| }, |
| "": function(checkSet, part, isXML){ |
| var doneName = done++, checkFn = dirCheck; |
| |
| if ( !part.match(/\W/) ) { |
| var nodeCheck = part = isXML ? part : part.toUpperCase(); |
| checkFn = dirNodeCheck; |
| } |
| |
| checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); |
| }, |
| "~": function(checkSet, part, isXML){ |
| var doneName = done++, checkFn = dirCheck; |
| |
| if ( typeof part === "string" && !part.match(/\W/) ) { |
| var nodeCheck = part = isXML ? part : part.toUpperCase(); |
| checkFn = dirNodeCheck; |
| } |
| |
| checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); |
| } |
| }, |
| find: { |
| ID: function(match, context, isXML){ |
| if ( typeof context.getElementById !== "undefined" && !isXML ) { |
| var m = context.getElementById(match[1]); |
| return m ? [m] : []; |
| } |
| }, |
| NAME: function(match, context, isXML){ |
| if ( typeof context.getElementsByName !== "undefined" ) { |
| var ret = [], results = context.getElementsByName(match[1]); |
| |
| for ( var i = 0, l = results.length; i < l; i++ ) { |
| if ( results[i].getAttribute("name") === match[1] ) { |
| ret.push( results[i] ); |
| } |
| } |
| |
| return ret.length === 0 ? null : ret; |
| } |
| }, |
| TAG: function(match, context){ |
| return context.getElementsByTagName(match[1]); |
| } |
| }, |
| preFilter: { |
| CLASS: function(match, curLoop, inplace, result, not, isXML){ |
| match = " " + match[1].replace(/\\/g, "") + " "; |
| |
| if ( isXML ) { |
| return match; |
| } |
| |
| for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { |
| if ( elem ) { |
| if ( not ^ (elem.className && (" " + elem.className + " ").indexOf(match) >= 0) ) { |
| if ( !inplace ) |
| result.push( elem ); |
| } else if ( inplace ) { |
| curLoop[i] = false; |
| } |
| } |
| } |
| |
| return false; |
| }, |
| ID: function(match){ |
| return match[1].replace(/\\/g, ""); |
| }, |
| TAG: function(match, curLoop){ |
| for ( var i = 0; curLoop[i] === false; i++ ){} |
| return curLoop[i] && isXML(curLoop[i]) ? match[1] : match[1].toUpperCase(); |
| }, |
| CHILD: function(match){ |
| if ( match[1] == "nth" ) { |
| // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' |
| var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( |
| match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" || |
| !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); |
| |
| // calculate the numbers (first)n+(last) including if they are negative |
| match[2] = (test[1] + (test[2] || 1)) - 0; |
| match[3] = test[3] - 0; |
| } |
| |
| // TODO: Move to normal caching system |
| match[0] = done++; |
| |
| return match; |
| }, |
| ATTR: function(match, curLoop, inplace, result, not, isXML){ |
| var name = match[1].replace(/\\/g, ""); |
| |
| if ( !isXML && Expr.attrMap[name] ) { |
| match[1] = Expr.attrMap[name]; |
| } |
| |
| if ( match[2] === "~=" ) { |
| match[4] = " " + match[4] + " "; |
| } |
| |
| return match; |
| }, |
| PSEUDO: function(match, curLoop, inplace, result, not){ |
| if ( match[1] === "not" ) { |
| // If we're dealing with a complex expression, or a simple one |
| if ( match[3].match(chunker).length > 1 || /^\w/.test(match[3]) ) { |
| match[3] = Sizzle(match[3], null, null, curLoop); |
| } else { |
| var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); |
| if ( !inplace ) { |
| result.push.apply( result, ret ); |
| } |
| return false; |
| } |
| } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { |
| return true; |
| } |
| |
| return match; |
| }, |
| POS: function(match){ |
| match.unshift( true ); |
| return match; |
| } |
| }, |
| filters: { |
| enabled: function(elem){ |
| return elem.disabled === false && elem.type !== "hidden"; |
| }, |
| disabled: function(elem){ |
| return elem.disabled === true; |
| }, |
| checked: function(elem){ |
| return elem.checked === true; |
| }, |
| selected: function(elem){ |
| // Accessing this property makes selected-by-default |
| // options in Safari work properly |
| elem.parentNode.selectedIndex; |
| return elem.selected === true; |
| }, |
| parent: function(elem){ |
| return !!elem.firstChild; |
| }, |
| empty: function(elem){ |
| return !elem.firstChild; |
| }, |
| has: function(elem, i, match){ |
| return !!Sizzle( match[3], elem ).length; |
| }, |
| header: function(elem){ |
| return /h\d/i.test( elem.nodeName ); |
| }, |
| text: function(elem){ |
| return "text" === elem.type; |
| }, |
| radio: function(elem){ |
| return "radio" === elem.type; |
| }, |
| checkbox: function(elem){ |
| return "checkbox" === elem.type; |
| }, |
| file: function(elem){ |
| return "file" === elem.type; |
| }, |
| password: function(elem){ |
| return "password" === elem.type; |
| }, |
| submit: function(elem){ |
| return "submit" === elem.type; |
| }, |
| image: function(elem){ |
| return "image" === elem.type; |
| }, |
| reset: function(elem){ |
| return "reset" === elem.type; |
| }, |
| button: function(elem){ |
| return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON"; |
| }, |
| input: function(elem){ |
| return /input|select|textarea|button/i.test(elem.nodeName); |
| } |
| }, |
| setFilters: { |
| first: function(elem, i){ |
| return i === 0; |
| }, |
| last: function(elem, i, match, array){ |
| return i === array.length - 1; |
| }, |
| even: function(elem, i){ |
| return i % 2 === 0; |
| }, |
| odd: function(elem, i){ |
| return i % 2 === 1; |
| }, |
| lt: function(elem, i, match){ |
| return i < match[3] - 0; |
| }, |
| gt: function(elem, i, match){ |
| return i > match[3] - 0; |
| }, |
| nth: function(elem, i, match){ |
| return match[3] - 0 == i; |
| }, |
| eq: function(elem, i, match){ |
| return match[3] - 0 == i; |
| } |
| }, |
| filter: { |
| PSEUDO: function(elem, match, i, array){ |
| var name = match[1], filter = Expr.filters[ name ]; |
| |
| if ( filter ) { |
| return filter( elem, i, match, array ); |
| } else if ( name === "contains" ) { |
| return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0; |
| } else if ( name === "not" ) { |
| var not = match[3]; |
| |
| for ( var i = 0, l = not.length; i < l; i++ ) { |
| if ( not[i] === elem ) { |
| return false; |
| } |
| } |
| |
| return true; |
| } |
| }, |
| CHILD: function(elem, match){ |
| var type = match[1], node = elem; |
| switch (type) { |
| case 'only': |
| case 'first': |
| while (node = node.previousSibling) { |
| if ( node.nodeType === 1 ) return false; |
| } |
| if ( type == 'first') return true; |
| node = elem; |
| case 'last': |
| while (node = node.nextSibling) { |
| if ( node.nodeType === 1 ) return false; |
| } |
| return true; |
| case 'nth': |
| var first = match[2], last = match[3]; |
| |
| if ( first == 1 && last == 0 ) { |
| return true; |
| } |
| |
| var doneName = match[0], |
| parent = elem.parentNode; |
| |
| if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { |
| var count = 0; |
| for ( node = parent.firstChild; node; node = node.nextSibling ) { |
| if ( node.nodeType === 1 ) { |
| node.nodeIndex = ++count; |
| } |
| } |
| parent.sizcache = doneName; |
| } |
| |
| var diff = elem.nodeIndex - last; |
| if ( first == 0 ) { |
| return diff == 0; |
| } else { |
| return ( diff % first == 0 && diff / first >= 0 ); |
| } |
| } |
| }, |
| ID: function(elem, match){ |
| return elem.nodeType === 1 && elem.getAttribute("id") === match; |
| }, |
| TAG: function(elem, match){ |
| return (match === "*" && elem.nodeType === 1) || elem.nodeName === match; |
| }, |
| CLASS: function(elem, match){ |
| return (" " + (elem.className || elem.getAttribute("class")) + " ") |
| .indexOf( match ) > -1; |
| }, |
| ATTR: function(elem, match){ |
| var name = match[1], |
| result = Expr.attrHandle[ name ] ? |
| Expr.attrHandle[ name ]( elem ) : |
| elem[ name ] != null ? |
| elem[ name ] : |
| elem.getAttribute( name ), |
| value = result + "", |
| type = match[2], |
| check = match[4]; |
| |
| return result == null ? |
| type === "!=" : |
| type === "=" ? |
| value === check : |
| type === "*=" ? |
| value.indexOf(check) >= 0 : |
| type === "~=" ? |
| (" " + value + " ").indexOf(check) >= 0 : |
| !check ? |
| value && result !== false : |
| type === "!=" ? |
| value != check : |
| type === "^=" ? |
| value.indexOf(check) === 0 : |
| type === "$=" ? |
| value.substr(value.length - check.length) === check : |
| type === "|=" ? |
| value === check || value.substr(0, check.length + 1) === check + "-" : |
| false; |
| }, |
| POS: function(elem, match, i, array){ |
| var name = match[2], filter = Expr.setFilters[ name ]; |
| |
| if ( filter ) { |
| return filter( elem, i, match, array ); |
| } |
| } |
| } |
| }; |
| |
| var origPOS = Expr.match.POS; |
| |
| for ( var type in Expr.match ) { |
| Expr.match[ type ] = RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); |
| } |
| |
| var makeArray = function(array, results) { |
| array = Array.prototype.slice.call( array ); |
| |
| if ( results ) { |
| results.push.apply( results, array ); |
| return results; |
| } |
| |
| return array; |
| }; |
| |
| // Perform a simple check to determine if the browser is capable of |
| // converting a NodeList to an array using builtin methods. |
| try { |
| Array.prototype.slice.call( document.documentElement.childNodes ); |
| |
| // Provide a fallback method if it does not work |
| } catch(e){ |
| makeArray = function(array, results) { |
| var ret = results || []; |
| |
| if ( toString.call(array) === "[object Array]" ) { |
| Array.prototype.push.apply( ret, array ); |
| } else { |
| if ( typeof array.length === "number" ) { |
| for ( var i = 0, l = array.length; i < l; i++ ) { |
| ret.push( array[i] ); |
| } |
| } else { |
| for ( var i = 0; array[i]; i++ ) { |
| ret.push( array[i] ); |
| } |
| } |
| } |
| |
| return ret; |
| }; |
| } |
| |
| var sortOrder; |
| |
| if ( document.documentElement.compareDocumentPosition ) { |
| sortOrder = function( a, b ) { |
| var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; |
| if ( ret === 0 ) { |
| hasDuplicate = true; |
| } |
| return ret; |
| }; |
| } else if ( "sourceIndex" in document.documentElement ) { |
| sortOrder = function( a, b ) { |
| var ret = a.sourceIndex - b.sourceIndex; |
| if ( ret === 0 ) { |
| hasDuplicate = true; |
| } |
| return ret; |
| }; |
| } else if ( document.createRange ) { |
| sortOrder = function( a, b ) { |
| var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); |
| aRange.selectNode(a); |
| aRange.collapse(true); |
| bRange.selectNode(b); |
| bRange.collapse(true); |
| var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange); |
| if ( ret === 0 ) { |
| hasDuplicate = true; |
| } |
| return ret; |
| }; |
| } |
| |
| // Check to see if the browser returns elements by name when |
| // querying by getElementById (and provide a workaround) |
| (function(){ |
| // We're going to inject a fake input element with a specified name |
| var form = document.createElement("form"), |
| id = "script" + (new Date).getTime(); |
| form.innerHTML = "<input name='" + id + "'/>"; |
| |
| // Inject it into the root element, check its status, and remove it quickly |
| var root = document.documentElement; |
| root.insertBefore( form, root.firstChild ); |
| |
| // The workaround has to do additional checks after a getElementById |
| // Which slows things down for other browsers (hence the branching) |
| if ( !!document.getElementById( id ) ) { |
| Expr.find.ID = function(match, context, isXML){ |
| if ( typeof context.getElementById !== "undefined" && !isXML ) { |
| var m = context.getElementById(match[1]); |
| return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : []; |
| } |
| }; |
| |
| Expr.filter.ID = function(elem, match){ |
| var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); |
| return elem.nodeType === 1 && node && node.nodeValue === match; |
| }; |
| } |
| |
| root.removeChild( form ); |
| })(); |
| |
| (function(){ |
| // Check to see if the browser returns only elements |
| // when doing getElementsByTagName("*") |
| |
| // Create a fake element |
| var div = document.createElement("div"); |
| div.appendChild( document.createComment("") ); |
| |
| // Make sure no comments are found |
| if ( div.getElementsByTagName("*").length > 0 ) { |
| Expr.find.TAG = function(match, context){ |
| var results = context.getElementsByTagName(match[1]); |
| |
| // Filter out possible comments |
| if ( match[1] === "*" ) { |
| var tmp = []; |
| |
| for ( var i = 0; results[i]; i++ ) { |
| if ( results[i].nodeType === 1 ) { |
| tmp.push( results[i] ); |
| } |
| } |
| |
| results = tmp; |
| } |
| |
| return results; |
| }; |
| } |
| |
| // Check to see if an attribute returns normalized href attributes |
| div.innerHTML = "<a href='#'></a>"; |
| if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && |
| div.firstChild.getAttribute("href") !== "#" ) { |
| Expr.attrHandle.href = function(elem){ |
| return elem.getAttribute("href", 2); |
| }; |
| } |
| })(); |
| |
| if ( document.querySelectorAll ) (function(){ |
| var oldSizzle = Sizzle, div = document.createElement("div"); |
| div.innerHTML = "<p class='TEST'></p>"; |
| |
| // Safari can't handle uppercase or unicode characters when |
| // in quirks mode. |
| if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { |
| return; |
| } |
| |
| Sizzle = function(query, context, extra, seed){ |
| context = context || document; |
| |
| // Only use querySelectorAll on non-XML documents |
| // (ID selectors don't work in non-HTML documents) |
| if ( !seed && context.nodeType === 9 && !isXML(context) ) { |
| try { |
| return makeArray( context.querySelectorAll(query), extra ); |
| } catch(e){} |
| } |
| |
| return oldSizzle(query, context, extra, seed); |
| }; |
| |
| Sizzle.find = oldSizzle.find; |
| Sizzle.filter = oldSizzle.filter; |
| Sizzle.selectors = oldSizzle.selectors; |
| Sizzle.matches = oldSizzle.matches; |
| })(); |
| |
| if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ |
| var div = document.createElement("div"); |
| div.innerHTML = "<div class='test e'></div><div class='test'></div>"; |
| |
| // Opera can't find a second classname (in 9.6) |
| if ( div.getElementsByClassName("e").length === 0 ) |
| return; |
| |
| // Safari caches class attributes, doesn't catch changes (in 3.2) |
| div.lastChild.className = "e"; |
| |
| if ( div.getElementsByClassName("e").length === 1 ) |
| return; |
| |
| Expr.order.splice(1, 0, "CLASS"); |
| Expr.find.CLASS = function(match, context, isXML) { |
| if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { |
| return context.getElementsByClassName(match[1]); |
| } |
| }; |
| })(); |
| |
| function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
| var sibDir = dir == "previousSibling" && !isXML; |
| for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
| var elem = checkSet[i]; |
| if ( elem ) { |
| if ( sibDir && elem.nodeType === 1 ){ |
| elem.sizcache = doneName; |
| elem.sizset = i; |
| } |
| elem = elem[dir]; |
| var match = false; |
| |
| while ( elem ) { |
| if ( elem.sizcache === doneName ) { |
| match = checkSet[elem.sizset]; |
| break; |
| } |
| |
| if ( elem.nodeType === 1 && !isXML ){ |
| elem.sizcache = doneName; |
| elem.sizset = i; |
| } |
| |
| if ( elem.nodeName === cur ) { |
| match = elem; |
| break; |
| } |
| |
| elem = elem[dir]; |
| } |
| |
| checkSet[i] = match; |
| } |
| } |
| } |
| |
| function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
| var sibDir = dir == "previousSibling" && !isXML; |
| for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
| var elem = checkSet[i]; |
| if ( elem ) { |
| if ( sibDir && elem.nodeType === 1 ) { |
| elem.sizcache = doneName; |
| elem.sizset = i; |
| } |
| elem = elem[dir]; |
| var match = false; |
| |
| while ( elem ) { |
| if ( elem.sizcache === doneName ) { |
| match = checkSet[elem.sizset]; |
| break; |
| } |
| |
| if ( elem.nodeType === 1 ) { |
| if ( !isXML ) { |
| elem.sizcache = doneName; |
| elem.sizset = i; |
| } |
| if ( typeof cur !== "string" ) { |
| if ( elem === cur ) { |
| match = true; |
| break; |
| } |
| |
| } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { |
| match = elem; |
| break; |
| } |
| } |
| |
| elem = elem[dir]; |
| } |
| |
| checkSet[i] = match; |
| } |
| } |
| } |
| |
| var contains = document.compareDocumentPosition ? function(a, b){ |
| return a.compareDocumentPosition(b) & 16; |
| } : function(a, b){ |
| return a !== b && (a.contains ? a.contains(b) : true); |
| }; |
| |
| var isXML = function(elem){ |
| return elem.nodeType === 9 && elem.documentElement && elem.documentElement.nodeName !== "HTML" || |
| !!elem.ownerDocument && isXML( elem.ownerDocument ); |
| }; |
| |
| var posProcess = function(selector, context){ |
| var tmpSet = [], later = "", match, |
| root = context.nodeType ? [context] : context; |
| |
| // Position selectors must be done after the filter |
| // And so must :not(positional) so we move all PSEUDOs to the end |
| while ( (match = Expr.match.PSEUDO.exec( selector )) ) { |
| later += match[0]; |
| selector = selector.replace( Expr.match.PSEUDO, "" ); |
| } |
| |
| selector = Expr.relative[selector] ? selector + "*" : selector; |
| |
| for ( var i = 0, l = root.length; i < l; i++ ) { |
| Sizzle( selector, root[i], tmpSet ); |
| } |
| |
| return Sizzle.filter( later, tmpSet ); |
| }; |
| |
| // EXPOSE |
| jQuery.find = Sizzle; |
| jQuery.filter = Sizzle.filter; |
| jQuery.expr = Sizzle.selectors; |
| jQuery.expr[":"] = jQuery.expr.filters; |
| |
| Sizzle.selectors.filters.hidden = function(elem){ |
| return elem.offsetWidth === 0 || elem.offsetHeight === 0; |
| }; |
| |
| Sizzle.selectors.filters.visible = function(elem){ |
| return elem.offsetWidth > 0 || elem.offsetHeight > 0; |
| }; |
| |
| Sizzle.selectors.filters.animated = function(elem){ |
| return jQuery.grep(jQuery.timers, function(fn){ |
| return elem === fn.elem; |
| }).length; |
| }; |
| |
| jQuery.multiFilter = function( expr, elems, not ) { |
| if ( not ) { |
| expr = ":not(" + expr + ")"; |
| } |
| |
| return Sizzle.matches(expr, elems); |
| }; |
| |
| jQuery.dir = function( elem, dir ){ |
| var matched = [], cur = elem[dir]; |
| while ( cur && cur != document ) { |
| if ( cur.nodeType == 1 ) |
| matched.push( cur ); |
| cur = cur[dir]; |
| } |
| return matched; |
| }; |
| |
| jQuery.nth = function(cur, result, dir, elem){ |
| result = result || 1; |
| var num = 0; |
| |
| for ( ; cur; cur = cur[dir] ) |
| if ( cur.nodeType == 1 && ++num == result ) |
| break; |
| |
| return cur; |
| }; |
| |
| jQuery.sibling = function(n, elem){ |
| var r = []; |
| |
| for ( ; n; n = n.nextSibling ) { |
| if ( n.nodeType == 1 && n != elem ) |
| r.push( n ); |
| } |
| |
| return r; |
| }; |
| |
| return; |
| |
| window.Sizzle = Sizzle; |
| |
| })(); |
| /* |
| * A number of helper functions used for managing events. |
| * Many of the ideas behind this code originated from |
| * Dean Edwards' addEvent library. |
| */ |
| jQuery.event = { |
| |
| // Bind an event to an element |
| // Original by Dean Edwards |
| add: function(elem, types, handler, data) { |
| if ( elem.nodeType == 3 || elem.nodeType == 8 ) |
| return; |
| |
| // For whatever reason, IE has trouble passing the window object |
| // around, causing it to be cloned in the process |
| if ( elem.setInterval && elem != window ) |
| elem = window; |
| |
| // Make sure that the function being executed has a unique ID |
| if ( !handler.guid ) |
| handler.guid = this.guid++; |
| |
| // if data is passed, bind to handler |
| if ( data !== undefined ) { |
| // Create temporary function pointer to original handler |
| var fn = handler; |
| |
| // Create unique handler function, wrapped around original handler |
| handler = this.proxy( fn ); |
| |
| // Store data in unique handler |
| handler.data = data; |
| } |
| |
| // Init the element's event structure |
| var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}), |
| handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){ |
| // Handle the second event of a trigger and when |
| // an event is called after a page has unloaded |
| return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
| jQuery.event.handle.apply(arguments.callee.elem, arguments) : |
| undefined; |
| }); |
| // Add elem as a property of the handle function |
| // This is to prevent a memory leak with non-native |
| // event in IE. |
| handle.elem = elem; |
| |
| // Handle multiple events separated by a space |
| // jQuery(...).bind("mouseover mouseout", fn); |
| jQuery.each(types.split(/\s+/), function(index, type) { |
| // Namespaced event handlers |
| var namespaces = type.split("."); |
| type = namespaces.shift(); |
| handler.type = namespaces.slice().sort().join("."); |
| |
| // Get the current list of functions bound to this event |
| var handlers = events[type]; |
| |
| if ( jQuery.event.specialAll[type] ) |
| jQuery.event.specialAll[type].setup.call(elem, data, namespaces); |
| |
| // Init the event handler queue |
| if (!handlers) { |
| handlers = events[type] = {}; |
| |
| // Check for a special event handler |
| // Only use addEventListener/attachEvent if the special |
| // events handler returns false |
| if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem, data, namespaces) === false ) { |
| // Bind the global event handler to the element |
| if (elem.addEventListener) |
| elem.addEventListener(type, handle, false); |
| else if (elem.attachEvent) |
| elem.attachEvent("on" + type, handle); |
| } |
| } |
| |
| // Add the function to the element's handler list |
| handlers[handler.guid] = handler; |
| |
| // Keep track of which events have been used, for global triggering |
| jQuery.event.global[type] = true; |
| }); |
| |
| // Nullify elem to prevent memory leaks in IE |
| elem = null; |
| }, |
| |
| guid: 1, |
| global: {}, |
| |
| // Detach an event or set of events from an element |
| remove: function(elem, types, handler) { |
| // don't do events on text and comment nodes |
| if ( elem.nodeType == 3 || elem.nodeType == 8 ) |
| return; |
| |
| var events = jQuery.data(elem, "events"), ret, index; |
| |
| if ( events ) { |
| // Unbind all events for the element |
| if ( types === undefined || (typeof types === "string" && types.charAt(0) == ".") ) |
| for ( var type in events ) |
| this.remove( elem, type + (types || "") ); |
| else { |
| // types is actually an event object here |
| if ( types.type ) { |
| handler = types.handler; |
| types = types.type; |
| } |
| |
| // Handle multiple events seperated by a space |
| // jQuery(...).unbind("mouseover mouseout", fn); |
| jQuery.each(types.split(/\s+/), function(index, type){ |
| // Namespaced event handlers |
| var namespaces = type.split("."); |
| type = namespaces.shift(); |
| var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); |
| |
| if ( events[type] ) { |
| // remove the given handler for the given type |
| if ( handler ) |
| delete events[type][handler.guid]; |
| |
| // remove all handlers for the given type |
| else |
| for ( var handle in events[type] ) |
| // Handle the removal of namespaced events |
| if ( namespace.test(events[type][handle].type) ) |
| delete events[type][handle]; |
| |
| if ( jQuery.event.specialAll[type] ) |
| jQuery.event.specialAll[type].teardown.call(elem, namespaces); |
| |
| // remove generic event handler if no more handlers exist |
| for ( ret in events[type] ) break; |
| if ( !ret ) { |
| if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem, namespaces) === false ) { |
| if (elem.removeEventListener) |
| elem.removeEventListener(type, jQuery.data(elem, "handle"), false); |
| else if (elem.detachEvent) |
| elem.detachEvent("on" + type, jQuery.data(elem, "handle")); |
| } |
| ret = null; |
| delete events[type]; |
| } |
| } |
| }); |
| } |
| |
| // Remove the expando if it's no longer used |
| for ( ret in events ) break; |
| if ( !ret ) { |
| var handle = jQuery.data( elem, "handle" ); |
| if ( handle ) handle.elem = null; |
| jQuery.removeData( elem, "events" ); |
| jQuery.removeData( elem, "handle" ); |
| } |
| } |
| }, |
| |
| // bubbling is internal |
| trigger: function( event, data, elem, bubbling ) { |
| // Event object or event type |
| var type = event.type || event; |
| |
| if( !bubbling ){ |
| event = typeof event === "object" ? |
| // jQuery.Event object |
| event[expando] ? event : |
| // Object literal |
| jQuery.extend( jQuery.Event(type), event ) : |
| // Just the event type (string) |
| jQuery.Event(type); |
| |
| if ( type.indexOf("!") >= 0 ) { |
| event.type = type = type.slice(0, -1); |
| event.exclusive = true; |
| } |
| |
| // Handle a global trigger |
| if ( !elem ) { |
| // Don't bubble custom events when global (to avoid too much overhead) |
| event.stopPropagation(); |
| // Only trigger if we've ever bound an event for it |
| if ( this.global[type] ) |
| jQuery.each( jQuery.cache, function(){ |
| if ( this.events && this.events[type] ) |
| jQuery.event.trigger( event, data, this.handle.elem ); |
| }); |
| } |
| |
| // Handle triggering a single element |
| |
| // don't do events on text and comment nodes |
| if ( !elem || elem.nodeType == 3 || elem.nodeType == 8 ) |
| return undefined; |
| |
| // Clean up in case it is reused |
| event.result = undefined; |
| event.target = elem; |
| |
| // Clone the incoming data, if any |
| data = jQuery.makeArray(data); |
| data.unshift( event ); |
| } |
| |
| event.currentTarget = elem; |
| |
| // Trigger the event, it is assumed that "handle" is a function |
| var handle = jQuery.data(elem, "handle"); |
| if ( handle ) |
| handle.apply( elem, data ); |
| |
| // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links) |
| if ( (!elem[type] || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false ) |
| event.result = false; |
| |
| // Trigger the native events (except for clicks on links) |
| if ( !bubbling && elem[type] && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type == "click") ) { |
| this.triggered = true; |
| try { |
| elem[ type ](); |
| // prevent IE from throwing an error for some hidden elements |
| } catch (e) {} |
| } |
| |
| this.triggered = false; |
| |
| if ( !event.isPropagationStopped() ) { |
| var parent = elem.parentNode || elem.ownerDocument; |
| if ( parent ) |
| jQuery.event.trigger(event, data, parent, true); |
| } |
| }, |
| |
| handle: function(event) { |
| // returned undefined or false |
| var all, handlers; |
| |
| event = arguments[0] = jQuery.event.fix( event || window.event ); |
| event.currentTarget = this; |
| |
| // Namespaced event handlers |
| var namespaces = event.type.split("."); |
| event.type = namespaces.shift(); |
| |
| // Cache this now, all = true means, any handler |
| all = !namespaces.length && !event.exclusive; |
| |
| var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); |
| |
| handlers = ( jQuery.data(this, "events") || {} )[event.type]; |
| |
| for ( var j in handlers ) { |
| var handler = handlers[j]; |
| |
| // Filter the functions by class |
| if ( all || namespace.test(handler.type) ) { |
| // Pass in a reference to the handler function itself |
| // So that we can later remove it |
| event.handler = handler; |
| event.data = handler.data; |
| |
| var ret = handler.apply(this, arguments); |
| |
| if( ret !== undefined ){ |
| event.result = ret; |
| if ( ret === false ) { |
| event.preventDefault(); |
| event.stopPropagation(); |
| } |
| } |
| |
| if( event.isImmediatePropagationStopped() ) |
| break; |
| |
| } |
| } |
| }, |
| |
| props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), |
| |
| fix: function(event) { |
| if ( event[expando] ) |
| return event; |
| |
| // store a copy of the original event object |
| // and "clone" to set read-only properties |
| var originalEvent = event; |
| event = jQuery.Event( originalEvent ); |
| |
| for ( var i = this.props.length, prop; i; ){ |
| prop = this.props[ --i ]; |
| event[ prop ] = originalEvent[ prop ]; |
| } |
| |
| // Fix target property, if necessary |
| if ( !event.target ) |
| event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either |
| |
| // check if target is a textnode (safari) |
| if ( event.target.nodeType == 3 ) |
| event.target = event.target.parentNode; |
| |
| // Add relatedTarget, if necessary |
| if ( !event.relatedTarget && event.fromElement ) |
| event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement; |
| |
| // Calculate pageX/Y if missing and clientX/Y available |
| if ( event.pageX == null && event.clientX != null ) { |
| var doc = document.documentElement, body = document.body; |
| event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0); |
| event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0); |
| } |
| |
| // Add which for key events |
| if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) |
| event.which = event.charCode || event.keyCode; |
| |
| // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs) |
| if ( !event.metaKey && event.ctrlKey ) |
| event.metaKey = event.ctrlKey; |
| |
| // Add which for click: 1 == left; 2 == middle; 3 == right |
| // Note: button is not normalized, so don't use it |
| if ( !event.which && event.button ) |
| event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
| |
| return event; |
| }, |
| |
| proxy: function( fn, proxy ){ |
| proxy = proxy || function(){ return fn.apply(this, arguments); }; |
| // Set the guid of unique handler to the same of original handler, so it can be removed |
| proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++; |
| // So proxy can be declared as an argument |
| return proxy; |
| }, |
| |
| special: { |
| ready: { |
| // Make sure the ready event is setup |
| setup: bindReady, |
| teardown: function() {} |
| } |
| }, |
| |
| specialAll: { |
| live: { |
| setup: function( selector, namespaces ){ |
| jQuery.event.add( this, namespaces[0], liveHandler ); |
| }, |
| teardown: function( namespaces ){ |
| if ( namespaces.length ) { |
| var remove = 0, name = RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)"); |
| |
| jQuery.each( (jQuery.data(this, "events").live || {}), function(){ |
| if ( name.test(this.type) ) |
| remove++; |
| }); |
| |
| if ( remove < 1 ) |
| jQuery.event.remove( this, namespaces[0], liveHandler ); |
| } |
| } |
| } |
| } |
| }; |
| |
| jQuery.Event = function( src ){ |
| // Allow instantiation without the 'new' keyword |
| if( !this.preventDefault ) |
| return new jQuery.Event(src); |
| |
| // Event object |
| if( src && src.type ){ |
| this.originalEvent = src; |
| this.type = src.type; |
| // Event type |
| }else |
| this.type = src; |
| |
| // timeStamp is buggy for some events on Firefox(#3843) |
| // So we won't rely on the native value |
| this.timeStamp = now(); |
| |
| // Mark it as fixed |
| this[expando] = true; |
| }; |
| |
| function returnFalse(){ |
| return false; |
| } |
| function returnTrue(){ |
| return true; |
| } |
| |
| // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding |
| // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html |
| jQuery.Event.prototype = { |
| preventDefault: function() { |
| this.isDefaultPrevented = returnTrue; |
| |
| var e = this.originalEvent; |
| if( !e ) |
| return; |
| // if preventDefault exists run it on the original event |
| if (e.preventDefault) |
| e.preventDefault(); |
| // otherwise set the returnValue property of the original event to false (IE) |
| e.returnValue = false; |
| }, |
| stopPropagation: function() { |
| this.isPropagationStopped = returnTrue; |
| |
| var e = this.originalEvent; |
| if( !e ) |
| return; |
| // if stopPropagation exists run it on the original event |
| if (e.stopPropagation) |
| e.stopPropagation(); |
| // otherwise set the cancelBubble property of the original event to true (IE) |
| e.cancelBubble = true; |
| }, |
| stopImmediatePropagation:function(){ |
| this.isImmediatePropagationStopped = returnTrue; |
| this.stopPropagation(); |
| }, |
| isDefaultPrevented: returnFalse, |
| isPropagationStopped: returnFalse, |
| isImmediatePropagationStopped: returnFalse |
| }; |
| // Checks if an event happened on an element within another element |
| // Used in jQuery.event.special.mouseenter and mouseleave handlers |
| var withinElement = function(event) { |
| // Check if mouse(over|out) are still within the same parent element |
| var parent = event.relatedTarget; |
| // Traverse up the tree |
| while ( parent && parent != this ) |
| try { parent = parent.parentNode; } |
| catch(e) { parent = this; } |
| |
| if( parent != this ){ |
| // set the correct event type |
| event.type = event.data; |
| // handle event if we actually just moused on to a non sub-element |
| jQuery.event.handle.apply( this, arguments ); |
| } |
| }; |
| |
| jQuery.each({ |
| mouseover: 'mouseenter', |
| mouseout: 'mouseleave' |
| }, function( orig, fix ){ |
| jQuery.event.special[ fix ] = { |
| setup: function(){ |
| jQuery.event.add( this, orig, withinElement, fix ); |
| }, |
| teardown: function(){ |
| jQuery.event.remove( this, orig, withinElement ); |
| } |
| }; |
| }); |
| |
| jQuery.fn.extend({ |
| bind: function( type, data, fn ) { |
| return type == "unload" ? this.one(type, data, fn) : this.each(function(){ |
| jQuery.event.add( this, type, fn || data, fn && data ); |
| }); |
| }, |
| |
| one: function( type, data, fn ) { |
| var one = jQuery.event.proxy( fn || data, function(event) { |
| jQuery(this).unbind(event, one); |
| return (fn || data).apply( this, arguments ); |
| }); |
| return this.each(function(){ |
| jQuery.event.add( this, type, one, fn && data); |
| }); |
| }, |
| |
| unbind: function( type, fn ) { |
| return this.each(function(){ |
| jQuery.event.remove( this, type, fn ); |
| }); |
| }, |
| |
| trigger: function( type, data ) { |
| return this.each(function(){ |
| jQuery.event.trigger( type, data, this ); |
| }); |
| }, |
| |
| triggerHandler: function( type, data ) { |
| if( this[0] ){ |
| var event = jQuery.Event(type); |
| event.preventDefault(); |
| event.stopPropagation(); |
| jQuery.event.trigger( event, data, this[0] ); |
| return event.result; |
| } |
| }, |
| |
| toggle: function( fn ) { |
| // Save reference to arguments for access in closure |
| var args = arguments, i = 1; |
| |
| // link all the functions, so any of them can unbind this click handler |
| while( i < args.length ) |
| jQuery.event.proxy( fn, args[i++] ); |
| |
| return this.click( jQuery.event.proxy( fn, function(event) { |
| // Figure out which function to execute |
| this.lastToggle = ( this.lastToggle || 0 ) % i; |
| |
| // Make sure that clicks stop |
| event.preventDefault(); |
| |
| // and execute the function |
| return args[ this.lastToggle++ ].apply( this, arguments ) || false; |
| })); |
| }, |
| |
| hover: function(fnOver, fnOut) { |
| return this.mouseenter(fnOver).mouseleave(fnOut); |
| }, |
| |
| ready: function(fn) { |
| // Attach the listeners |
| bindReady(); |
| |
| // If the DOM is already ready |
| if ( jQuery.isReady ) |
| // Execute the function immediately |
| fn.call( document, jQuery ); |
| |
| // Otherwise, remember the function for later |
| else |
| // Add the function to the wait list |
| jQuery.readyList.push( fn ); |
| |
| return this; |
| }, |
| |
| live: function( type, fn ){ |
| var proxy = jQuery.event.proxy( fn ); |
| proxy.guid += this.selector + type; |
| |
| jQuery(document).bind( liveConvert(type, this.selector), this.selector, proxy ); |
| |
| return this; |
| }, |
| |
| die: function( type, fn ){ |
| jQuery(document).unbind( liveConvert(type, this.selector), fn ? { guid: fn.guid + this.selector + type } : null ); |
| return this; |
| } |
| }); |
| |
| function liveHandler( event ){ |
| var check = RegExp("(^|\\.)" + event.type + "(\\.|$)"), |
| stop = true, |
| elems = []; |
| |
| jQuery.each(jQuery.data(this, "events").live || [], function(i, fn){ |
| if ( check.test(fn.type) ) { |
| var elem = jQuery(event.target).closest(fn.data)[0]; |
| if ( elem ) |
| elems.push({ elem: elem, fn: fn }); |
| } |
| }); |
| |
| elems.sort(function(a,b) { |
| return jQuery.data(a.elem, "closest") - jQuery.data(b.elem, "closest"); |
| }); |
| |
| jQuery.each(elems, function(){ |
| if ( this.fn.call(this.elem, event, this.fn.data) === false ) |
| return (stop = false); |
| }); |
| |
| return stop; |
| } |
| |
| function liveConvert(type, selector){ |
| return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join("."); |
| } |
| |
| jQuery.extend({ |
| isReady: false, |
| readyList: [], |
| // Handle when the DOM is ready |
| ready: function() { |
| // Make sure that the DOM is not already loaded |
| if ( !jQuery.isReady ) { |
| // Remember that the DOM is ready |
| jQuery.isReady = true; |
| |
| // If there are functions bound, to execute |
| if ( jQuery.readyList ) { |
| // Execute all of them |
| jQuery.each( jQuery.readyList, function(){ |
| this.call( document, jQuery ); |
| }); |
| |
| // Reset the list of functions |
| jQuery.readyList = null; |
| } |
| |
| // Trigger any bound ready events |
| jQuery(document).triggerHandler("ready"); |
| } |
| } |
| }); |
| |
| var readyBound = false; |
| |
| function bindReady(){ |
| if ( readyBound ) return; |
| readyBound = true; |
| |
| // Mozilla, Opera and webkit nightlies currently support this event |
| if ( document.addEventListener ) { |
| // Use the handy event callback |
| document.addEventListener( "DOMContentLoaded", function(){ |
| document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
| jQuery.ready(); |
| }, false ); |
| |
| // If IE event model is used |
| } else if ( document.attachEvent ) { |
| // ensure firing before onload, |
| // maybe late but safe also for iframes |
| document.attachEvent("onreadystatechange", function(){ |
| if ( document.readyState === "complete" ) { |
| document.detachEvent( "onreadystatechange", arguments.callee ); |
| jQuery.ready(); |
| } |
| }); |
| |
| // If IE and not an iframe |
| // continually check to see if the document is ready |
| if ( document.documentElement.doScroll && window == window.top ) (function(){ |
| if ( jQuery.isReady ) return; |
| |
| try { |
| // If IE is used, use the trick by Diego Perini |
| // http://javascript.nwbox.com/IEContentLoaded/ |
| document.documentElement.doScroll("left"); |
| } catch( error ) { |
| setTimeout( arguments.callee, 0 ); |
| return; |
| } |
| |
| // and execute any waiting functions |
| jQuery.ready(); |
| })(); |
| } |
| |
| // A fallback to window.onload, that will always work |
| jQuery.event.add( window, "load", jQuery.ready ); |
| } |
| |
| jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + |
| "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," + |
| "change,select,submit,keydown,keypress,keyup,error").split(","), function(i, name){ |
| |
| // Handle event binding |
| jQuery.fn[name] = function(fn){ |
| return fn ? this.bind(name, fn) : this.trigger(name); |
| }; |
| }); |
| |
| // Prevent memory leaks in IE |
| // And prevent errors on refresh with events like mouseover in other browsers |
| // Window isn't included so as not to unbind existing unload events |
| jQuery( window ).bind( 'unload', function(){ |
| for ( var id in jQuery.cache ) |
| // Skip the window |
| if ( id != 1 && jQuery.cache[ id ].handle ) |
| jQuery.event.remove( jQuery.cache[ id ].handle.elem ); |
| }); |
| (function(){ |
| |
| jQuery.support = {}; |
| |
| var root = document.documentElement, |
| script = document.createElement("script"), |
| div = document.createElement("div"), |
| id = "script" + (new Date).getTime(); |
| |
| div.style.display = "none"; |
| div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>'; |
| |
| var all = div.getElementsByTagName("*"), |
| a = div.getElementsByTagName("a")[0]; |
| |
| // Can't get basic test support |
| if ( !all || !all.length || !a ) { |
| return; |
| } |
| |
| jQuery.support = { |
| // IE strips leading whitespace when .innerHTML is used |
| leadingWhitespace: div.firstChild.nodeType == 3, |
| |
| // Make sure that tbody elements aren't automatically inserted |
| // IE will insert them into empty tables |
| tbody: !div.getElementsByTagName("tbody").length, |
| |
| // Make sure that you can get all elements in an <object> element |
| // IE 7 always returns no results |
| objectAll: !!div.getElementsByTagName("object")[0] |
| .getElementsByTagName("*").length, |
| |
| // Make sure that link elements get serialized correctly by innerHTML |
| // This requires a wrapper element in IE |
| htmlSerialize: !!div.getElementsByTagName("link").length, |
| |
| // Get the style information from getAttribute |
| // (IE uses .cssText insted) |
| style: /red/.test( a.getAttribute("style") ), |
| |
| // Make sure that URLs aren't manipulated |
| // (IE normalizes it by default) |
| hrefNormalized: a.getAttribute("href") === "/a", |
| |
| // Make sure that element opacity exists |
| // (IE uses filter instead) |
| opacity: a.style.opacity === "0.5", |
| |
| // Verify style float existence |
| // (IE uses styleFloat instead of cssFloat) |
| cssFloat: !!a.style.cssFloat, |
| |
| // Will be defined later |
| scriptEval: false, |
| noCloneEvent: true, |
| boxModel: null |
| }; |
| |
| script.type = "text/javascript"; |
| try { |
| script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
| } catch(e){} |
| |
| root.insertBefore( script, root.firstChild ); |
| |
| // Make sure that the execution of code works by injecting a script |
| // tag with appendChild/createTextNode |
| // (IE doesn't support this, fails, and uses .text instead) |
| if ( window[ id ] ) { |
| jQuery.support.scriptEval = true; |
| delete window[ id ]; |
| } |
| |
| root.removeChild( script ); |
| |
| if ( div.attachEvent && div.fireEvent ) { |
| div.attachEvent("onclick", function(){ |
| // Cloning a node shouldn't copy over any |
| // bound event handlers (IE does this) |
| jQuery.support.noCloneEvent = false; |
| div.detachEvent("onclick", arguments.callee); |
| }); |
| div.cloneNode(true).fireEvent("onclick"); |
| } |
| |
| // Figure out if the W3C box model works as expected |
| // document.body must exist before we can do this |
| jQuery(function(){ |
| var div = document.createElement("div"); |
| div.style.width = div.style.paddingLeft = "1px"; |
| |
| document.body.appendChild( div ); |
| jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
| document.body.removeChild( div ).style.display = 'none'; |
| }); |
| })(); |
| |
| var styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat"; |
| |
| jQuery.props = { |
| "for": "htmlFor", |
| "class": "className", |
| "float": styleFloat, |
| cssFloat: styleFloat, |
| styleFloat: styleFloat, |
| readonly: "readOnly", |
| maxlength: "maxLength", |
| cellspacing: "cellSpacing", |
| rowspan: "rowSpan", |
| tabindex: "tabIndex" |
| }; |
| jQuery.fn.extend({ |
| // Keep a copy of the old load |
| _load: jQuery.fn.load, |
| |
| load: function( url, params, callback ) { |
| if ( typeof url !== "string" ) |
| return this._load( url ); |
| |
| var off = url.indexOf(" "); |
| if ( off >= 0 ) { |
| var selector = url.slice(off, url.length); |
| url = url.slice(0, off); |
| } |
| |
| // Default to a GET request |
| var type = "GET"; |
| |
| // If the second parameter was provided |
| if ( params ) |
| // If it's a function |
| if ( jQuery.isFunction( params ) ) { |
| // We assume that it's the callback |
| callback = params; |
| params = null; |
| |
| // Otherwise, build a param string |
| } else if( typeof params === "object" ) { |
| params = jQuery.param( params ); |
| type = "POST"; |
| } |
| |
| var self = this; |
| |
| // Request the remote document |
| jQuery.ajax({ |
| url: url, |
| type: type, |
| dataType: "html", |
| data: params, |
| complete: function(res, status){ |
| // If successful, inject the HTML into all the matched elements |
| if ( status == "success" || status == "notmodified" ) |
| // See if a selector was specified |
| self.html( selector ? |
| // Create a dummy div to hold the results |
| jQuery("<div/>") |
| // inject the contents of the document in, removing the scripts |
| // to avoid any 'Permission Denied' errors in IE |
| .append(res.responseText.replace(/<script(.|\s)*?\/script>/g, "")) |
| |
| // Locate the specified elements |
| .find(selector) : |
| |
| // If not, just inject the full result |
| res.responseText ); |
| |
| if( callback ) |
| self.each( callback, [res.responseText, status, res] ); |
| } |
| }); |
| return this; |
| }, |
| |
| serialize: function() { |
| return jQuery.param(this.serializeArray()); |
| }, |
| serializeArray: function() { |
| return this.map(function(){ |
| return this.elements ? jQuery.makeArray(this.elements) : this; |
| }) |
| .filter(function(){ |
| return this.name && !this.disabled && |
| (this.checked || /select|textarea/i.test(this.nodeName) || |
| /text|hidden|password|search/i.test(this.type)); |
| }) |
| .map(function(i, elem){ |
| var val = jQuery(this).val(); |
| return val == null ? null : |
| jQuery.isArray(val) ? |
| jQuery.map( val, function(val, i){ |
| return {name: elem.name, value: val}; |
| }) : |
| {name: elem.name, value: val}; |
| }).get(); |
| } |
| }); |
| |
| // Attach a bunch of functions for handling common AJAX events |
| jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){ |
| jQuery.fn[o] = function(f){ |
| return this.bind(o, f); |
| }; |
| }); |
| |
| var jsc = now(); |
| |
| jQuery.extend({ |
| |
| get: function( url, data, callback, type ) { |
| // shift arguments if data argument was ommited |
| if ( jQuery.isFunction( data ) ) { |
| callback = data; |
| data = null; |
| } |
| |
| return jQuery.ajax({ |
| type: "GET", |
| url: url, |
| data: data, |
| success: callback, |
| dataType: type |
| }); |
| }, |
| |
| getScript: function( url, callback ) { |
| return jQuery.get(url, null, callback, "script"); |
| }, |
| |
| getJSON: function( url, data, callback ) { |
| return jQuery.get(url, data, callback, "json"); |
| }, |
| |
| post: function( url, data, callback, type ) { |
| if ( jQuery.isFunction( data ) ) { |
| callback = data; |
| data = {}; |
| } |
| |
| return jQuery.ajax({ |
| type: "POST", |
| url: url, |
| data: data, |
| success: callback, |
| dataType: type |
| }); |
| }, |
| |
| ajaxSetup: function( settings ) { |
| jQuery.extend( jQuery.ajaxSettings, settings ); |
| }, |
| |
| ajaxSettings: { |
| url: location.href, |
| global: true, |
| type: "GET", |
| contentType: "application/x-www-form-urlencoded", |
| processData: true, |
| async: true, |
| /* |
| timeout: 0, |
| data: null, |
| username: null, |
| password: null, |
| */ |
| // Create the request object; Microsoft failed to properly |
| // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available |
| // This function can be overriden by calling jQuery.ajaxSetup |
| xhr:function(){ |
| return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); |
| }, |
| accepts: { |
| xml: "application/xml, text/xml", |
| html: "text/html", |
| script: "text/javascript, application/javascript", |
| json: "application/json, text/javascript", |
| text: "text/plain", |
| _default: "*/*" |
| } |
| }, |
| |
| // Last-Modified header cache for next request |
| lastModified: {}, |
| |
| ajax: function( s ) { |
| // Extend the settings, but re-extend 's' so that it can be |
| // checked again later (in the test suite, specifically) |
| s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); |
| |
| var jsonp, jsre = /=\?(&|$)/g, status, data, |
| type = s.type.toUpperCase(); |
| |
| // convert data if not already a string |
| if ( s.data && s.processData && typeof s.data !== "string" ) |
| s.data = jQuery.param(s.data); |
| |
| // Handle JSONP Parameter Callbacks |
| if ( s.dataType == "jsonp" ) { |
| if ( type == "GET" ) { |
| if ( !s.url.match(jsre) ) |
| s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
| } else if ( !s.data || !s.data.match(jsre) ) |
| s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
| s.dataType = "json"; |
| } |
| |
| // Build temporary JSONP function |
| if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) { |
| jsonp = "jsonp" + jsc++; |
| |
| // Replace the =? sequence both in the query string and the data |
| if ( s.data ) |
| s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
| s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
| |
| // We need to make sure |
| // that a JSONP style response is executed properly |
| s.dataType = "script"; |
| |
| // Handle JSONP-style loading |
| window[ jsonp ] = function(tmp){ |
| data = tmp; |
| success(); |
| complete(); |
| // Garbage collect |
| window[ jsonp ] = undefined; |
| try{ delete window[ jsonp ]; } catch(e){} |
| if ( head ) |
| head.removeChild( script ); |
| }; |
| } |
| |
| if ( s.dataType == "script" && s.cache == null ) |
| s.cache = false; |
| |
| if ( s.cache === false && type == "GET" ) { |
| var ts = now(); |
| // try replacing _= if it is there |
| var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2"); |
| // if nothing was replaced, add timestamp to the end |
| s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : ""); |
| } |
| |
| // If data is available, append data to url for get requests |
| if ( s.data && type == "GET" ) { |
| s.url += (s.url.match(/\?/) ? "&" : "?") + s.data; |
| |
| // IE likes to send both get and post data, prevent this |
| s.data = null; |
| } |
| |
| // Watch for a new set of requests |
| if ( s.global && ! jQuery.active++ ) |
| jQuery.event.trigger( "ajaxStart" ); |
| |
| // Matches an absolute URL, and saves the domain |
| var parts = /^(\w+:)?\/\/([^\/?#]+)/.exec( s.url ); |
| |
| // If we're requesting a remote document |
| // and trying to load JSON or Script with a GET |
| if ( s.dataType == "script" && type == "GET" && parts |
| && ( parts[1] && parts[1] != location.protocol || parts[2] != location.host )){ |
| |
| var head = document.getElementsByTagName("head")[0]; |
| var script = document.createElement("script"); |
| script.src = s.url; |
| if (s.scriptCharset) |
| script.charset = s.scriptCharset; |
| |
| // Handle Script loading |
| if ( !jsonp ) { |
| var done = false; |
| |
| // Attach handlers for all browsers |
| script.onload = script.onreadystatechange = function(){ |
| if ( !done && (!this.readyState || |
| this.readyState == "loaded" || this.readyState == "complete") ) { |
| done = true; |
| success(); |
| complete(); |
| |
| // Handle memory leak in IE |
| script.onload = script.onreadystatechange = null; |
| head.removeChild( script ); |
| } |
| }; |
| } |
| |
| head.appendChild(script); |
| |
| // We handle everything using the script element injection |
| return undefined; |
| } |
| |
| var requestDone = false; |
| |
| // Create the request object |
| var xhr = s.xhr(); |
| |
| // Open the socket |
| // Passing null username, generates a login popup on Opera (#2865) |
| if( s.username ) |
| xhr.open(type, s.url, s.async, s.username, s.password); |
| else |
| xhr.open(type, s.url, s.async); |
| |
| // Need an extra try/catch for cross domain requests in Firefox 3 |
| try { |
| // Set the correct header, if data is being sent |
| if ( s.data ) |
| xhr.setRequestHeader("Content-Type", s.contentType); |
| |
| // Set the If-Modified-Since header, if ifModified mode. |
| if ( s.ifModified ) |
| xhr.setRequestHeader("If-Modified-Since", |
| jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" ); |
| |
| // Set header so the called script knows that it's an XMLHttpRequest |
| xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
| |
| // Set the Accepts header for the server, depending on the dataType |
| xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ? |
| s.accepts[ s.dataType ] + ", */*" : |
| s.accepts._default ); |
| } catch(e){} |
| |
| // Allow custom headers/mimetypes and early abort |
| if ( s.beforeSend && s.beforeSend(xhr, s) === false ) { |
| // Handle the global AJAX counter |
| if ( s.global && ! --jQuery.active ) |
| jQuery.event.trigger( "ajaxStop" ); |
| // close opended socket |
| xhr.abort(); |
| return false; |
| } |
| |
| if ( s.global ) |
| jQuery.event.trigger("ajaxSend", [xhr, s]); |
| |
| // Wait for a response to come back |
| var onreadystatechange = function(isTimeout){ |
| // The request was aborted, clear the interval and decrement jQuery.active |
| if (xhr.readyState == 0) { |
| if (ival) { |
| // clear poll interval |
| clearInterval(ival); |
| ival = null; |
| // Handle the global AJAX counter |
| if ( s.global && ! --jQuery.active ) |
| jQuery.event.trigger( "ajaxStop" ); |
| } |
| // The transfer is complete and the data is available, or the request timed out |
| } else if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) { |
| requestDone = true; |
| |
| // clear poll interval |
| if (ival) { |
| clearInterval(ival); |
| ival = null; |
| } |
| |
| status = isTimeout == "timeout" ? "timeout" : |
| !jQuery.httpSuccess( xhr ) ? "error" : |
| s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? "notmodified" : |
| "success"; |
| |
| if ( status == "success" ) { |
| // Watch for, and catch, XML document parse errors |
| try { |
| // process the data (runs the xml through httpData regardless of callback) |
| data = jQuery.httpData( xhr, s.dataType, s ); |
| } catch(e) { |
| status = "parsererror"; |
| } |
| } |
| |
| // Make sure that the request was successful or notmodified |
| if ( status == "success" ) { |
| // Cache Last-Modified header, if ifModified mode. |
| var modRes; |
| try { |
| modRes = xhr.getResponseHeader("Last-Modified"); |
| } catch(e) {} // swallow exception thrown by FF if header is not available |
| |
| if ( s.ifModified && modRes ) |
| jQuery.lastModified[s.url] = modRes; |
| |
| // JSONP handles its own success callback |
| if ( !jsonp ) |
| success(); |
| } else |
| jQuery.handleError(s, xhr, status); |
| |
| // Fire the complete handlers |
| complete(); |
| |
| if ( isTimeout ) |
| xhr.abort(); |
| |
| // Stop memory leaks |
| if ( s.async ) |
| xhr = null; |
| } |
| }; |
| |
| if ( s.async ) { |
| // don't attach the handler to the request, just poll it instead |
| var ival = setInterval(onreadystatechange, 13); |
| |
| // Timeout checker |
| if ( s.timeout > 0 ) |
| setTimeout(function(){ |
| // Check to see if the request is still happening |
| if ( xhr && !requestDone ) |
| onreadystatechange( "timeout" ); |
| }, s.timeout); |
| } |
| |
| // Send the data |
| try { |
| xhr.send(s.data); |
| } catch(e) { |
| jQuery.handleError(s, xhr, null, e); |
| } |
| |
| // firefox 1.5 doesn't fire statechange for sync requests |
| if ( !s.async ) |
| onreadystatechange(); |
| |
| function success(){ |
| // If a local callback was specified, fire it and pass it the data |
| if ( s.success ) |
| s.success( data, status ); |
| |
| // Fire the global callback |
| if ( s.global ) |
| jQuery.event.trigger( "ajaxSuccess", [xhr, s] ); |
| } |
| |
| function complete(){ |
| // Process result |
| if ( s.complete ) |
| s.complete(xhr, status); |
| |
| // The request was completed |
| if ( s.global ) |
| jQuery.event.trigger( "ajaxComplete", [xhr, s] ); |
| |
| // Handle the global AJAX counter |
| if ( s.global && ! --jQuery.active ) |
| jQuery.event.trigger( "ajaxStop" ); |
| } |
| |
| // return XMLHttpRequest to allow aborting the request etc. |
| return xhr; |
| }, |
| |
| handleError: function( s, xhr, status, e ) { |
| // If a local callback was specified, fire it |
| if ( s.error ) s.error( xhr, status, e ); |
| |
| // Fire the global callback |
| if ( s.global ) |
| jQuery.event.trigger( "ajaxError", [xhr, s, e] ); |
| }, |
| |
| // Counter for holding the number of active queries |
| active: 0, |
| |
| // Determines if an XMLHttpRequest was successful or not |
| httpSuccess: function( xhr ) { |
| try { |
| // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450 |
| return !xhr.status && location.protocol == "file:" || |
| ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223; |
| } catch(e){} |
| return false; |
| }, |
| |
| // Determines if an XMLHttpRequest returns NotModified |
| httpNotModified: function( xhr, url ) { |
| try { |
| var xhrRes = xhr.getResponseHeader("Last-Modified"); |
| |
| // Firefox always returns 200. check Last-Modified date |
| return xhr.status == 304 || xhrRes == jQuery.lastModified[url]; |
| } catch(e){} |
| return false; |
| }, |
| |
| httpData: function( xhr, type, s ) { |
| var ct = xhr.getResponseHeader("content-type"), |
| xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0, |
| data = xml ? xhr.responseXML : xhr.responseText; |
| |
| if ( xml && data.documentElement.tagName == "parsererror" ) |
| throw "parsererror"; |
| |
| // Allow a pre-filtering function to sanitize the response |
| // s != null is checked to keep backwards compatibility |
| if( s && s.dataFilter ) |
| data = s.dataFilter( data, type ); |
| |
| // The filter can actually parse the response |
| if( typeof data === "string" ){ |
| |
| // If the type is "script", eval it in global context |
| if ( type == "script" ) |
| jQuery.globalEval( data ); |
| |
| // Get the JavaScript object, if JSON is used. |
| if ( type == "json" ) |
| data = window["eval"]("(" + data + ")"); |
| } |
| |
| return data; |
| }, |
| |
| // Serialize an array of form elements or a set of |
| // key/values into a query string |
| param: function( a ) { |
| var s = [ ]; |
| |
| function add( key, value ){ |
| s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); |
| }; |
| |
| // If an array was passed in, assume that it is an array |
| // of form elements |
| if ( jQuery.isArray(a) || a.jquery ) |
| // Serialize the form elements |
| jQuery.each( a, function(){ |
| add( this.name, this.value ); |
| }); |
| |
| // Otherwise, assume that it's an object of key/value pairs |
| else |
| // Serialize the key/values |
| for ( var j in a ) |
| // If the value is an array then the key names need to be repeated |
| if ( jQuery.isArray(a[j]) ) |
| jQuery.each( a[j], function(){ |
| add( j, this ); |
| }); |
| else |
| add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] ); |
| |
| // Return the resulting serialization |
| return s.join("&").replace(/%20/g, "+"); |
| } |
| |
| }); |
| var elemdisplay = {}, |
| timerId, |
| fxAttrs = [ |
| // height animations |
| [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ], |
| // width animations |
| [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ], |
| // opacity animations |
| [ "opacity" ] |
| ]; |
| |
| function genFx( type, num ){ |
| var obj = {}; |
| jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function(){ |
| obj[ this ] = type; |
| }); |
| return obj; |
| } |
| |
| jQuery.fn.extend({ |
| show: function(speed,callback){ |
| if ( speed ) { |
| return this.animate( genFx("show", 3), speed, callback); |
| } else { |
| for ( var i = 0, l = this.length; i < l; i++ ){ |
| var old = jQuery.data(this[i], "olddisplay"); |
| |
| this[i].style.display = old || ""; |
| |
| if ( jQuery.css(this[i], "display") === "none" ) { |
| var tagName = this[i].tagName, display; |
| |
| if ( elemdisplay[ tagName ] ) { |
| display = elemdisplay[ tagName ]; |
| } else { |
| var elem = jQuery("<" + tagName + " />").appendTo("body"); |
| |
| display = elem.css("display"); |
| if ( display === "none" ) |
| display = "block"; |
| |
| elem.remove(); |
| |
| elemdisplay[ tagName ] = display; |
| } |
| |
| jQuery.data(this[i], "olddisplay", display); |
| } |
| } |
| |
| // Set the display of the elements in a second loop |
| // to avoid the constant reflow |
| for ( var i = 0, l = this.length; i < l; i++ ){ |
| this[i].style.display = jQuery.data(this[i], "olddisplay") || ""; |
| } |
| |
| return this; |
| } |
| }, |
| |
| hide: function(speed,callback){ |
| if ( speed ) { |
| return this.animate( genFx("hide", 3), speed, callback); |
| } else { |
| for ( var i = 0, l = this.length; i < l; i++ ){ |
| var old = jQuery.data(this[i], "olddisplay"); |
| if ( !old && old !== "none" ) |
| jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display")); |
| } |
| |
| // Set the display of the elements in a second loop |
| // to avoid the constant reflow |
| for ( var i = 0, l = this.length; i < l; i++ ){ |
| this[i].style.display = "none"; |
| } |
| |
| return this; |
| } |
| }, |
| |
| // Save the old toggle function |
| _toggle: jQuery.fn.toggle, |
| |
| toggle: function( fn, fn2 ){ |
| var bool = typeof fn === "boolean"; |
| |
| return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? |
| this._toggle.apply( this, arguments ) : |
| fn == null || bool ? |
| this.each(function(){ |
| var state = bool ? fn : jQuery(this).is(":hidden"); |
| jQuery(this)[ state ? "show" : "hide" ](); |
| }) : |
| this.animate(genFx("toggle", 3), fn, fn2); |
| }, |
| |
| fadeTo: function(speed,to,callback){ |
| return this.animate({opacity: to}, speed, callback); |
| }, |
| |
| animate: function( prop, speed, easing, callback ) { |
| var optall = jQuery.speed(speed, easing, callback); |
| |
| return this[ optall.queue === false ? "each" : "queue" ](function(){ |
| |
| var opt = jQuery.extend({}, optall), p, |
| hidden = this.nodeType == 1 && jQuery(this).is(":hidden"), |
| self = this; |
| |
| for ( p in prop ) { |
| if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) |
| return opt.complete.call(this); |
| |
| if ( ( p == "height" || p == "width" ) && this.style ) { |
| // Store display property |
| opt.display = jQuery.css(this, "display"); |
| |
| // Make sure that nothing sneaks out |
| opt.overflow = this.style.overflow; |
| } |
| } |
| |
| if ( opt.overflow != null ) |
| this.style.overflow = "hidden"; |
| |
| opt.curAnim = jQuery.extend({}, prop); |
| |
| jQuery.each( prop, function(name, val){ |
| var e = new jQuery.fx( self, opt, name ); |
| |
| if ( /toggle|show|hide/.test(val) ) |
| e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); |
| else { |
| var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/), |
| start = e.cur(true) || 0; |
| |
| if ( parts ) { |
| var end = parseFloat(parts[2]), |
| unit = parts[3] || "px"; |
| |
| // We need to compute starting value |
| if ( unit != "px" ) { |
| self.style[ name ] = (end || 1) + unit; |
| start = ((end || 1) / e.cur(true)) * start; |
| self.style[ name ] = start + unit; |
| } |
| |
| // If a +=/-= token was provided, we're doing a relative animation |
| if ( parts[1] ) |
| end = ((parts[1] == "-=" ? -1 : 1) * end) + start; |
| |
| e.custom( start, end, unit ); |
| } else |
| e.custom( start, val, "" ); |
| } |
| }); |
| |
| // For JS strict compliance |
| return true; |
| }); |
| }, |
| |
| stop: function(clearQueue, gotoEnd){ |
| var timers = jQuery.timers; |
| |
| if (clearQueue) |
| this.queue([]); |
| |
| this.each(function(){ |
| // go in reverse order so anything added to the queue during the loop is ignored |
| for ( var i = timers.length - 1; i >= 0; i-- ) |
| if ( timers[i].elem == this ) { |
| if (gotoEnd) |
| // force the next step to be the last |
| timers[i](true); |
| timers.splice(i, 1); |
| } |
| }); |
| |
| // start the next in the queue if the last step wasn't forced |
| if (!gotoEnd) |
| this.dequeue(); |
| |
| return this; |
| } |
| |
| }); |
| |
| // Generate shortcuts for custom animations |
| jQuery.each({ |
| slideDown: genFx("show", 1), |
| slideUp: genFx("hide", 1), |
| slideToggle: genFx("toggle", 1), |
| fadeIn: { opacity: "show" }, |
| fadeOut: { opacity: "hide" } |
| }, function( name, props ){ |
| jQuery.fn[ name ] = function( speed, callback ){ |
| return this.animate( props, speed, callback ); |
| }; |
| }); |
| |
| jQuery.extend({ |
| |
| speed: function(speed, easing, fn) { |
| var opt = typeof speed === "object" ? speed : { |
| complete: fn || !fn && easing || |
| jQuery.isFunction( speed ) && speed, |
| duration: speed, |
| easing: fn && easing || easing && !jQuery.isFunction(easing) && easing |
| }; |
| |
| opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : |
| jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default; |
| |
| // Queueing |
| opt.old = opt.complete; |
| opt.complete = function(){ |
| if ( opt.queue !== false ) |
| jQuery(this).dequeue(); |
| if ( jQuery.isFunction( opt.old ) ) |
| opt.old.call( this ); |
| }; |
| |
| return opt; |
| }, |
| |
| easing: { |
| linear: function( p, n, firstNum, diff ) { |
| return firstNum + diff * p; |
| }, |
| swing: function( p, n, firstNum, diff ) { |
| return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum; |
| } |
| }, |
| |
| timers: [], |
| |
| fx: function( elem, options, prop ){ |
| this.options = options; |
| this.elem = elem; |
| this.prop = prop; |
| |
| if ( !options.orig ) |
| options.orig = {}; |
| } |
| |
| }); |
| |
| jQuery.fx.prototype = { |
| |
| // Simple function for setting a style value |
| update: function(){ |
| if ( this.options.step ) |
| this.options.step.call( this.elem, this.now, this ); |
| |
| (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this ); |
| |
| // Set display property to block for height/width animations |
| if ( ( this.prop == "height" || this.prop == "width" ) && this.elem.style ) |
| this.elem.style.display = "block"; |
| }, |
| |
| // Get the current size |
| cur: function(force){ |
| if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) |
| return this.elem[ this.prop ]; |
| |
| var r = parseFloat(jQuery.css(this.elem, this.prop, force)); |
| return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0; |
| }, |
| |
| // Start an animation from one number to another |
| custom: function(from, to, unit){ |
| this.startTime = now(); |
| this.start = from; |
| this.end = to; |
| this.unit = unit || this.unit || "px"; |
| this.now = this.start; |
| this.pos = this.state = 0; |
| |
| var self = this; |
| function t(gotoEnd){ |
| return self.step(gotoEnd); |
| } |
| |
| t.elem = this.elem; |
| |
| if ( t() && jQuery.timers.push(t) && !timerId ) { |
| timerId = setInterval(function(){ |
| var timers = jQuery.timers; |
| |
| for ( var i = 0; i < timers.length; i++ ) |
| if ( !timers[i]() ) |
| timers.splice(i--, 1); |
| |
| if ( !timers.length ) { |
| clearInterval( timerId ); |
| timerId = undefined; |
| } |
| }, 13); |
| } |
| }, |
| |
| // Simple 'show' function |
| show: function(){ |
| // Remember where we started, so that we can go back to it later |
| this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); |
| this.options.show = true; |
| |
| // Begin the animation |
| // Make sure that we start at a small width/height to avoid any |
| // flash of content |
| this.custom(this.prop == "width" || this.prop == "height" ? 1 : 0, this.cur()); |
| |
| // Start by showing the element |
| jQuery(this.elem).show(); |
| }, |
| |
| // Simple 'hide' function |
| hide: function(){ |
| // Remember where we started, so that we can go back to it later |
| this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); |
| this.options.hide = true; |
| |
| // Begin the animation |
| this.custom(this.cur(), 0); |
| }, |
| |
| // Each step of an animation |
| step: function(gotoEnd){ |
| var t = now(); |
| |
| if ( gotoEnd || t >= this.options.duration + this.startTime ) { |
| this.now = this.end; |
| this.pos = this.state = 1; |
| this.update(); |
| |
| this.options.curAnim[ this.prop ] = true; |
| |
| var done = true; |
| for ( var i in this.options.curAnim ) |
| if ( this.options.curAnim[i] !== true ) |
| done = false; |
| |
| if ( done ) { |
| if ( this.options.display != null ) { |
| // Reset the overflow |
| this.elem.style.overflow = this.options.overflow; |
| |
| // Reset the display |
| this.elem.style.display = this.options.display; |
| if ( jQuery.css(this.elem, "display") == "none" ) |
| this.elem.style.display = "block"; |
| } |
| |
| // Hide the element if the "hide" operation was done |
| if ( this.options.hide ) |
| jQuery(this.elem).hide(); |
| |
| // Reset the properties, if the item has been hidden or shown |
| if ( this.options.hide || this.options.show ) |
| for ( var p in this.options.curAnim ) |
| jQuery.attr(this.elem.style, p, this.options.orig[p]); |
| |
| // Execute the complete function |
| this.options.complete.call( this.elem ); |
| } |
| |
| return false; |
| } else { |
| var n = t - this.startTime; |
| this.state = n / this.options.duration; |
| |
| // Perform the easing function, defaults to swing |
| this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration); |
| this.now = this.start + ((this.end - this.start) * this.pos); |
| |
| // Perform the next step of the animation |
| this.update(); |
| } |
| |
| return true; |
| } |
| |
| }; |
| |
| jQuery.extend( jQuery.fx, { |
| speeds:{ |
| slow: 600, |
| fast: 200, |
| // Default speed |
| _default: 400 |
| }, |
| step: { |
| |
| opacity: function(fx){ |
| jQuery.attr(fx.elem.style, "opacity", fx.now); |
| }, |
| |
| _default: function(fx){ |
| if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) |
| fx.elem.style[ fx.prop ] = fx.now + fx.unit; |
| else |
| fx.elem[ fx.prop ] = fx.now; |
| } |
| } |
| }); |
| if ( document.documentElement["getBoundingClientRect"] ) |
| jQuery.fn.offset = function() { |
| if ( !this[0] ) return { top: 0, left: 0 }; |
| if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] ); |
| var box = this[0].getBoundingClientRect(), doc = this[0].ownerDocument, body = doc.body, docElem = doc.documentElement, |
| clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, |
| top = box.top + (self.pageYOffset || jQuery.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
| left = box.left + (self.pageXOffset || jQuery.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
| return { top: top, left: left }; |
| }; |
| else |
| jQuery.fn.offset = function() { |
| if ( !this[0] ) return { top: 0, left: 0 }; |
| if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] ); |
| jQuery.offset.initialized || jQuery.offset.initialize(); |
| |
| var elem = this[0], offsetParent = elem.offsetParent, prevOffsetParent = elem, |
| doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
| body = doc.body, defaultView = doc.defaultView, |
| prevComputedStyle = defaultView.getComputedStyle(elem, null), |
| top = elem.offsetTop, left = elem.offsetLeft; |
| |
| while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { |
| computedStyle = defaultView.getComputedStyle(elem, null); |
| top -= elem.scrollTop, left -= elem.scrollLeft; |
| if ( elem === offsetParent ) { |
| top += elem.offsetTop, left += elem.offsetLeft; |
| if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.tagName)) ) |
| top += parseInt( computedStyle.borderTopWidth, 10) || 0, |
| left += parseInt( computedStyle.borderLeftWidth, 10) || 0; |
| prevOffsetParent = offsetParent, offsetParent = elem.offsetParent; |
| } |
| if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) |
| top += parseInt( computedStyle.borderTopWidth, 10) || 0, |
| left += parseInt( computedStyle.borderLeftWidth, 10) || 0; |
| prevComputedStyle = computedStyle; |
| } |
| |
| if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) |
| top += body.offsetTop, |
| left += body.offsetLeft; |
| |
| if ( prevComputedStyle.position === "fixed" ) |
| top += Math.max(docElem.scrollTop, body.scrollTop), |
| left += Math.max(docElem.scrollLeft, body.scrollLeft); |
| |
| return { top: top, left: left }; |
| }; |
| |
| jQuery.offset = { |
| initialize: function() { |
| if ( this.initialized ) return; |
| var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, rules, prop, bodyMarginTop = body.style.marginTop, |
| html = '<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>'; |
| |
| rules = { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' }; |
| for ( prop in rules ) container.style[prop] = rules[prop]; |
| |
| container.innerHTML = html; |
| body.insertBefore(container, body.firstChild); |
| innerDiv = container.firstChild, checkDiv = innerDiv.firstChild, td = innerDiv.nextSibling.firstChild.firstChild; |
| |
| this.doesNotAddBorder = (checkDiv.offsetTop !== 5); |
| this.doesAddBorderForTableAndCells = (td.offsetTop === 5); |
| |
| innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative'; |
| this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); |
| |
| body.style.marginTop = '1px'; |
| this.doesNotIncludeMarginInBodyOffset = (body.offsetTop === 0); |
| body.style.marginTop = bodyMarginTop; |
| |
| body.removeChild(container); |
| this.initialized = true; |
| }, |
| |
| bodyOffset: function(body) { |
| jQuery.offset.initialized || jQuery.offset.initialize(); |
| var top = body.offsetTop, left = body.offsetLeft; |
| if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) |
| top += parseInt( jQuery.curCSS(body, 'marginTop', true), 10 ) || 0, |
| left += parseInt( jQuery.curCSS(body, 'marginLeft', true), 10 ) || 0; |
| return { top: top, left: left }; |
| } |
| }; |
| |
| |
| jQuery.fn.extend({ |
| position: function() { |
| var left = 0, top = 0, results; |
| |
| if ( this[0] ) { |
| // Get *real* offsetParent |
| var offsetParent = this.offsetParent(), |
| |
| // Get correct offsets |
| offset = this.offset(), |
| parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset(); |
| |
| // Subtract element margins |
| // note: when an element has margin: auto the offsetLeft and marginLeft |
| // are the same in Safari causing offset.left to incorrectly be 0 |
| offset.top -= num( this, 'marginTop' ); |
| offset.left -= num( this, 'marginLeft' ); |
| |
| // Add offsetParent borders |
| parentOffset.top += num( offsetParent, 'borderTopWidth' ); |
| parentOffset.left += num( offsetParent, 'borderLeftWidth' ); |
| |
| // Subtract the two offsets |
| results = { |
| top: offset.top - parentOffset.top, |
| left: offset.left - parentOffset.left |
| }; |
| } |
| |
| return results; |
| }, |
| |
| offsetParent: function() { |
| var offsetParent = this[0].offsetParent || document.body; |
| while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static') ) |
| offsetParent = offsetParent.offsetParent; |
| return jQuery(offsetParent); |
| } |
| }); |
| |
| |
| // Create scrollLeft and scrollTop methods |
| jQuery.each( ['Left', 'Top'], function(i, name) { |
| var method = 'scroll' + name; |
| |
| jQuery.fn[ method ] = function(val) { |
| if (!this[0]) return null; |
| |
| return val !== undefined ? |
| |
| // Set the scroll offset |
| this.each(function() { |
| this == window || this == document ? |
| window.scrollTo( |
| !i ? val : jQuery(window).scrollLeft(), |
| i ? val : jQuery(window).scrollTop() |
| ) : |
| this[ method ] = val; |
| }) : |
| |
| // Return the scroll offset |
| this[0] == window || this[0] == document ? |
| self[ i ? 'pageYOffset' : 'pageXOffset' ] || |
| jQuery.boxModel && document.documentElement[ method ] || |
| document.body[ method ] : |
| this[0][ method ]; |
| }; |
| }); |
| // Create innerHeight, innerWidth, outerHeight and outerWidth methods |
| jQuery.each([ "Height", "Width" ], function(i, name){ |
| |
| var tl = i ? "Left" : "Top", // top or left |
| br = i ? "Right" : "Bottom", // bottom or right |
| lower = name.toLowerCase(); |
| |
| // innerHeight and innerWidth |
| jQuery.fn["inner" + name] = function(){ |
| return this[0] ? |
| jQuery.css( this[0], lower, false, "padding" ) : |
| null; |
| }; |
| |
| // outerHeight and outerWidth |
| jQuery.fn["outer" + name] = function(margin) { |
| return this[0] ? |
| jQuery.css( this[0], lower, false, margin ? "margin" : "border" ) : |
| null; |
| }; |
| |
| var type = name.toLowerCase(); |
| |
| jQuery.fn[ type ] = function( size ) { |
| // Get window width or height |
| return this[0] == window ? |
| // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode |
| document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || |
| document.body[ "client" + name ] : |
| |
| // Get document width or height |
| this[0] == document ? |
| // Either scroll[Width/Height] or offset[Width/Height], whichever is greater |
| Math.max( |
| document.documentElement["client" + name], |
| document.body["scroll" + name], document.documentElement["scroll" + name], |
| document.body["offset" + name], document.documentElement["offset" + name] |
| ) : |
| |
| // Get or set width or height on the element |
| size === undefined ? |
| // Get width or height on the element |
| (this.length ? jQuery.css( this[0], type ) : null) : |
| |
| // Set the width or height on the element (default to pixels if value is unitless) |
| this.css( type, typeof size === "string" ? size : size + "px" ); |
| }; |
| |
| }); |
| })(); |
| |
| // Contents of jquery.i18n.properties-1.0.4.js |
| |
| /****************************************************************************** |
| * jquery.i18n.properties |
| * |
| * Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and |
| * MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses. |
| * |
| * @version 1.0.x |
| * @author Nuno Fernandes |
| * @url www.codingwithcoffee.com |
| * @inspiration Localisation assistance for jQuery (http://keith-wood.name/localisation.html) |
| * by Keith Wood (kbwood{at}iinet.com.au) June 2007 |
| * |
| *****************************************************************************/ |
| |
| (function($) { |
| $.i18n = {}; |
| |
| /** Map holding bundle keys (if mode: 'map') */ |
| $.i18n.map = {}; |
| |
| |
| |
| $.i18n.properties = function(settings) { |
| // set up settings |
| var defaults = { |
| name: 'Messages', |
| language: '', |
| path: '', |
| mode: 'vars', |
| callback: function(){} |
| }; |
| settings = $.extend(defaults, settings); |
| if(settings.language === null || settings.language == '') { |
| settings.language = normaliseLanguageCode(navigator.language /* Mozilla */ || navigator.userLanguage /* IE */); |
| } |
| if(settings.language === null) {settings.language='';} |
| |
| // load and parse bundle files |
| var files = getFiles(settings.name); |
| for(i=0; i<files.length; i++) { |
| // 1. load base (eg, Messages.properties) |
| //loadAndParseFile(settings.path + files[i] + '.properties', settings.language, settings.mode); |
| // 2. with language code (eg, Messages_pt.properties) |
| if(settings.language.length >= 2) { |
| loadAndParseFile(settings.path + files[i] + '_' + settings.language.substring(0, 2) +'.properties', settings.language, settings.mode); |
| } |
| // 3. with language code and country code (eg, Messages_pt_PT.properties) |
| // if(settings.language.length >= 5) { |
| // loadAndParseFile(settings.path + files[i] + '_' + settings.language.substring(0, 5) +'.properties', settings.language, settings.mode); |
| // } |
| } |
| |
| // call callback |
| if(settings.callback){ settings.callback(); } |
| }; |
| |
| |
| /** |
| * When configured with mode: 'map', allows access to bundle values by specifying its key. |
| * Eg, jQuery.i18n.prop('com.company.bundles.menu_add') |
| */ |
| $.i18n.prop = function(key, placeHolderValues) { |
| var value = $.i18n.map[key]; |
| if(value === null) { return key; } |
| if(!placeHolderValues) { |
| //if(key == 'spv.lbl.modified') {alert(value);} |
| return value; |
| }else{ |
| for(var i=0; i<placeHolderValues.length; i++) { |
| var regexp = new RegExp('\\{('+i+')\\}', "g"); |
| value = value.replace(regexp, placeHolderValues[i]); |
| } |
| return value; |
| } |
| }; |
| |
| |
| /** Load and parse .properties files */ |
| function loadAndParseFile(filename, language, mode) { |
| $.ajax({ |
| url: filename, |
| async: false, |
| contentType: "text/plain;charset=UTF-8", |
| dataType: 'text', |
| error: function(XMLHttpRequest, textStatus, errorThrown) { |
| |
| loadAndParseFile(filename, language, mode); |
| }, |
| success: function(data, status) { |
| var parsed = ''; |
| var parameters = data.split( /\n/ ); |
| var regPlaceHolder = /(\{\d+\})/g; |
| var regRepPlaceHolder = /\{(\d+)\}/g; |
| var unicodeRE = /(\\u.{4})/ig; |
| for(var i=0; i<parameters.length; i++ ) { |
| parameters[i] = parameters[i].replace( /^\s\s*/, '' ).replace( /\s\s*$/, '' ); // trim |
| if(parameters[i].length > 0 && parameters[i].match("^#")!="#") { // skip comments |
| var pair = parameters[i].split('='); |
| if(pair.length > 0) { |
| /** Process key & value */ |
| var name = unescape(pair[0]).replace( /^\s\s*/, '' ).replace( /\s\s*$/, '' ); // trim |
| var value = pair.length == 1 ? "" : pair[1]; |
| value = value.replace( /"/g, '\\"' ); // escape quotation mark (") |
| value = value.replace( /^\s\s*/, '' ).replace( /\s\s*$/, '' ); // trim |
| |
| /** Mode: bundle keys in a map */ |
| if(mode == 'map' || mode == 'both') { |
| // handle unicode chars possibly left out |
| var unicodeMatches = value.match(unicodeRE); |
| if(unicodeMatches) { |
| for(var u=0; u<unicodeMatches.length; u++) { |
| value = value.replace( unicodeMatches[u], unescapeUnicode(unicodeMatches[u])); |
| } |
| } |
| // add to map |
| $.i18n.map[name] = value; |
| } |
| |
| /** Mode: bundle keys as vars/functions */ |
| if(mode == 'vars' || mode == 'both') { |
| // make sure namespaced key exists (eg, 'some.key') |
| checkKeyNamespace(name); |
| |
| // value with variable substitutions |
| if(regPlaceHolder.test(value)) { |
| var parts = value.split(regPlaceHolder); |
| // process function args |
| var first = true; |
| var fnArgs = ''; |
| var usedArgs = []; |
| for(var p=0; p<parts.length; p++) { |
| if(regPlaceHolder.test(parts[p]) && usedArgs.indexOf(parts[p]) == -1) { |
| if(!first) {fnArgs += ',';} |
| fnArgs += parts[p].replace(regRepPlaceHolder, 'v$1'); |
| usedArgs.push(parts[p]); |
| first = false; |
| } |
| } |
| parsed += name + '=function(' + fnArgs + '){'; |
| // process function body |
| var fnExpr = '"' + value.replace(regRepPlaceHolder, '"+v$1+"') + '"'; |
| parsed += 'return ' + fnExpr + ';' + '};'; |
| |
| // simple value |
| }else{ |
| parsed += name+'="'+value+'";'; |
| } |
| } |
| } |
| } |
| } |
| eval(parsed); |
| } |
| }); |
| } |
| |
| /** Make sure namespace exists (for keys with dots in name) */ |
| function checkKeyNamespace(key) { |
| var regDot = /\./g; |
| if(regDot.test(key)) { |
| var fullname = ''; |
| var names = key.split( /\./ ); |
| for(var i=0; i<names.length; i++) { |
| if(i>0) {fullname += '.';} |
| fullname += names[i]; |
| if(eval('typeof '+fullname+' == "undefined"')) { |
| eval(fullname + '={};'); |
| } |
| } |
| } |
| } |
| |
| /** Make sure filename is an array */ |
| function getFiles(names) { |
| return (names && names.constructor == Array) ? names : [names]; |
| } |
| |
| /** Ensure language code is in the format aa_AA. */ |
| function normaliseLanguageCode(lang) { |
| lang = lang.toLowerCase(); |
| if(lang.length > 3) { |
| lang = lang.substring(0, 3) + lang.substring(3).toUpperCase(); |
| } |
| return lang; |
| } |
| |
| /** Unescape unicode chars ('\u00e3') */ |
| function unescapeUnicode(str) { |
| // unescape unicode codes |
| var codes = []; |
| var code = parseInt(str.substr(2), 16); |
| if (code >= 0 && code < Math.pow(2, 16)) { |
| codes.push(code); |
| } |
| // convert codes to text |
| var unescaped = ''; |
| for (var i = 0; i < codes.length; ++i) { |
| unescaped += String.fromCharCode(codes[i]); |
| } |
| return unescaped; |
| } |
| |
| })(jQuery); |
| |
| //Contents of jquery.form.js |
| |
| /*! |
| * jQuery Form Plugin |
| * version: 2.43 (12-MAR-2010) |
| * @requires jQuery v1.3.2 or later |
| * |
| * Examples and documentation at: http://malsup.com/jquery/form/ |
| * Dual licensed under the MIT and GPL licenses: |
| * http://www.opensource.org/licenses/mit-license.php |
| * http://www.gnu.org/licenses/gpl.html |
| */ |
| ;(function($) { |
| |
| /* |
| Usage Note: |
| ----------- |
| Do not use both ajaxSubmit and ajaxForm on the same form. These |
| functions are intended to be exclusive. Use ajaxSubmit if you want |
| to bind your own submit handler to the form. For example, |
| |
| $(document).ready(function() { |
| $('#myForm').bind('submit', function() { |
| $(this).ajaxSubmit({ |
| target: '#output' |
| }); |
| return false; // <-- important! |
| }); |
| }); |
| |
| Use ajaxForm when you want the plugin to manage all the event binding |
| for you. For example, |
| |
| $(document).ready(function() { |
| $('#myForm').ajaxForm({ |
| target: '#output' |
| }); |
| }); |
| |
| When using ajaxForm, the ajaxSubmit function will be invoked for you |
| at the appropriate time. |
| */ |
| |
| /** |
| * ajaxSubmit() provides a mechanism for immediately submitting |
| * an HTML form using AJAX. |
| */ |
| $.fn.ajaxSubmit = function(options) { |
| // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) |
| if (!this.length) { |
| log('ajaxSubmit: skipping submit process - no element selected'); |
| return this; |
| } |
| |
| if (typeof options == 'function') |
| options = { success: options }; |
| |
| var url = $.trim(this.attr('action')); |
| if (url) { |
| // clean url (don't include hash vaue) |
| url = (url.match(/^([^#]+)/)||[])[1]; |
| } |
| url = url || window.location.href || ''; |
| |
| options = $.extend({ |
| url: url, |
| type: this.attr('method') || 'GET', |
| iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' |
| }, options || {}); |
| |
| // hook for manipulating the form data before it is extracted; |
| // convenient for use with rich editors like tinyMCE or FCKEditor |
| var veto = {}; |
| this.trigger('form-pre-serialize', [this, options, veto]); |
| if (veto.veto) { |
| log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); |
| return this; |
| } |
| |
| // provide opportunity to alter form data before it is serialized |
| if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { |
| log('ajaxSubmit: submit aborted via beforeSerialize callback'); |
| return this; |
| } |
| |
| var a = this.formToArray(options.semantic); |
| if (options.data) { |
| options.extraData = options.data; |
| for (var n in options.data) { |
| if(options.data[n] instanceof Array) { |
| for (var k in options.data[n]) |
| a.push( { name: n, value: options.data[n][k] } ); |
| } |
| else |
| a.push( { name: n, value: options.data[n] } ); |
| } |
| } |
| |
| // give pre-submit callback an opportunity to abort the submit |
| if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { |
| log('ajaxSubmit: submit aborted via beforeSubmit callback'); |
| return this; |
| } |
| |
| // fire vetoable 'validate' event |
| this.trigger('form-submit-validate', [a, this, options, veto]); |
| if (veto.veto) { |
| log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); |
| return this; |
| } |
| |
| var q = $.param(a); |
| |
| if (options.type.toUpperCase() == 'GET') { |
| options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; |
| options.data = null; // data is null for 'get' |
| } |
| else |
| options.data = q; // data is the query string for 'post' |
| |
| var $form = this, callbacks = []; |
| if (options.resetForm) callbacks.push(function() { $form.resetForm(); }); |
| if (options.clearForm) callbacks.push(function() { $form.clearForm(); }); |
| |
| // perform a load on the target only if dataType is not provided |
| if (!options.dataType && options.target) { |
| var oldSuccess = options.success || function(){}; |
| callbacks.push(function(data) { |
| var fn = options.replaceTarget ? 'replaceWith' : 'html'; |
| $(options.target)[fn](data).each(oldSuccess, arguments); |
| }); |
| } |
| else if (options.success) |
| callbacks.push(options.success); |
| |
| options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg |
| for (var i=0, max=callbacks.length; i < max; i++) |
| callbacks[i].apply(options, [data, status, xhr || $form, $form]); |
| }; |
| |
| // are there files to upload? |
| var files = $('input:file', this).fieldValue(); |
| var found = false; |
| for (var j=0; j < files.length; j++) |
| if (files[j]) |
| found = true; |
| |
| var multipart = false; |
| // var mp = 'multipart/form-data'; |
| // multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); |
| |
| // options.iframe allows user to force iframe mode |
| // 06-NOV-09: now defaulting to iframe mode if file input is detected |
| if ((files.length && options.iframe !== false) || options.iframe || found || multipart) { |
| // hack to fix Safari hang (thanks to Tim Molendijk for this) |
| // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d |
| if (options.closeKeepAlive) |
| $.get(options.closeKeepAlive, fileUpload); |
| else |
| fileUpload(); |
| } |
| else |
| $.ajax(options); |
| |
| // fire 'notify' event |
| this.trigger('form-submit-notify', [this, options]); |
| return this; |
| |
| |
| // private function for handling file uploads (hat tip to YAHOO!) |
| function fileUpload() { |
| var form = $form[0]; |
| |
| if ($(':input[name=submit]', form).length) { |
| alert('Error: Form elements must not be named "submit".'); |
| return; |
| } |
| |
| var opts = $.extend({}, $.ajaxSettings, options); |
| var s = $.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts); |
| |
| var id = 'jqFormIO' + (new Date().getTime()); |
| var $io = $('<iframe id="' + id + '" name="' + id + '" src="'+ opts.iframeSrc +'" onload="(jQuery(this).data(\'form-plugin-onload\'))()" />'); |
| var io = $io[0]; |
| |
| $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' }); |
| |
| var xhr = { // mock object |
| aborted: 0, |
| responseText: null, |
| responseXML: null, |
| status: 0, |
| async: false, |
| statusText: 'n/a', |
| getAllResponseHeaders: function() {}, |
| getResponseHeader: function() {}, |
| setRequestHeader: function() {}, |
| abort: function() { |
| this.aborted = 1; |
| $io.attr('src', opts.iframeSrc); // abort op in progress |
| } |
| }; |
| |
| var g = opts.global; |
| // trigger ajax global events so that activity/block indicators work like normal |
| if (g && ! $.active++) $.event.trigger("ajaxStart"); |
| if (g) $.event.trigger("ajaxSend", [xhr, opts]); |
| |
| if (s.beforeSend && s.beforeSend(xhr, s) === false) { |
| s.global && $.active--; |
| return; |
| } |
| if (xhr.aborted) |
| return; |
| |
| var cbInvoked = false; |
| var timedOut = 0; |
| |
| // add submitting element to data if we know it |
| var sub = form.clk; |
| if (sub) { |
| var n = sub.name; |
| if (n && !sub.disabled) { |
| opts.extraData = opts.extraData || {}; |
| opts.extraData[n] = sub.value; |
| if (sub.type == "image") { |
| opts.extraData[n+'.x'] = form.clk_x; |
| opts.extraData[n+'.y'] = form.clk_y; |
| } |
| } |
| } |
| |
| // take a breath so that pending repaints get some cpu time before the upload starts |
| function doSubmit() { |
| // make sure form attrs are set |
| var t = $form.attr('target'), a = $form.attr('action'); |
| |
| // update form attrs in IE friendly way |
| form.setAttribute('target',id); |
| if (form.getAttribute('method') != 'POST') |
| form.setAttribute('method', 'POST'); |
| if (form.getAttribute('action') != opts.url) |
| form.setAttribute('action', opts.url); |
| |
| // ie borks in some cases when setting encoding |
| if (! opts.skipEncodingOverride) { |
| $form.attr({ |
| encoding: 'multipart/form-data', |
| enctype: 'multipart/form-data' |
| }); |
| } |
| |
| // support timout |
| if (opts.timeout) |
| setTimeout(function() { timedOut = true; cb(); }, opts.timeout); |
| |
| // add "extra" data to form if provided in options |
| var extraInputs = []; |
| try { |
| if (opts.extraData) |
| for (var n in opts.extraData) |
| extraInputs.push( |
| $('<input type="hidden" name="'+n+'" value="'+opts.extraData[n]+'" />') |
| .appendTo(form)[0]); |
| |
| // add iframe to doc and submit the form |
| $io.appendTo('body'); |
| $io.data('form-plugin-onload', cb); |
| form.submit(); |
| } |
| finally { |
| // reset attrs and remove "extra" input elements |
| form.setAttribute('action',a); |
| t ? form.setAttribute('target', t) : $form.removeAttr('target'); |
| $(extraInputs).remove(); |
| } |
| }; |
| |
| if (opts.forceSync) |
| doSubmit(); |
| else |
| setTimeout(doSubmit, 10); // this lets dom updates render |
| |
| var domCheckCount = 100; |
| |
| function cb() { |
| if (cbInvoked) |
| return; |
| |
| var ok = true; |
| try { |
| if (timedOut) throw 'timeout'; |
| // extract the server response from the iframe |
| var data, doc; |
| |
| doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document; |
| |
| var isXml = opts.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc); |
| log('isXml='+isXml); |
| if (!isXml && (doc.body == null || doc.body.innerHTML == '')) { |
| if (--domCheckCount) { |
| // in some browsers (Opera) the iframe DOM is not always traversable when |
| // the onload callback fires, so we loop a bit to accommodate |
| log('requeing onLoad callback, DOM not available'); |
| setTimeout(cb, 250); |
| return; |
| } |
| log('Could not access iframe DOM after 100 tries.'); |
| return; |
| } |
| |
| log('response detected'); |
| cbInvoked = true; |
| xhr.responseText = doc.body ? doc.body.innerHTML : null; |
| xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc; |
| xhr.getResponseHeader = function(header){ |
| var headers = {'content-type': opts.dataType}; |
| return headers[header]; |
| }; |
| |
| if (opts.dataType == 'json' || opts.dataType == 'script') { |
| // see if user embedded response in textarea |
| var ta = doc.getElementsByTagName('textarea')[0]; |
| if (ta) |
| xhr.responseText = ta.value; |
| else { |
| // account for browsers injecting pre around json response |
| var pre = doc.getElementsByTagName('pre')[0]; |
| if (pre) |
| xhr.responseText = pre.innerHTML; |
| } |
| } |
| else if (opts.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) { |
| xhr.responseXML = toXml(xhr.responseText); |
| } |
| data = $.httpData(xhr, opts.dataType); |
| } |
| catch(e){ |
| log('error caught:',e); |
| ok = false; |
| xhr.error = e; |
| $.handleError(opts, xhr, 'error', e); |
| } |
| |
| // ordering of these callbacks/triggers is odd, but that's how $.ajax does it |
| if (ok) { |
| opts.success(data, 'success'); |
| if (g) $.event.trigger("ajaxSuccess", [xhr, opts]); |
| } |
| if (g) $.event.trigger("ajaxComplete", [xhr, opts]); |
| if (g && ! --$.active) $.event.trigger("ajaxStop"); |
| if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error'); |
| |
| // clean up |
| setTimeout(function() { |
| $io.removeData('form-plugin-onload'); |
| $io.remove(); |
| xhr.responseXML = null; |
| }, 100); |
| }; |
| |
| function toXml(s, doc) { |
| if (window.ActiveXObject) { |
| doc = new ActiveXObject('Microsoft.XMLDOM'); |
| doc.async = 'false'; |
| doc.loadXML(s); |
| } |
| else |
| doc = (new DOMParser()).parseFromString(s, 'text/xml'); |
| return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null; |
| }; |
| }; |
| }; |
| |
| /** |
| * ajaxForm() provides a mechanism for fully automating form submission. |
| * |
| * The advantages of using this method instead of ajaxSubmit() are: |
| * |
| * 1: This method will include coordinates for <input type="image" /> elements (if the element |
| * is used to submit the form). |
| * 2. This method will include the submit element's name/value data (for the element that was |
| * used to submit the form). |
| * 3. This method binds the submit() method to the form for you. |
| * |
| * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely |
| * passes the options argument along after properly binding events for submit elements and |
| * the form itself. |
| */ |
| $.fn.ajaxForm = function(options) { |
| return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) { |
| e.preventDefault(); |
| $(this).ajaxSubmit(options); |
| }).bind('click.form-plugin', function(e) { |
| var target = e.target; |
| var $el = $(target); |
| if (!($el.is(":submit,input:image"))) { |
| // is this a child element of the submit el? (ex: a span within a button) |
| var t = $el.closest(':submit'); |
| if (t.length == 0) |
| return; |
| target = t[0]; |
| } |
| var form = this; |
| form.clk = target; |
| if (target.type == 'image') { |
| if (e.offsetX != undefined) { |
| form.clk_x = e.offsetX; |
| form.clk_y = e.offsetY; |
| } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin |
| var offset = $el.offset(); |
| form.clk_x = e.pageX - offset.left; |
| form.clk_y = e.pageY - offset.top; |
| } else { |
| form.clk_x = e.pageX - target.offsetLeft; |
| form.clk_y = e.pageY - target.offsetTop; |
| } |
| } |
| // clear form vars |
| setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100); |
| }); |
| }; |
| |
| // ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm |
| $.fn.ajaxFormUnbind = function() { |
| return this.unbind('submit.form-plugin click.form-plugin'); |
| }; |
| |
| /** |
| * formToArray() gathers form element data into an array of objects that can |
| * be passed to any of the following ajax functions: $.get, $.post, or load. |
| * Each object in the array has both a 'name' and 'value' property. An example of |
| * an array for a simple login form might be: |
| * |
| * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ] |
| * |
| * It is this array that is passed to pre-submit callback functions provided to the |
| * ajaxSubmit() and ajaxForm() methods. |
| */ |
| $.fn.formToArray = function(semantic) { |
| var a = []; |
| if (this.length == 0) return a; |
| |
| var form = this[0]; |
| var els = semantic ? form.getElementsByTagName('*') : form.elements; |
| if (!els) return a; |
| for(var i=0, max=els.length; i < max; i++) { |
| var el = els[i]; |
| var n = el.name; |
| if (!n) continue; |
| |
| if (semantic && form.clk && el.type == "image") { |
| // handle image inputs on the fly when semantic == true |
| if(!el.disabled && form.clk == el) { |
| a.push({name: n, value: $(el).val()}); |
| a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y}); |
| } |
| continue; |
| } |
| |
| var v = $.fieldValue(el, true); |
| if (v && v.constructor == Array) { |
| for(var j=0, jmax=v.length; j < jmax; j++) |
| a.push({name: n, value: v[j]}); |
| } |
| else if (v !== null && typeof v != 'undefined') |
| a.push({name: n, value: v}); |
| } |
| |
| if (!semantic && form.clk) { |
| // input type=='image' are not found in elements array! handle it here |
| var $input = $(form.clk), input = $input[0], n = input.name; |
| if (n && !input.disabled && input.type == 'image') { |
| a.push({name: n, value: $input.val()}); |
| a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y}); |
| } |
| } |
| return a; |
| }; |
| |
| /** |
| * Serializes form data into a 'submittable' string. This method will return a string |
| * in the format: name1=value1&name2=value2 |
| */ |
| $.fn.formSerialize = function(semantic) { |
| //hand off to jQuery.param for proper encoding |
| return $.param(this.formToArray(semantic)); |
| }; |
| |
| /** |
| * Serializes all field elements in the jQuery object into a query string. |
| * This method will return a string in the format: name1=value1&name2=value2 |
| */ |
| $.fn.fieldSerialize = function(successful) { |
| var a = []; |
| this.each(function() { |
| var n = this.name; |
| if (!n) return; |
| var v = $.fieldValue(this, successful); |
| if (v && v.constructor == Array) { |
| for (var i=0,max=v.length; i < max; i++) |
| a.push({name: n, value: v[i]}); |
| } |
| else if (v !== null && typeof v != 'undefined') |
| a.push({name: this.name, value: v}); |
| }); |
| //hand off to jQuery.param for proper encoding |
| return $.param(a); |
| }; |
| |
| /** |
| * Returns the value(s) of the element in the matched set. For example, consider the following form: |
| * |
| * <form><fieldset> |
| * <input name="A" type="text" /> |
| * <input name="A" type="text" /> |
| * <input name="B" type="checkbox" value="B1" /> |
| * <input name="B" type="checkbox" value="B2"/> |
| * <input name="C" type="radio" value="C1" /> |
| * <input name="C" type="radio" value="C2" /> |
| * </fieldset></form> |
| * |
| * var v = $(':text').fieldValue(); |
| * // if no values are entered into the text inputs |
| * v == ['',''] |
| * // if values entered into the text inputs are 'foo' and 'bar' |
| * v == ['foo','bar'] |
| * |
| * var v = $(':checkbox').fieldValue(); |
| * // if neither checkbox is checked |
| * v === undefined |
| * // if both checkboxes are checked |
| * v == ['B1', 'B2'] |
| * |
| * var v = $(':radio').fieldValue(); |
| * // if neither radio is checked |
| * v === undefined |
| * // if first radio is checked |
| * v == ['C1'] |
| * |
| * The successful argument controls whether or not the field element must be 'successful' |
| * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls). |
| * The default value of the successful argument is true. If this value is false the value(s) |
| * for each element is returned. |
| * |
| * Note: This method *always* returns an array. If no valid value can be determined the |
| * array will be empty, otherwise it will contain one or more values. |
| */ |
| $.fn.fieldValue = function(successful) { |
| for (var val=[], i=0, max=this.length; i < max; i++) { |
| var el = this[i]; |
| var v = $.fieldValue(el, successful); |
| if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) |
| continue; |
| v.constructor == Array ? $.merge(val, v) : val.push(v); |
| } |
| return val; |
| }; |
| |
| /** |
| * Returns the value of the field element. |
| */ |
| $.fieldValue = function(el, successful) { |
| var n = el.name, t = el.type, tag = el.tagName.toLowerCase(); |
| if (typeof successful == 'undefined') successful = true; |
| |
| if (successful && (!n || el.disabled || t == 'reset' || t == 'button' || |
| (t == 'checkbox' || t == 'radio') && !el.checked || |
| (t == 'submit' || t == 'image') && el.form && el.form.clk != el || |
| tag == 'select' && el.selectedIndex == -1)) |
| return null; |
| |
| if (tag == 'select') { |
| var index = el.selectedIndex; |
| if (index < 0) return null; |
| var a = [], ops = el.options; |
| var one = (t == 'select-one'); |
| var max = (one ? index+1 : ops.length); |
| for(var i=(one ? index : 0); i < max; i++) { |
| var op = ops[i]; |
| if (op.selected) { |
| var v = op.value; |
| if (!v) // extra pain for IE... |
| v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value; |
| if (one) return v; |
| a.push(v); |
| } |
| } |
| return a; |
| } |
| return el.value; |
| }; |
| |
| /** |
| * Clears the form data. Takes the following actions on the form's input fields: |
| * - input text fields will have their 'value' property set to the empty string |
| * - select elements will have their 'selectedIndex' property set to -1 |
| * - checkbox and radio inputs will have their 'checked' property set to false |
| * - inputs of type submit, button, reset, and hidden will *not* be effected |
| * - button elements will *not* be effected |
| */ |
| $.fn.clearForm = function() { |
| return this.each(function() { |
| $('input,select,textarea', this).clearFields(); |
| }); |
| }; |
| |
| /** |
| * Clears the selected form elements. |
| */ |
| $.fn.clearFields = $.fn.clearInputs = function() { |
| return this.each(function() { |
| var t = this.type, tag = this.tagName.toLowerCase(); |
| if (t == 'text' || t == 'password' || tag == 'textarea') |
| this.value = ''; |
| else if (t == 'checkbox' || t == 'radio') |
| this.checked = false; |
| else if (tag == 'select') |
| this.selectedIndex = -1; |
| }); |
| }; |
| |
| /** |
| * Resets the form data. Causes all form elements to be reset to their original value. |
| */ |
| $.fn.resetForm = function() { |
| return this.each(function() { |
| // guard against an input with the name of 'reset' |
| // note that IE reports the reset function as an 'object' |
| if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) |
| this.reset(); |
| }); |
| }; |
| |
| /** |
| * Enables or disables any matching elements. |
| */ |
| $.fn.enable = function(b) { |
| if (b == undefined) b = true; |
| return this.each(function() { |
| this.disabled = !b; |
| }); |
| }; |
| |
| /** |
| * Checks/unchecks any matching checkboxes or radio buttons and |
| * selects/deselects and matching option elements. |
| */ |
| $.fn.selected = function(select) { |
| if (select == undefined) select = true; |
| return this.each(function() { |
| var t = this.type; |
| if (t == 'checkbox' || t == 'radio') |
| this.checked = select; |
| else if (this.tagName.toLowerCase() == 'option') { |
| var $sel = $(this).parent('select'); |
| if (select && $sel[0] && $sel[0].type == 'select-one') { |
| // deselect all other options |
| $sel.find('option').selected(false); |
| } |
| this.selected = select; |
| } |
| }); |
| }; |
| |
| // helper fn for console logging |
| // set $.fn.ajaxSubmit.debug to true to enable debug logging |
| function log() { |
| if ($.fn.ajaxSubmit.debug) { |
| var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,''); |
| if (window.console && window.console.log) |
| window.console.log(msg); |
| else if (window.opera && window.opera.postError) |
| window.opera.postError(msg); |
| } |
| }; |
| |
| })(jQuery); |
| |
| //Contents of download.jQuery.js |
| |
| $.download = function(url, data, method, callback){ |
| var inputs = ''; |
| var iframeX; |
| var downloadInterval; |
| if(url/* && data*/){ |
| // remove old iframe if has |
| if($("#iframeX")) $("#iframeX").remove(); |
| // creater new iframe |
| iframeX= $('<iframe src="[removed]false;" name="iframeX" id="iframeX"></iframe>').appendTo('body').hide(); |
| if($.browser.msie){ |
| downloadInterval = setInterval(function(){ |
| // if loading then readyState is “loading” else readyState is “interactive” |
| if(iframeX&& iframeX[0].readyState !=="loading"){ |
| if(undefined != callback) |
| callback(); |
| clearInterval(downloadInterval); |
| } |
| }, 23); |
| } else { |
| iframeX.load(function(){ |
| if(undefined != callback) |
| callback(); |
| }); |
| } |
| |
| jQuery.each(data.split('&'), function(){ |
| var pair = this.split('='); |
| inputs+='<input type="hidden" name="'+ pair[0] +'" value="'+ pair[1] +'" />'; |
| }); |
| |
| //create form to send request |
| $('<form action="'+ url +'" method="'+ (method||'post') + '" target="iframeX">'+inputs+'</form>').appendTo('body').submit().remove(); |
| } |
| } |
| |
| //Contents of sm and hm |
| |
| function sm(obl, wd, ht){ |
| var h='hidden'; |
| var b='block'; |
| var p='px'; |
| var obol=getID('ol'); |
| var obbxd = getID('mbd'); |
| obbxd.innerHTML = getID(obl).innerHTML; |
| obol.style.height=pageHeight()+p; |
| obol.style.width=pageWidth()+p; |
| obol.style.top=posTop()+p; |
| obol.style.left=posLeft()+p; |
| obol.style.display=b; |
| var tp=posTop()+((pageHeight()-ht)/2)-12; |
| var lt=posLeft()+((pageWidth()-wd)/2)-12; |
| var obbx=getID('mbox'); |
| obbx.style.top=(tp<0?0:tp)+p; |
| obbx.style.left=(lt<0?0:lt)+p; |
| obbx.style.width=wd+p; |
| obbx.style.height=ht+p; |
| inf(h); |
| obbx.style.display=b; |
| if("IE6" == GetBrowserType()) |
| { |
| $("#mbd").bgiframe(); |
| } |
| |
| return false; |
| } |
| |
| function hm(){ |
| var v='visible'; |
| var n='none'; |
| getID('ol').style.display=n; |
| getID('mbox').style.display=n; |
| inf(v); |
| document.onkeypress='' |
| } |
| |
| //Contents of md5.js |
| |
| /*Copyright (c) 1998 - 2009, Paul Johnston & Contributors |
| * All rights reserved. |
| * |
| * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: |
| * |
| * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. |
| * Redistributions in binary form must reproduce the above copyright notice, |
| * this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. |
| * |
| * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. |
| * |
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
| * INCLUDING, BUT NOT LIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, |
| * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| * STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| |
| /* |
| * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message |
| * Digest Algorithm, as defined in RFC 1321. |
| * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. |
| * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet |
| * Distributed under the BSD License |
| * See http://pajhome.org.uk/crypt/md5 for more info. |
| */ |
| |
| /* |
| * Configurable variables. You may need to tweak these to be compatible with |
| * the server-side, but the defaults work in most cases. |
| */ |
| var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ |
| var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ |
| var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ |
| |
| /* |
| * These are the functions you'll usually want to call |
| * They take string arguments and return either hex or base-64 encoded strings |
| */ |
| function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));} |
| function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));} |
| function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));} |
| function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); } |
| function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); } |
| function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); } |
| |
| /* |
| * Perform a simple self-test to see if the VM is working |
| */ |
| function md5_vm_test() |
| { |
| return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; |
| } |
| |
| /* |
| * Calculate the MD5 of an array of little-endian words, and a bit length |
| */ |
| function core_md5(x, len) |
| { |
| /* append padding */ |
| x[len >> 5] |= 0x80 << ((len) % 32); |
| x[(((len + 64) >>> 9) << 4) + 14] = len; |
| |
| var a = 1732584193; |
| var b = -271733879; |
| var c = -1732584194; |
| var d = 271733878; |
| |
| for(var i = 0; i < x.length; i += 16) |
| { |
| var olda = a; |
| var oldb = b; |
| var oldc = c; |
| var oldd = d; |
| |
| a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); |
| d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); |
| c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); |
| b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); |
| a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); |
| d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); |
| c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); |
| b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); |
| a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); |
| d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); |
| c = md5_ff(c, d, a, b, x[i+10], 17, -42063); |
| b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); |
| a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); |
| d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); |
| c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); |
| b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); |
| |
| a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); |
| d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); |
| c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); |
| b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); |
| a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); |
| d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); |
| c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); |
| b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); |
| a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); |
| d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); |
| c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); |
| b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); |
| a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); |
| d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); |
| c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); |
| b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); |
| |
| a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); |
| d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); |
| c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); |
| b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); |
| a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); |
| d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); |
| c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); |
| b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); |
| a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); |
| d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); |
| c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); |
| b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); |
| a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); |
| d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); |
| c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); |
| b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); |
| |
| a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); |
| d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); |
| c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); |
| b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); |
| a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); |
| d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); |
| c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); |
| b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); |
| a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); |
| d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); |
| c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); |
| b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); |
| a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); |
| d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); |
| c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); |
| b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); |
| |
| a = safe_add(a, olda); |
| b = safe_add(b, oldb); |
| c = safe_add(c, oldc); |
| d = safe_add(d, oldd); |
| } |
| return Array(a, b, c, d); |
| |
| } |
| |
| /* |
| * These functions implement the four basic operations the algorithm uses. |
| */ |
| function md5_cmn(q, a, b, x, s, t) |
| { |
| return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); |
| } |
| function md5_ff(a, b, c, d, x, s, t) |
| { |
| return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); |
| } |
| function md5_gg(a, b, c, d, x, s, t) |
| { |
| return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); |
| } |
| function md5_hh(a, b, c, d, x, s, t) |
| { |
| return md5_cmn(b ^ c ^ d, a, b, x, s, t); |
| } |
| function md5_ii(a, b, c, d, x, s, t) |
| { |
| return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); |
| } |
| |
| /* |
| * Calculate the HMAC-MD5, of a key and some data |
| */ |
| function core_hmac_md5(key, data) |
| { |
| var bkey = str2binl(key); |
| if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz); |
| |
| var ipad = Array(16), opad = Array(16); |
| for(var i = 0; i < 16; i++) |
| { |
| ipad[i] = bkey[i] ^ 0x36363636; |
| opad[i] = bkey[i] ^ 0x5C5C5C5C; |
| } |
| |
| var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz); |
| return core_md5(opad.concat(hash), 512 + 128); |
| } |
| |
| /* |
| * Add integers, wrapping at 2^32. This uses 16-bit operations internally |
| * to work around bugs in some JS interpreters. |
| */ |
| function safe_add(x, y) |
| { |
| var lsw = (x & 0xFFFF) + (y & 0xFFFF); |
| var msw = (x >> 16) + (y >> 16) + (lsw >> 16); |
| return (msw << 16) | (lsw & 0xFFFF); |
| } |
| |
| /* |
| * Bitwise rotate a 32-bit number to the left. |
| */ |
| function bit_rol(num, cnt) |
| { |
| return (num << cnt) | (num >>> (32 - cnt)); |
| } |
| |
| /* |
| * Convert a string to an array of little-endian words |
| * If chrsz is ASCII, characters >255 have their hi-byte silently ignored. |
| */ |
| function str2binl(str) |
| { |
| var bin = Array(); |
| var mask = (1 << chrsz) - 1; |
| for(var i = 0; i < str.length * chrsz; i += chrsz) |
| bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); |
| return bin; |
| } |
| |
| /* |
| * Convert an array of little-endian words to a string |
| */ |
| function binl2str(bin) |
| { |
| var str = ""; |
| var mask = (1 << chrsz) - 1; |
| for(var i = 0; i < bin.length * 32; i += chrsz) |
| str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); |
| return str; |
| } |
| |
| /* |
| * Convert an array of little-endian words to a hex string. |
| */ |
| function binl2hex(binarray) |
| { |
| var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; |
| var str = ""; |
| for(var i = 0; i < binarray.length * 4; i++) |
| { |
| str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + |
| hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); |
| } |
| return str; |
| } |
| |
| /* |
| * Convert an array of little-endian words to a base-64 string |
| */ |
| function binl2b64(binarray) |
| { |
| var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
| var str = ""; |
| for(var i = 0; i < binarray.length * 4; i += 3) |
| { |
| var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16) |
| | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 ) |
| | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF); |
| for(var j = 0; j < 4; j++) |
| { |
| if(i * 8 + j * 6 > binarray.length * 32) str += b64pad; |
| else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); |
| } |
| } |
| return str; |
| } |
| |
| function md5_js_loaded() { return true; } |
| |
| //Contents of modaldbox.js |
| |
| /* Modal Dialog Box |
| * copyright 8th July 2006 by Stephen Chapman |
| * http://javascript.about.com/ |
| * |
| * Permission is hereby granted, free of charge, to any person obtaining |
| * a copy of this software and associated documentation files (the |
| * "Software"), to deal in the Software without restriction, including |
| * without limitation the rights to use, copy, modify, merge, publish, |
| * distribute, sublicense, and/or sell copies of the Software, and to |
| * permit persons to whom the Software is furnished to do so, subject to |
| * the following conditions: |
| * |
| * The above copyright notice and this permission notice shall be |
| * included in all copies or substantial portions of the Software. |
| * |
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| */ |
| function pageWidth() { |
| return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null; |
| } |
| function pageHeight() { |
| return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null; |
| } |
| function posLeft() { |
| return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement && document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0; |
| } |
| function posTop() { |
| return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement && document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0; |
| } |
| function getID(x) { |
| return document.getElementById(x); |
| } |
| function scrollFix() { |
| var obol=getID('ol'); |
| obol.style.top=posTop()+'px'; |
| obol.style.left=posLeft()+'px' |
| } |
| function sizeFix() { |
| var obol=getID('ol'); |
| obol.style.height=pageHeight()+'px'; |
| obol.style.width=pageWidth()+'px'; |
| } |
| function kp(e) { |
| ky=e?e.which:event.keyCode; |
| if(ky==88||ky==120)CloseDlg(); |
| return false |
| } |
| function inf(h) { |
| // tag=document.getElementsByTagName('select'); |
| // for(i=tag.length-1;i>=0;i--)tag[i].style.visibility=h; |
| tag=document.getElementsByTagName('iframe'); |
| for(i=tag.length-1; i>=0; i--)tag[i].style.visibility=h; |
| tag=document.getElementsByTagName('object'); |
| for(i=tag.length-1; i>=0; i--)tag[i].style.visibility=h; |
| } |
| function ShowDlg(dlgID, wd, ht) { |
| var h='hidden'; |
| var b='block'; |
| var p='px'; |
| var obol= document.getElementById('ol'); |
| var obbxd = document.getElementById('mbd'); |
| obbxd.innerHTML = getID(dlgID).innerHTML; |
| obol.style.height=pageHeight()+p; |
| obol.style.width=pageWidth()+p; |
| obol.style.top=posTop()+p; |
| obol.style.left=posLeft()+p; |
| obol.style.display=b; |
| var tp=posTop()+((pageHeight()-ht)/2)-12; |
| var lt=posLeft()+((pageWidth()-wd)/2)-12; |
| var obbx=getID('mbox'); |
| obbx.style.top=(tp<0?0:tp)+p; |
| obbx.style.left=(lt<0?0:lt)+p; |
| obbx.style.width=wd+p; |
| obbx.style.height=ht+p; |
| inf(h); |
| obbx.style.display=b; |
| if("IE6" == GetBrowserType()) { |
| $("#mbd").bgiframe(); |
| } |
| |
| return false; |
| } |
| function CloseDlg() { |
| var v='visible'; |
| var n='none'; |
| getID('ol').style.display=n; |
| getID('mbox').style.display=n; |
| inf(v); |
| document.onkeypress='' |
| } |
| function initmb() { |
| var ab='absolute'; |
| var n='none'; |
| var obody=document.getElementsByTagName('body')[0]; |
| var frag=document.createDocumentFragment(); |
| var obol=document.createElement('div'); |
| obol.setAttribute('id','ol'); |
| obol.style.display=n; |
| obol.style.position=ab; |
| obol.style.top=0; |
| obol.style.left=0; |
| obol.style.zIndex=998; |
| obol.style.width='100%'; |
| frag.appendChild(obol); |
| var obbx=document.createElement('div'); |
| obbx.setAttribute('id','mbox'); |
| obbx.style.display=n; |
| obbx.style.position=ab; |
| obbx.style.zIndex=999; |
| var obl=document.createElement('span'); |
| obbx.appendChild(obl); |
| var obbxd=document.createElement('div'); |
| obbxd.setAttribute('id','mbd'); |
| obl.appendChild(obbxd); |
| frag.insertBefore(obbx,obol.nextSibling); |
| obody.insertBefore(frag,obody.firstChild); |
| window.onscroll = scrollFix; |
| window.onresize = sizeFix; |
| } |
| |
| //Contents of table.js |
| |
| /** |
| * Copyright (c)2005-2009 Matt Kruse (javascripttoolbox.com) |
| * |
| * Dual licensed under the MIT and GPL licenses. |
| * This basically means you can use this code however you want for |
| * free, but don't claim to have written it yourself! |
| * Donations always accepted: http://www.JavascriptToolbox.com/donate/ |
| * |
| * Please do not link to the .js files on javascripttoolbox.com from |
| * your site. Copy the files locally to your server instead. |
| * |
| */ |
| /** |
| * Table.js |
| * Functions for interactive Tables |
| * |
| * Copyright (c) 2007 Matt Kruse (javascripttoolbox.com) |
| * Dual licensed under the MIT and GPL licenses. |
| * |
| * @version 0.981 |
| * |
| * @history 0.981 2007-03-19 Added Sort.numeric_comma, additional date parsing formats |
| * @history 0.980 2007-03-18 Release new BETA release pending some testing. Todo: Additional docs, examples, plus jQuery plugin. |
| * @history 0.959 2007-03-05 Added more "auto" functionality, couple bug fixes |
| * @history 0.958 2007-02-28 Added auto functionality based on class names |
| * @history 0.957 2007-02-21 Speed increases, more code cleanup, added Auto Sort functionality |
| * @history 0.956 2007-02-16 Cleaned up the code and added Auto Filter functionality. |
| * @history 0.950 2006-11-15 First BETA release. |
| * |
| * @todo Add more date format parsers |
| * @todo Add style classes to colgroup tags after sorting/filtering in case the user wants to highlight the whole column |
| * @todo Correct for colspans in data rows (this may slow it down) |
| * @todo Fix for IE losing form control values after sort? |
| */ |
| |
| /** |
| * Sort Functions |
| */ |
| var Sort = (function(){ |
| var sort = {}; |
| // Default alpha-numeric sort |
| // -------------------------- |
| sort.alphanumeric = function(a,b) { |
| return (a==b)?0:(a<b)?-1:1; |
| }; |
| sort['default'] = sort.alphanumeric; // IE chokes on sort.default |
| |
| // This conversion is generalized to work for either a decimal separator of , or . |
| sort.numeric_converter = function(separator) { |
| return function(val) { |
| if (typeof(val)=="string") { |
| val = parseFloat(val.replace(/^[^\d\.]*([\d., ]+).*/g,"$1").replace(new RegExp("[^\\\d"+separator+"]","g"),'').replace(/,/,'.')) || 0; |
| } |
| return val || 0; |
| }; |
| }; |
| |
| // Numeric Sort |
| // ------------ |
| sort.numeric = function(a,b) { |
| return sort.numeric.convert(a)-sort.numeric.convert(b); |
| }; |
| sort.numeric.convert = sort.numeric_converter("."); |
| |
| // Numeric Sort - comma decimal separator |
| // -------------------------------------- |
| sort.numeric_comma = function(a,b) { |
| return sort.numeric_comma.convert(a)-sort.numeric_comma.convert(b); |
| }; |
| sort.numeric_comma.convert = sort.numeric_converter(","); |
| |
| // Case-insensitive Sort |
| // --------------------- |
| sort.ignorecase = function(a,b) { |
| return sort.alphanumeric(sort.ignorecase.convert(a),sort.ignorecase.convert(b)); |
| }; |
| sort.ignorecase.convert = function(val) { |
| if (val==null) { return ""; } |
| return (""+val).toLowerCase(); |
| }; |
| |
| // Currency Sort |
| // ------------- |
| sort.currency = sort.numeric; // Just treat it as numeric! |
| sort.currency_comma = sort.numeric_comma; |
| |
| // Date sort |
| // --------- |
| sort.date = function(a,b) { |
| return sort.numeric(sort.date.convert(a),sort.date.convert(b)); |
| }; |
| // Convert 2-digit years to 4 |
| sort.date.fixYear=function(yr) { |
| yr = +yr; |
| if (yr<50) { yr += 2000; } |
| else if (yr<100) { yr += 1900; } |
| return yr; |
| }; |
| sort.date.formats = [ |
| // YY[YY]-MM-DD |
| { re:/(\d{2,4})-(\d{1,2})-(\d{1,2})/ , f:function(x){ return (new Date(sort.date.fixYear(x[1]),+x[2],+x[3])).getTime(); } } |
| // MM/DD/YY[YY] or MM-DD-YY[YY] |
| ,{ re:/(\d{1,2})[\/-](\d{1,2})[\/-](\d{2,4})/ , f:function(x){ return (new Date(sort.date.fixYear(x[3]),+x[1],+x[2])).getTime(); } } |
| // Any catch-all format that new Date() can handle. This is not reliable except for long formats, for example: 31 Jan 2000 01:23:45 GMT |
| ,{ re:/(.*\d{4}.*\d+:\d+\d+.*)/, f:function(x){ var d=new Date(x[1]); if(d){return d.getTime();} } } |
| ]; |
| sort.date.convert = function(val) { |
| var m,v, f = sort.date.formats; |
| for (var i=0,L=f.length; i<L; i++) { |
| if (m=val.match(f[i].re)) { |
| v=f[i].f(m); |
| if (typeof(v)!="undefined") { return v; } |
| } |
| } |
| return 9999999999999; // So non-parsed dates will be last, not first |
| }; |
| |
| return sort; |
| })(); |
| |
| /** |
| * The main Table namespace |
| */ |
| var Table = (function(){ |
| |
| /** |
| * Determine if a reference is defined |
| */ |
| function def(o) {return (typeof o!="undefined");}; |
| |
| /** |
| * Determine if an object or class string contains a given class. |
| */ |
| function hasClass(o,name) { |
| return new RegExp("(^|\\s)"+name+"(\\s|$)").test(o.className); |
| }; |
| |
| /** |
| * Add a class to an object |
| */ |
| function addClass(o,name) { |
| var c = o.className || ""; |
| if (def(c) && !hasClass(o,name)) { |
| o.className += (c?" ":"") + name; |
| } |
| }; |
| |
| /** |
| * Remove a class from an object |
| */ |
| function removeClass(o,name) { |
| var c = o.className || ""; |
| o.className = c.replace(new RegExp("(^|\\s)"+name+"(\\s|$)"),"$1"); |
| }; |
| |
| /** |
| * For classes that match a given substring, return the rest |
| */ |
| function classValue(o,prefix) { |
| var c = o.className; |
| if (c.match(new RegExp("(^|\\s)"+prefix+"([^ ]+)"))) { |
| return RegExp.$2; |
| } |
| return null; |
| }; |
| |
| /** |
| * Return true if an object is hidden. |
| * This uses the "russian doll" technique to unwrap itself to the most efficient |
| * function after the first pass. This avoids repeated feature detection that |
| * would always fall into the same block of code. |
| */ |
| function isHidden(o) { |
| if (window.getComputedStyle) { |
| var cs = window.getComputedStyle; |
| return (isHidden = function(o) { |
| return 'none'==cs(o,null).getPropertyValue('display'); |
| })(o); |
| } |
| else if (window.currentStyle) { |
| return(isHidden = function(o) { |
| return 'none'==o.currentStyle['display']; |
| })(o); |
| } |
| return (isHidden = function(o) { |
| return 'none'==o.style['display']; |
| })(o); |
| }; |
| |
| /** |
| * Get a parent element by tag name, or the original element if it is of the tag type |
| */ |
| function getParent(o,a,b) { |
| if (o!=null && o.nodeName) { |
| if (o.nodeName==a || (b && o.nodeName==b)) { |
| return o; |
| } |
| while (o=o.parentNode) { |
| if (o.nodeName && (o.nodeName==a || (b && o.nodeName==b))) { |
| return o; |
| } |
| } |
| } |
| return null; |
| }; |
| |
| /** |
| * Utility function to copy properties from one object to another |
| */ |
| function copy(o1,o2) { |
| for (var i=2;i<arguments.length; i++) { |
| var a = arguments[i]; |
| if (def(o1[a])) { |
| o2[a] = o1[a]; |
| } |
| } |
| } |
| |
| // The table object itself |
| var table = { |
| //Class names used in the code |
| AutoStripeClassName:"table-autostripe", |
| StripeClassNamePrefix:"table-stripeclass:", |
| |
| AutoSortClassName:"table-autosort", |
| AutoSortColumnPrefix:"table-autosort:", |
| AutoSortTitle:"Click to sort", |
| SortedAscendingClassName:"table-sorted-asc", |
| SortedDescendingClassName:"table-sorted-desc", |
| SortableClassName:"table-sortable", |
| SortableColumnPrefix:"table-sortable:", |
| NoSortClassName:"table-nosort", |
| |
| AutoFilterClassName:"table-autofilter", |
| FilteredClassName:"table-filtered", |
| FilterableClassName:"table-filterable", |
| FilteredRowcountPrefix:"table-filtered-rowcount:", |
| RowcountPrefix:"table-rowcount:", |
| FilterAllLabel:"Filter: All", |
| |
| AutoPageSizePrefix:"table-autopage:", |
| AutoPageJumpPrefix:"table-page:", |
| PageNumberPrefix:"table-page-number:", |
| PageCountPrefix:"table-page-count:" |
| }; |
| |
| /** |
| * A place to store misc table information, rather than in the table objects themselves |
| */ |
| table.tabledata = {}; |
| |
| /** |
| * Resolve a table given an element reference, and make sure it has a unique ID |
| */ |
| table.uniqueId=1; |
| table.resolve = function(o,args) { |
| if (o!=null && o.nodeName && o.nodeName!="TABLE") { |
| o = getParent(o,"TABLE"); |
| } |
| if (o==null) { return null; } |
| if (!o.id) { |
| var id = null; |
| do { var id = "TABLE_"+(table.uniqueId++); } |
| while (document.getElementById(id)!=null); |
| o.id = id; |
| } |
| this.tabledata[o.id] = this.tabledata[o.id] || {}; |
| if (args) { |
| copy(args,this.tabledata[o.id],"stripeclass","ignorehiddenrows","useinnertext","sorttype","col","desc","page","pagesize"); |
| } |
| return o; |
| }; |
| |
| |
| /** |
| * Run a function against each cell in a table header or footer, usually |
| * to add or remove css classes based on sorting, filtering, etc. |
| */ |
| table.processTableCells = function(t, type, func, arg) { |
| t = this.resolve(t); |
| if (t==null) { return; } |
| if (type!="TFOOT") { |
| this.processCells(t.tHead, func, arg); |
| } |
| if (type!="THEAD") { |
| this.processCells(t.tFoot, func, arg); |
| } |
| }; |
| |
| /** |
| * Internal method used to process an arbitrary collection of cells. |
| * Referenced by processTableCells. |
| * It's done this way to avoid getElementsByTagName() which would also return nested table cells. |
| */ |
| table.processCells = function(section,func,arg) { |
| if (section!=null) { |
| if (section.rows && section.rows.length && section.rows.length>0) { |
| var rows = section.rows; |
| for (var j=0,L2=rows.length; j<L2; j++) { |
| var row = rows[j]; |
| if (row.cells && row.cells.length && row.cells.length>0) { |
| var cells = row.cells; |
| for (var k=0,L3=cells.length; k<L3; k++) { |
| var cellsK = cells[k]; |
| func.call(this,cellsK,arg); |
| } |
| } |
| } |
| } |
| } |
| }; |
| |
| /** |
| * Get the cellIndex value for a cell. This is only needed because of a Safari |
| * bug that causes cellIndex to exist but always be 0. |
| * Rather than feature-detecting each time it is called, the function will |
| * re-write itself the first time it is called. |
| */ |
| table.getCellIndex = function(td) { |
| var tr = td.parentNode; |
| var cells = tr.cells; |
| if (cells && cells.length) { |
| if (cells.length>1 && cells[cells.length-1].cellIndex>0) { |
| // Define the new function, overwrite the one we're running now, and then run the new one |
| (this.getCellIndex = function(td) { |
| return td.cellIndex; |
| })(td); |
| } |
| // Safari will always go through this slower block every time. Oh well. |
| for (var i=0,L=cells.length; i<L; i++) { |
| if (tr.cells[i]==td) { |
| return i; |
| } |
| } |
| } |
| return 0; |
| }; |
| |
| /** |
| * A map of node names and how to convert them into their "value" for sorting, filtering, etc. |
| * These are put here so it is extensible. |
| */ |
| table.nodeValue = { |
| 'INPUT':function(node) { |
| if (def(node.value) && node.type && ((node.type!="checkbox" && node.type!="radio") || node.checked)) { |
| return node.value; |
| } |
| return ""; |
| }, |
| 'SELECT':function(node) { |
| if (node.selectedIndex>=0 && node.options) { |
| // Sort select elements by the visible text |
| return node.options[node.selectedIndex].text; |
| } |
| return ""; |
| }, |
| 'IMG':function(node) { |
| return node.name || ""; |
| } |
| }; |
| |
| /** |
| * Get the text value of a cell. Only use innerText if explicitly told to, because |
| * otherwise we want to be able to handle sorting on inputs and other types |
| */ |
| table.getCellValue = function(td,useInnerText) { |
| if (useInnerText && def(td.innerText)) { |
| return td.innerText; |
| } |
| if (!td.childNodes) { |
| return ""; |
| } |
| var childNodes=td.childNodes; |
| var ret = ""; |
| for (var i=0,L=childNodes.length; i<L; i++) { |
| var node = childNodes[i]; |
| var type = node.nodeType; |
| // In order to get realistic sort results, we need to treat some elements in a special way. |
| // These behaviors are defined in the nodeValue() object, keyed by node name |
| if (type==1) { |
| var nname = node.nodeName; |
| if (this.nodeValue[nname]) { |
| ret += this.nodeValue[nname](node); |
| } |
| else { |
| ret += this.getCellValue(node); |
| } |
| } |
| else if (type==3) { |
| if (def(node.innerText)) { |
| ret += node.innerText; |
| } |
| else if (def(node.nodeValue)) { |
| ret += node.nodeValue; |
| } |
| } |
| } |
| return ret; |
| }; |
| |
| /** |
| * Consider colspan and rowspan values in table header cells to calculate the actual cellIndex |
| * of a given cell. This is necessary because if the first cell in row 0 has a rowspan of 2, |
| * then the first cell in row 1 will have a cellIndex of 0 rather than 1, even though it really |
| * starts in the second column rather than the first. |
| * See: http://www.javascripttoolbox.com/temp/table_cellindex.html |
| */ |
| table.tableHeaderIndexes = {}; |
| table.getActualCellIndex = function(tableCellObj) { |
| if (!def(tableCellObj.cellIndex)) { return null; } |
| var tableObj = getParent(tableCellObj,"TABLE"); |
| var cellCoordinates = tableCellObj.parentNode.rowIndex+"-"+this.getCellIndex(tableCellObj); |
| |
| // If it has already been computed, return the answer from the lookup table |
| if (def(this.tableHeaderIndexes[tableObj.id])) { |
| return this.tableHeaderIndexes[tableObj.id][cellCoordinates]; |
| } |
| |
| var matrix = []; |
| this.tableHeaderIndexes[tableObj.id] = {}; |
| var thead = getParent(tableCellObj,"THEAD"); |
| var trs = thead.getElementsByTagName('TR'); |
| |
| // Loop thru every tr and every cell in the tr, building up a 2-d array "grid" that gets |
| // populated with an "x" for each space that a cell takes up. If the first cell is colspan |
| // 2, it will fill in values [0] and [1] in the first array, so that the second cell will |
| // find the first empty cell in the first row (which will be [2]) and know that this is |
| // where it sits, rather than its internal .cellIndex value of [1]. |
| for (var i=0; i<trs.length; i++) { |
| var cells = trs[i].cells; |
| for (var j=0; j<cells.length; j++) { |
| var c = cells[j]; |
| var rowIndex = c.parentNode.rowIndex; |
| var cellId = rowIndex+"-"+this.getCellIndex(c); |
| var rowSpan = c.rowSpan || 1; |
| var colSpan = c.colSpan || 1; |
| var firstAvailCol; |
| if(!def(matrix[rowIndex])) { |
| matrix[rowIndex] = []; |
| } |
| var m = matrix[rowIndex]; |
| // Find first available column in the first row |
| for (var k=0; k<m.length+1; k++) { |
| if (!def(m[k])) { |
| firstAvailCol = k; |
| break; |
| } |
| } |
| this.tableHeaderIndexes[tableObj.id][cellId] = firstAvailCol; |
| for (var k=rowIndex; k<rowIndex+rowSpan; k++) { |
| if(!def(matrix[k])) { |
| matrix[k] = []; |
| } |
| var matrixrow = matrix[k]; |
| for (var l=firstAvailCol; l<firstAvailCol+colSpan; l++) { |
| matrixrow[l] = "x"; |
| } |
| } |
| } |
| } |
| // Store the map so future lookups are fast. |
| return this.tableHeaderIndexes[tableObj.id][cellCoordinates]; |
| }; |
| |
| /** |
| * Sort all rows in each TBODY (tbodies are sorted independent of each other) |
| */ |
| table.sort = function(o,args) { |
| var t, tdata, sortconvert=null; |
| // Allow for a simple passing of sort type as second parameter |
| if (typeof(args)=="function") { |
| args={sorttype:args}; |
| } |
| args = args || {}; |
| |
| // If no col is specified, deduce it from the object sent in |
| if (!def(args.col)) { |
| args.col = this.getActualCellIndex(o) || 0; |
| } |
| // If no sort type is specified, default to the default sort |
| args.sorttype = args.sorttype || Sort['default']; |
| |
| // Resolve the table |
| t = this.resolve(o,args); |
| tdata = this.tabledata[t.id]; |
| |
| |
| if (args.re_sort) |
| { |
| tdata.desc = tdata.lastdesc; |
| } |
| else |
| { |
| // If we are sorting on the same column as last time, flip the sort direction |
| if (def(tdata.lastcol) && tdata.lastcol==tdata.col && def(tdata.lastdesc)) { |
| tdata.desc = !tdata.lastdesc; |
| } |
| else { |
| tdata.desc = !!args.desc; |
| } |
| } |
| |
| // Store the last sorted column so clicking again will reverse the sort order |
| tdata.lastcol=tdata.col; |
| tdata.lastdesc=!!tdata.desc; |
| |
| // If a sort conversion function exists, pre-convert cell values and then use a plain alphanumeric sort |
| var sorttype = tdata.sorttype; |
| if (typeof(sorttype.convert)=="function") { |
| sortconvert=tdata.sorttype.convert; |
| sorttype=Sort.alphanumeric; |
| } |
| |
| // Loop through all THEADs and remove sorted class names, then re-add them for the col |
| // that is being sorted |
| this.processTableCells(t,"THEAD", |
| function(cell) { |
| if (hasClass(cell,this.SortableClassName)) { |
| removeClass(cell,this.SortedAscendingClassName); |
| removeClass(cell,this.SortedDescendingClassName); |
| // If the computed colIndex of the cell equals the sorted colIndex, flag it as sorted |
| if (tdata.col==table.getActualCellIndex(cell) && (classValue(cell,table.SortableClassName))) { |
| addClass(cell,tdata.desc?this.SortedAscendingClassName:this.SortedDescendingClassName); |
| } |
| } |
| } |
| ); |
| |
| // Sort each tbody independently |
| var bodies = t.tBodies; |
| if (bodies==null || bodies.length==0) { return; } |
| |
| // Define a new sort function to be called to consider descending or not |
| var newSortFunc = (tdata.desc)? |
| function(a,b){return sorttype(b[0],a[0]);} |
| :function(a,b){return sorttype(a[0],b[0]);}; |
| |
| var useinnertext=!!tdata.useinnertext; |
| var col = tdata.col; |
| |
| for (var i=0,L=bodies.length; i<L; i++) { |
| var tb = bodies[i], tbrows = tb.rows, rows = []; |
| |
| // Allow tbodies to request that they not be sorted |
| if(!hasClass(tb,table.NoSortClassName)) { |
| // Create a separate array which will store the converted values and refs to the |
| // actual rows. This is the array that will be sorted. |
| var cRow, cRowIndex=0; |
| if (cRow=tbrows[cRowIndex]){ |
| // Funky loop style because it's considerably faster in IE |
| do { |
| if (rowCells = cRow.cells) { |
| var cellValue = (col<rowCells.length)?this.getCellValue(rowCells[col],useinnertext):null; |
| if (sortconvert) cellValue = sortconvert(cellValue); |
| rows[cRowIndex] = [cellValue,tbrows[cRowIndex]]; |
| } |
| } while (cRow=tbrows[++cRowIndex]) |
| } |
| |
| // Do the actual sorting |
| rows.sort(newSortFunc); |
| |
| // Move the rows to the correctly sorted order. Appending an existing DOM object just moves it! |
| cRowIndex=0; |
| var displayedCount=0; |
| var f=[removeClass,addClass]; |
| if (cRow=rows[cRowIndex]){ |
| do { |
| tb.appendChild(cRow[1]); |
| } while (cRow=rows[++cRowIndex]) |
| } |
| } |
| } |
| |
| // If paging is enabled on the table, then we need to re-page because the order of rows has changed! |
| if (tdata.pagesize) { |
| this.page(t); // This will internally do the striping |
| } |
| else { |
| // Re-stripe if a class name was supplied |
| if (tdata.stripeclass) { |
| this.stripe(t,tdata.stripeclass,!!tdata.ignorehiddenrows); |
| } |
| } |
| }; |
| |
| /** |
| * Apply a filter to rows in a table and hide those that do not match. |
| */ |
| table.filter = function(o,filters,args) { |
| var cell; |
| args = args || {}; |
| |
| var t = this.resolve(o,args); |
| var tdata = this.tabledata[t.id]; |
| |
| // If new filters were passed in, apply them to the table's list of filters |
| if (!filters) { |
| // If a null or blank value was sent in for 'filters' then that means reset the table to no filters |
| tdata.filters = null; |
| } |
| else { |
| // Allow for passing a select list in as the filter, since this is common design |
| if (filters.nodeName=="SELECT" && filters.type=="select-one" && filters.selectedIndex>-1) { |
| filters={ 'filter':filters.options[filters.selectedIndex].value }; |
| } |
| // Also allow for a regular input |
| if (filters.nodeName=="INPUT" && filters.type=="text") { |
| filters={ 'filter':"/^"+filters.value+"/" }; |
| } |
| // Force filters to be an array |
| if (typeof(filters)=="object" && !filters.length) { |
| filters = [filters]; |
| } |
| |
| // Convert regular expression strings to RegExp objects and function strings to function objects |
| for (var i=0,L=filters.length; i<L; i++) { |
| var filter = filters[i]; |
| if (typeof(filter.filter)=="string") { |
| // If a filter string is like "/expr/" then turn it into a Regex |
| if (filter.filter.match(/^\/(.*)\/$/)) { |
| filter.filter = new RegExp(RegExp.$1); |
| filter.filter.regex=true; |
| } |
| // If filter string is like "function (x) { ... }" then turn it into a function |
| else if (filter.filter.match(/^function\s*\(([^\)]*)\)\s*\{(.*)}\s*$/)) { |
| filter.filter = Function(RegExp.$1,RegExp.$2); |
| } |
| } |
| // If some non-table object was passed in rather than a 'col' value, resolve it |
| // and assign it's column index to the filter if it doesn't have one. This way, |
| // passing in a cell reference or a select object etc instead of a table object |
| // will automatically set the correct column to filter. |
| if (filter && !def(filter.col) && (cell=getParent(o,"TD","TH"))) { |
| filter.col = this.getCellIndex(cell); |
| } |
| |
| // Apply the passed-in filters to the existing list of filters for the table, removing those that have a filter of null or "" |
| if ((!filter || !filter.filter) && tdata.filters) { |
| delete tdata.filters[filter.col]; |
| } |
| else { |
| tdata.filters = tdata.filters || {}; |
| tdata.filters[filter.col] = filter.filter; |
| } |
| } |
| // If no more filters are left, then make sure to empty out the filters object |
| for (var j in tdata.filters) { var keep = true; } |
| if (!keep) { |
| tdata.filters = null; |
| } |
| } |
| // Everything's been setup, so now scrape the table rows |
| return table.scrape(o); |
| }; |
| |
| /** |
| * "Page" a table by showing only a subset of the rows |
| */ |
| table.page = function(t,page,args) { |
| args = args || {}; |
| if (def(page)) { args.page = page; } |
| return table.scrape(t,args); |
| }; |
| |
| /** |
| * Jump forward or back any number of pages |
| */ |
| table.pageJump = function(t,count,args) { |
| t = this.resolve(t,args); |
| return this.page(t,(table.tabledata[t.id].page||0)+count,args); |
| }; |
| |
| /** |
| * Go to the next page of a paged table |
| */ |
| table.pageNext = function(t,args) { |
| return this.pageJump(t,1,args); |
| }; |
| |
| /** |
| * Go to the previous page of a paged table |
| */ |
| table.pagePrevious = function(t,args) { |
| return this.pageJump(t,-1,args); |
| }; |
| |
| /** |
| * Scrape a table to either hide or show each row based on filters and paging |
| */ |
| table.scrape = function(o,args) { |
| var col,cell,filterList,filterReset=false,filter; |
| var page,pagesize,pagestart,pageend; |
| var unfilteredrows=[],unfilteredrowcount=0,totalrows=0; |
| var t,tdata,row,hideRow; |
| args = args || {}; |
| |
| // Resolve the table object |
| t = this.resolve(o,args); |
| tdata = this.tabledata[t.id]; |
| |
| // Setup for Paging |
| var page = tdata.page; |
| if (def(page)) { |
| // Don't let the page go before the beginning |
| if (page<0) { tdata.page=page=0; } |
| pagesize = tdata.pagesize || 25; // 25=arbitrary default |
| pagestart = page*pagesize+1; |
| pageend = pagestart + pagesize - 1; |
| } |
| |
| // Scrape each row of each tbody |
| var bodies = t.tBodies; |
| if (bodies==null || bodies.length==0) { return; } |
| for (var i=0,L=bodies.length; i<L; i++) { |
| var tb = bodies[i]; |
| for (var j=0,L2=tb.rows.length; j<L2; j++) { |
| row = tb.rows[j]; |
| hideRow = false; |
| |
| // Test if filters will hide the row |
| if (tdata.filters && row.cells) { |
| var cells = row.cells; |
| var cellsLength = cells.length; |
| // Test each filter |
| for (col in tdata.filters) { |
| if (!hideRow) { |
| filter = tdata.filters[col]; |
| if (filter && col<cellsLength) { |
| var val = this.getCellValue(cells[col]); |
| if (filter.regex && val.search) { |
| hideRow=(val.search(filter)<0); |
| } |
| else if (typeof(filter)=="function") { |
| hideRow=!filter(val,cells[col]); |
| } |
| else { |
| hideRow = (val!=filter); |
| } |
| } |
| } |
| } |
| } |
| |
| // Keep track of the total rows scanned and the total runs _not_ filtered out |
| totalrows++; |
| if (!hideRow) { |
| unfilteredrowcount++; |
| if (def(page)) { |
| // Temporarily keep an array of unfiltered rows in case the page we're on goes past |
| // the last page and we need to back up. Don't want to filter again! |
| unfilteredrows.push(row); |
| if (unfilteredrowcount<pagestart || unfilteredrowcount>pageend) { |
| hideRow = true; |
| } |
| } |
| } |
| |
| row.style.display = hideRow?"none":""; |
| } |
| } |
| |
| if (def(page)) { |
| // Check to see if filtering has put us past the requested page index. If it has, |
| // then go back to the last page and show it. |
| if (pagestart>=unfilteredrowcount) { |
| pagestart = unfilteredrowcount-(unfilteredrowcount%pagesize); |
| tdata.page = page = pagestart/pagesize; |
| for (var i=pagestart,L=unfilteredrows.length; i<L; i++) { |
| unfilteredrows[i].style.display=""; |
| } |
| } |
| } |
| |
| // Loop through all THEADs and add/remove filtered class names |
| this.processTableCells(t,"THEAD", |
| function(c) { |
| ((tdata.filters && def(tdata.filters[table.getCellIndex(c)]) && hasClass(c,table.FilterableClassName))?addClass:removeClass)(c,table.FilteredClassName); |
| } |
| ); |
| |
| // Stripe the table if necessary |
| if (tdata.stripeclass) { |
| this.stripe(t); |
| } |
| |
| // Calculate some values to be returned for info and updating purposes |
| var pagecount = Math.floor(unfilteredrowcount/pagesize)+1; |
| if (def(page)) { |
| // Update the page number/total containers if they exist |
| if (tdata.container_number) { |
| tdata.container_number.innerHTML = page+1; |
| } |
| if (tdata.container_count) { |
| tdata.container_count.innerHTML = pagecount; |
| } |
| } |
| |
| // Update the row count containers if they exist |
| if (tdata.container_filtered_count) { |
| tdata.container_filtered_count.innerHTML = unfilteredrowcount; |
| } |
| if (tdata.container_all_count) { |
| tdata.container_all_count.innerHTML = totalrows; |
| } |
| return { 'data':tdata, 'unfilteredcount':unfilteredrowcount, 'total':totalrows, 'pagecount':pagecount, 'page':page, 'pagesize':pagesize }; |
| }; |
| |
| /** |
| * Shade alternate rows, aka Stripe the table. |
| */ |
| table.stripe = function(t,className,args) { |
| args = args || {}; |
| args.stripeclass = className; |
| |
| t = this.resolve(t,args); |
| var tdata = this.tabledata[t.id]; |
| |
| var bodies = t.tBodies; |
| if (bodies==null || bodies.length==0) { |
| return; |
| } |
| |
| className = tdata.stripeclass; |
| // Cache a shorter, quicker reference to either the remove or add class methods |
| var f=[removeClass,addClass]; |
| for (var i=0,L=bodies.length; i<L; i++) { |
| var tb = bodies[i], tbrows = tb.rows, cRowIndex=0, cRow, displayedCount=0; |
| if (cRow=tbrows[cRowIndex]){ |
| // The ignorehiddenrows test is pulled out of the loop for a slight speed increase. |
| // Makes a bigger difference in FF than in IE. |
| // In this case, speed always wins over brevity! |
| if (tdata.ignoreHiddenRows) { |
| do { |
| f[displayedCount++%2](cRow,className); |
| } while (cRow=tbrows[++cRowIndex]) |
| } |
| else { |
| do { |
| if (!isHidden(cRow)) { |
| f[displayedCount++%2](cRow,className); |
| } |
| } while (cRow=tbrows[++cRowIndex]) |
| } |
| } |
| } |
| }; |
| |
| /** |
| * Build up a list of unique values in a table column |
| */ |
| table.getUniqueColValues = function(t,col) { |
| var values={}, bodies = this.resolve(t).tBodies; |
| for (var i=0,L=bodies.length; i<L; i++) { |
| var tbody = bodies[i]; |
| for (var r=0,L2=tbody.rows.length; r<L2; r++) { |
| values[this.getCellValue(tbody.rows[r].cells[col])] = true; |
| } |
| } |
| var valArray = []; |
| for (var val in values) { |
| valArray.push(val); |
| } |
| return valArray.sort(); |
| }; |
| |
| /** |
| * Scan the document on load and add sorting, filtering, paging etc ability automatically |
| * based on existence of class names on the table and cells. |
| */ |
| table.auto = function(args) { |
| var cells = [], tables = document.getElementsByTagName("TABLE"); |
| var val,tdata; |
| if (tables!=null) { |
| for (var i=0,L=tables.length; i<L; i++) { |
| var t = table.resolve(tables[i]); |
| tdata = table.tabledata[t.id]; |
| if (val=classValue(t,table.StripeClassNamePrefix)) { |
| tdata.stripeclass=val; |
| } |
| // Do auto-filter if necessary |
| if (hasClass(t,table.AutoFilterClassName)) { |
| table.autofilter(t); |
| } |
| // Do auto-page if necessary |
| if (val = classValue(t,table.AutoPageSizePrefix)) { |
| table.autopage(t,{'pagesize':+val}); |
| } |
| // Do auto-sort if necessary |
| if ((val = classValue(t,table.AutoSortColumnPrefix)) || (hasClass(t,table.AutoSortClassName))) { |
| table.autosort(t,{'col':(val==null)?null:+val}); |
| } |
| // Do auto-stripe if necessary |
| if (tdata.stripeclass && hasClass(t,table.AutoStripeClassName)) { |
| table.stripe(t); |
| } |
| } |
| } |
| }; |
| |
| /** |
| * Add sorting functionality to a table header cell |
| */ |
| table.autosort = function(t,args) { |
| t = this.resolve(t,args); |
| var tdata = this.tabledata[t.id]; |
| this.processTableCells(t, "THEAD", function(c) { |
| var type = classValue(c,table.SortableColumnPrefix); |
| if (type!=null) { |
| type = type || "default"; |
| c.title =c.title || table.AutoSortTitle; |
| addClass(c,table.SortableClassName); |
| c.onclick = Function("","Table.sort(this,{'sorttype':Sort['"+type+"']})"); |
| // If we are going to auto sort on a column, we need to keep track of what kind of sort it will be |
| if (args.col!=null) { |
| if (args.col==table.getActualCellIndex(c)) { |
| tdata.sorttype=Sort['"+type+"']; |
| } |
| } |
| } |
| } ); |
| if (args.col!=null) { |
| table.sort(t,args); |
| } |
| }; |
| |
| /** |
| * Add paging functionality to a table |
| */ |
| table.autopage = function(t,args) { |
| t = this.resolve(t,args); |
| var tdata = this.tabledata[t.id]; |
| if (tdata.pagesize) { |
| this.processTableCells(t, "THEAD,TFOOT", function(c) { |
| var type = classValue(c,table.AutoPageJumpPrefix); |
| if (type=="next") { type = 1; } |
| else if (type=="previous") { type = -1; } |
| if (type!=null) { |
| c.onclick = Function("","Table.pageJump(this,"+type+")"); |
| } |
| } ); |
| if (val = classValue(t,table.PageNumberPrefix)) { |
| tdata.container_number = document.getElementById(val); |
| } |
| if (val = classValue(t,table.PageCountPrefix)) { |
| tdata.container_count = document.getElementById(val); |
| } |
| return table.page(t,0,args); |
| } |
| }; |
| |
| /** |
| * A util function to cancel bubbling of clicks on filter dropdowns |
| */ |
| table.cancelBubble = function(e) { |
| e = e || window.event; |
| if (typeof(e.stopPropagation)=="function") { e.stopPropagation(); } |
| if (def(e.cancelBubble)) { e.cancelBubble = true; } |
| }; |
| |
| /** |
| * Auto-filter a table |
| */ |
| table.autofilter = function(t,args) { |
| args = args || {}; |
| t = this.resolve(t,args); |
| var tdata = this.tabledata[t.id],val; |
| table.processTableCells(t, "THEAD", function(cell) { |
| if (hasClass(cell,table.FilterableClassName)) { |
| var cellIndex = table.getCellIndex(cell); |
| var colValues = table.getUniqueColValues(t,cellIndex); |
| if (colValues.length>0) { |
| if (typeof(args.insert)=="function") { |
| func.insert(cell,colValues); |
| } |
| else { |
| var sel = '<select onchange="Table.filter(this,this)" onclick="Table.cancelBubble(event)" class="'+table.AutoFilterClassName+'"><option value="">'+table.FilterAllLabel+'</option>'; |
| for (var i=0; i<colValues.length; i++) { |
| sel += '<option value="'+colValues[i]+'">'+colValues[i]+'</option>'; |
| } |
| sel += '</select>'; |
| cell.innerHTML += "<br>"+sel; |
| } |
| } |
| } |
| }); |
| if (val = classValue(t,table.FilteredRowcountPrefix)) { |
| tdata.container_filtered_count = document.getElementById(val); |
| } |
| if (val = classValue(t,table.RowcountPrefix)) { |
| tdata.container_all_count = document.getElementById(val); |
| } |
| }; |
| |
| /** |
| * Attach the auto event so it happens on load. |
| * use jQuery's ready() function if available |
| */ |
| if (typeof(jQuery)!="undefined") { |
| jQuery(table.auto); |
| } |
| else if (window.addEventListener) { |
| window.addEventListener( "load", table.auto, false ); |
| } |
| else if (window.attachEvent) { |
| window.attachEvent( "onload", table.auto ); |
| } |
| |
| return table; |
| })(); |
| |
| //Contents of utils.js |
| |
| function isBrowser(){ |
| var Sys={}; |
| var ua=navigator.userAgent.toLowerCase(); |
| var s; |
| (s=ua.match(/msie ([\d.]+)/))?Sys.ie=s[1]: |
| (s=ua.match(/firefox\/([\d.]+)/))?Sys.firefox=s[1]: |
| (s=ua.match(/chrome\/([\d.]+)/))?Sys.chrome=s[1]: |
| (s=ua.match(/opera.([\d.]+)/))?Sys.opera=s[1]: |
| (s=ua.match(/version\/([\d.]+).*safari/))?Sys.safari=s[1]:0; |
| if(Sys.ie){ |
| if(Sys.ie=='9.0'){ |
| return 'IE9'; |
| }else if(Sys.ie=='8.0'){ |
| return 'IE8'; |
| }else if(Sys.ie=='7.0'){ |
| return 'IE8'; |
| } |
| else{ |
| return 'IE'; |
| } |
| } |
| if(Sys.firefox){ |
| return 'Firefox'; |
| } |
| if(Sys.chrome){ |
| return 'Chrome'; |
| } |
| if(Sys.opera){ |
| return 'Opera'; |
| } |
| if(Sys.safari){ |
| return 'Safari'; |
| } |
| return 'IE'; |
| }; |
| |
| /* |
| *Login Variables |
| */ |
| var AuthQop,username="",passwd="",GnCount=1,Authrealm,Gnonce,nonce; |
| var _resetTimeOut=600000; |
| var authHeaderIntervalID = 0; |
| |
| /* |
| * clear the Authheader from the coockies |
| */ |
| function clearAuthheader() { |
| //clearing coockies |
| Authheader = ""; |
| AuthQop = ""; |
| username = ""; |
| passwd = ""; |
| GnCount = ""; |
| Authrealm = ""; |
| //window.location.reload(); |
| window.location.href = '/'; |
| } |
| /* |
| * Reset the authHeader |
| */ |
| function resetInterval() { |
| if(authHeaderIntervalID > 0) |
| clearInterval(authHeaderIntervalID); |
| authHeaderIntervalID = setInterval( "clearAuthheader()", _resetTimeOut); |
| |
| } |
| |
| |
| /* |
| * Check the login responce as the 200 OK or not. |
| */ |
| function login_done(urlData) { |
| if(urlData.indexOf("200 OK") != -1 ) { |
| return true; |
| } else { |
| return false; |
| } |
| } |
| function getValue(authstr) { |
| var arr=authstr.split("="); |
| return arr[1].substring(1,arr[1].indexOf('\"',2) ); |
| } |
| /* |
| * as name suggest it is function which does the authentication |
| * and put the AuthHeader in the Cookies. Uses Digest Auth method |
| */ |
| function doLogin(username1,passwd1) { |
| var url = window.location.protocol + "//" + window.location.host + "/login.cgi"; |
| var loginParam = getAuthType(url); |
| //alert(loginParam); |
| if(loginParam!=null) { |
| var loginParamArray = loginParam.split(" "); |
| if(loginParamArray[0] =="Digest") { |
| //nonce="718337c309eacc5dc1d2558936225417", qop="auth" |
| Authrealm = getValue(loginParamArray[1]); |
| nonce = getValue(loginParamArray[2]); |
| AuthQop = getValue(loginParamArray[3]); |
| |
| // alert("nonce :" + nonce); |
| // alert("AuthQop :" + AuthQop); |
| // alert("Authrealm :" + Authrealm); |
| |
| username = username1; |
| passwd = passwd1; |
| var rand, date, salt, strResponse; |
| |
| Gnonce = nonce; |
| var tmp, DigestRes; |
| var HA1, HA2; |
| |
| |
| |
| |
| |
| HA1 = hex_md5(username+ ":" + Authrealm + ":" + passwd); |
| HA2 = hex_md5("GET" + ":" + "/cgi/xml_action.cgi"); |
| |
| rand = Math.floor(Math.random()*100001) |
| date = new Date().getTime(); |
| |
| salt = rand+""+date; |
| tmp = hex_md5(salt); |
| AuthCnonce = tmp.substring(0,16); |
| |
| |
| var strhex = hex(GnCount); |
| var temp = "0000000000" + strhex; |
| var Authcount = temp.substring(temp.length-8); |
| DigestRes = hex_md5(HA1 + ":" + nonce + ":" + Authcount + ":" + AuthCnonce + ":" + AuthQop + ":" + HA2); |
| |
| url = window.location.protocol + "//" + window.location.host + "/login.cgi?Action=Digest&username="+username+"&realm="+Authrealm+"&nonce="+nonce+"&response="+DigestRes+"&qop="+AuthQop+"&cnonce="+AuthCnonce + "&nc="+Authcount+"&temp=marvell"; |
| if(login_done(authentication(url))) { |
| strResponse = "Digest username=\"" + username + "\", realm=\"" + Authrealm + "\", nonce=\"" + nonce + "\", uri=\"" + "/cgi/protected.cgi" + "\", response=\"" + DigestRes + "\", qop=" + AuthQop + ", nc=00000001" + ", cnonce=\"" + AuthCnonce + "\"" ; |
| |
| return 1; |
| } else { |
| // show error message... |
| return 0; |
| } |
| |
| return strResponse; |
| } |
| } |
| return -1; |
| } |
| |
| function getAuthHeader(requestType,file) { |
| var rand, date, salt, strAuthHeader; |
| var tmp, DigestRes,AuthCnonce_f; |
| var HA1, HA2; |
| |
| |
| |
| HA1 = hex_md5(username+ ":" + Authrealm + ":" + passwd); |
| HA2 = hex_md5( requestType + ":" + "/cgi/xml_action.cgi"); |
| |
| rand = Math.floor(Math.random()*100001) |
| date = new Date().getTime(); |
| |
| salt = rand+""+date; |
| tmp = hex_md5(salt); |
| AuthCnonce_f = tmp.substring(0,16); |
| //AuthCnonce_f = tmp; |
| |
| var strhex = hex(GnCount); |
| var temp = "0000000000" + strhex; |
| var Authcount = temp.substring(temp.length-8); |
| DigestRes =hex_md5(HA1 + ":" + nonce + ":" + Authcount + ":" + AuthCnonce_f + ":" + AuthQop + ":"+ HA2); |
| |
| |
| GnCount++; |
| strAuthHeader = "Digest " + "username=\"" + username + "\", realm=\"" + Authrealm + "\", nonce=\"" + nonce + "\", uri=\"" + "/cgi/xml_action.cgi" + "\", response=\"" + DigestRes + "\", qop=" + AuthQop + ", nc=" + Authcount + ", cnonce=\"" + AuthCnonce_f + "\"" ; |
| DigestHeader = strAuthHeader ; |
| return strAuthHeader; |
| } |
| |
| |
| function logOut() { |
| var host = window.location.protocol + "//" + window.location.host + "/"; |
| var url = host+'xml_action.cgi?Action=logout'; |
| $.ajax( { |
| type: "GET", |
| url: url, |
| dataType: "html", |
| async:false, |
| complete: function() { |
| clearAuthheader(); |
| } |
| }); |
| } |
| |
| |
| |
| function getHeader (AuthMethod , file) { |
| var rand, date, salt, setResponse; |
| var tmp, DigestRes,AuthCnonce_f; |
| var HA1, HA2; |
| |
| HA1 = hex_md5(username + ":" + Authrealm + ":" + passwd); |
| HA2 = hex_md5(AuthMethod + ":" + "/cgi/xml_action.cgi"); |
| |
| /*Generate random sequence for Cnonce*/ |
| // Integer random = new Integer(Random.nextInt(2097152)); |
| // Integer date = new Integer((int)(System.currentTimeMillis() + 24)); |
| rand = Math.floor(); |
| date = new Date().getTime(); |
| |
| |
| salt = rand+""+date; |
| tmp = hex_md5(salt); |
| AuthCnonce = tmp.substring(0,16); |
| AuthCnonce_f = tmp; |
| |
| var strhex = hex(GnCount); |
| var temp = "0000000000" + strhex; |
| var Authcount = temp.substring(temp.length-8); |
| |
| DigestRes =hex_md5(HA1 + ":" + Gnonce + ":" + Authcount + ":" + AuthCnonce_f + ":" + AuthQop + ":"+ HA2); |
| |
| |
| ++GnCount; |
| |
| if("GET" == AuthMethod) { |
| if("upgrade" == file) { |
| //setResponse = "/login.cgi?Action=Upload&file=" + file + "&username=" + username + "&realm=" + Authrealm + "&nonce=" + Gnonce + "&response=" + DigestRes + "&cnonce=" + AuthCnonce_f + "&nc=" + Authcount + "&qop=" + AuthQop + "&temp=marvell"; |
| setResponse= "/xml_action.cgi?Action=Upload&file=upgrade&command=" |
| } else if("config_backup" == file) { |
| setResponse= "/xml_action.cgi?Action=Upload&file=backfile&config_backup=" |
| } else { |
| setResponse = "/login.cgi?Action=Download&file=" + file + "&username=" + username + "&realm=" + Authrealm + "&nonce=" + Gnonce + "&response=" + DigestRes + "&cnonce=" + AuthCnonce_f + "&nc=" + Authcount + "&qop=" + AuthQop + "&temp=marvell"; |
| } |
| } |
| |
| if("POST"==AuthMethod) { |
| setResponse = "/login.cgi?Action=Upload&file=" + file + "&username=" + username + "&realm=" + Authrealm + "&nonce=" + Gnonce + "&response=" + DigestRes + "&cnonce=" + AuthCnonce_f + "&nc=" + Authcount + "&qop=" + AuthQop + "&temp=marvell"; |
| } |
| |
| return setResponse; |
| } |
| |
| /* |
| * return the cookie parameter is Coockie name |
| */ |
| function GetCookie(c_name) { |
| if (document.cookie.length>0) { |
| c_start=document.cookie.indexOf(c_name + "="); |
| if (c_start!=-1) { |
| c_start=c_start + c_name.length+1; |
| c_end=document.cookie.indexOf(";",c_start); |
| if (c_end==-1) c_end=document.cookie.length; |
| return unescape(document.cookie.substring(c_start,c_end)); |
| } |
| } |
| return ""; |
| } |
| /* |
| * set cookie of browser it has expiry days after which it expires |
| */ |
| function SetCookie(c_name,value,expiredays) { |
| var exdate=new Date(); |
| exdate.setDate(exdate.getDate()+expiredays); |
| document.cookie=c_name+ "=" +escape(value)+ |
| ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); |
| } |
| |
| |
| |
| function ElementLocaliztion(pElementArray) { |
| for(var i=0; i<pElementArray.length; i++) { |
| if(jQuery.i18n.prop(pElementArray[i].id)!=null) |
| document.getElementById(pElementArray[i].id).innerHTML = jQuery.i18n.prop(pElementArray[i].id); |
| } |
| } |
| function LocalElementById(elementId) { |
| if("input" == document.getElementById(elementId).tagName.toLowerCase()) { |
| document.getElementById(elementId).value = jQuery.i18n.prop(elementId); |
| } else { |
| document.getElementById(elementId).innerHTML = jQuery.i18n.prop(elementId); |
| } |
| |
| } |
| |
| function LocalElementByTagName(elementTagName) { |
| if("button" == elementTagName) { |
| $(":button").each(function() { |
| $(this).val(jQuery.i18n.prop($(this).attr("id"))) |
| }) |
| } else { |
| $(elementTagName).each(function() { |
| $(this).text(jQuery.i18n.prop($(this).attr("id"))) |
| }) |
| } |
| } |
| |
| function LocalAllElement(){ |
| $("[id^='lt_']").each(function() { |
| if("input" == document.getElementById($(this).attr("id")).tagName.toLowerCase()) { |
| $(this).val(jQuery.i18n.prop($(this).attr("id"))); |
| }else{ |
| $(this).text(jQuery.i18n.prop($(this).attr("id"))); |
| } |
| }); |
| } |
| |
| |
| |
| |
| function hex(d) { |
| var hD="0123456789ABCDEF"; |
| var h = hD.substr(d&15,1); |
| while(d>15) { |
| d>>=4; |
| h=hD.substr(d&15,1)+h; |
| } |
| return h; |
| |
| } |
| |
| function clearTabaleRows(tableId) { |
| |
| var i=document.getElementById(tableId).rows.length; |
| while(i!=1) { |
| document.getElementById(tableId).deleteRow(i-1); |
| i--; |
| } |
| |
| } |
| |
| |
| |
| /* Converts timezone offset expressed in minutes to string */ |
| function GetMachineTimezoneGmtOffsetStr(tzGmtOffset ) { |
| var gmtOffsetStr =""+ getAbsValue(tzGmtOffset/60); |
| var tempInt = tzGmtOffset; |
| |
| if(tempInt < 0) { |
| tempInt = 0 - tempInt; |
| } |
| |
| if(( tempInt % 60 ) != 0 ) { |
| gmtOffsetStr += ":" + ( tempInt % 60 ); |
| } |
| |
| //new XDialog("Error","gmt offset" + gmtOffsetStr ).alert(); |
| |
| return gmtOffsetStr; |
| } |
| /* Find out timezone offset settings from connected device. If dst is observed we should see |
| * difference in Jan and July timezone offset.Pick the max one */ |
| function GetMachineTimezoneGmtOffset() { |
| var rightNow = new Date(); |
| |
| var JanuaryFirst= new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0,0); |
| var JulyFirst= new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0,0); |
| |
| var JanOffset,JulyOffset; |
| var tzGmtOffset; |
| |
| JanOffset = JanuaryFirst.getTimezoneOffset(); |
| JulyOffset = JulyFirst.getTimezoneOffset(); |
| |
| if(JulyOffset > JanOffset) { |
| tzGmtOffset= JulyOffset; |
| } else { |
| tzGmtOffset = JanOffset; |
| } |
| |
| return tzGmtOffset; |
| } |
| |
| /* Get the connected device's day light saving settings in string format e.g. M3.5.0 or J81 */ |
| function GetMachineTimezoneDstStartStr(StandardGMToffset) { |
| var rightNow = new Date(); |
| |
| var JanuaryFirst = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0,0); |
| var JulyFirst= new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0,0); |
| var HoursInSixMonths =((JulyFirst.getTime() - JanuaryFirst.getTime()) / (1000 * 60 * 60)); |
| var dstStartStr = ""; |
| var i ; |
| var JanOffset, JulyOffset; |
| var hourStart, hourEnd; |
| |
| /* If there are dst settings to be considered we should get them by checking in 6 months time interval */ |
| JanOffset = JanuaryFirst.getTimezoneOffset(); |
| JulyOffset = JulyFirst.getTimezoneOffset(); |
| |
| if(JanOffset > JulyOffset) { |
| hourStart = 0; |
| hourEnd = HoursInSixMonths; |
| } else { |
| hourStart = HoursInSixMonths; |
| hourEnd = HoursInSixMonths * 2; |
| } |
| |
| |
| var tempDate = getDstStartTime(hourStart,hourEnd, rightNow.getYear(),StandardGMToffset); |
| |
| if(tempDate != null) { |
| /* Dst setting string : M3.5.0 (Month of the year).(Week Of Month).(Day of Week) |
| * So We need to iterate over six months period for few years and find which week of month it is */ |
| |
| var changeWeek = getChangeWeek(hourStart,hourEnd, tempDate.getYear(),StandardGMToffset); |
| |
| switch(changeWeek) { |
| case -1: |
| break; |
| case -2: // Some regions have fixed day for start of dst setting which is expressed with J |
| dstStartStr ="J" + (((tempDate.getTime()-JanuaryFirst.getTime())/(24 * 60 * 60* 1000) ) + 1); |
| break; |
| default: |
| dstStartStr = "M" + (tempDate.getMonth() + 1) + "." + changeWeek + "." + tempDate.getDay(); |
| break; |
| } |
| } |
| |
| return dstStartStr; |
| } |
| |
| function getDstStartTime(hourStart,hourEnd, year,StandardGMToffset) { |
| /* Check at which hour timezone offset is different from standard timezone |
| * offset for that region. Thats the start of dst */ |
| |
| var i; |
| for(i = hourStart; i < hourEnd; i++) { |
| var dSampleDate = new Date(year,0, 1, 0, 0, 0,0); |
| dSampleDate.setHours(i); |
| |
| var CurrentGMToffset = dSampleDate.getTimezoneOffset(); |
| |
| if(CurrentGMToffset < StandardGMToffset) { |
| return dSampleDate; |
| } |
| } |
| return null; |
| |
| } |
| function setConnectedDeviceTimezoneStr(gmtOffset,dstStart,timezoneStringArray) { |
| var i,j; |
| var startIndex = -1; |
| var count = 0; |
| var index = -1; |
| |
| var tempGmtString; |
| var tempDstString; |
| |
| for(j = 0; j < timezoneStringArray[1].length ; j++) { |
| var charArr = toCharArray(timezoneStringArray[1][j]); |
| count = 0; |
| tempGmtString = ""; |
| tempDstString = ""; |
| startIndex = -1; |
| |
| for(i = 0; i < timezoneStringArray[1][j].split(",",3)[0].length; i++) { |
| if(((charArr[i] >= '0') && (charArr[i] <= '9')) ||(charArr[i] == '-') || (charArr[i] == ':')) { |
| count++; |
| if(startIndex == -1) { |
| startIndex = i; |
| } |
| tempGmtString = tempGmtString + charArr[i]; |
| } |
| |
| } |
| |
| if(tempGmtString == gmtOffset) { |
| |
| if(timezoneStringArray[1][j].split(",",3).length > 1) { |
| tempDstString = timezoneStringArray[1][j].split(",",3)[1]; |
| } else { |
| tempDstString = ""; |
| } |
| |
| if((dstStart.length == 0) && (tempDstString.length != 0)) { |
| //new XDialog("Error","gmt offset matched but dst settings did not match!" + dstStart + "__" + tempDstString).alert(); |
| continue; |
| } |
| |
| if(tempDstString.substring(0,dstStart.length) == dstStart) { |
| //new XDialog("Error","Found perfect timezone match with gmt and dst" + timezoneStringArray[1][j]).alert(); |
| index = j; |
| break; |
| } else { |
| //new XDialog("Error","gmt offset matched but dst settings did not match!" + dstStart + "__" + tempDstString).alert(); |
| continue; |
| } |
| |
| } else { |
| //new XDialog("Error","gmt offset did not match!" + tempGmtString + "__" + gmtOffset).alert(); |
| continue; |
| } |
| |
| } |
| |
| if(index == -1) { |
| //new XDialog("Error","Failed to get timezone settings from connected device").alert(); |
| //new XDialog("Error","Failed_ " + gmtOffset +"_" + dstStart).alert(); |
| //GetPCTimeZoneString.setText(""); |
| return -1; |
| } else { |
| //GetPCTimeZoneString.setText(timezoneStringComboBox.getItemText(index)); |
| //timezoneString.setText(timezoneStringArray[1][index]); |
| return index; |
| } |
| } |
| function toCharArray(str) { |
| var charArray = new Array(0); |
| for(var i=0; i<str.length; i++) |
| charArray[i]=str.charAt(i); |
| return charArray; |
| } |
| |
| /* We know the day of month but not the week. We can find day of the month for few years |
| * and guess which week of the month it would be */ |
| function getChangeWeek( hourStart, hourEnd, year, StandardGMToffset) { |
| var i; |
| var min = 32 , max = 0, dom = 0; |
| |
| for(i = year; i < year + 20 ; i++) { |
| dom =(getDstStartTime(hourStart,hourEnd,i,StandardGMToffset)).getDate(); |
| if(dom > max) { |
| max = dom; |
| } |
| if(dom < min) { |
| min = dom; |
| } |
| } |
| |
| if(max == min) { |
| return -1; |
| } |
| |
| /* Some regions have fixed day for start of dst settings. e.g 1 April |
| * We handle it as special case */ |
| if(max - min != 6) { |
| return -2; |
| } |
| |
| //new XDialog("Error","max " + max + "min " + min + " dom " + dom).alert(); |
| return getAbsValue((((max + 6)/7))); |
| |
| } |
| |
| function getAbsValue(i) { |
| |
| return i.toString().split(".")[0]; |
| } |
| |
| |
| function getHelp(helpPage) { |
| if(GetCookie('locale')=='') |
| htmlFilename = "help_en.html"; |
| else |
| htmlFilename = "help_" + GetCookie('locale')+".html"; |
| var host = window.location.protocol + "//" + window.location.host + "/"; |
| var url = host + htmlFilename + "#" + helpPage; |
| |
| var helpWindow = window.open(url, 'newwindow'); |
| helpWindow.focus(); |
| |
| } |
| function getMainHelp() { |
| getHelp(""); |
| } |
| function showAlert(msgLanguageID) { |
| ShowDlg("alertMB",350,150); |
| document.getElementById("lAlertMessage").innerHTML = jQuery.i18n.prop(msgLanguageID); |
| document.getElementById("lAlert").innerHTML = jQuery.i18n.prop("lAlert"); |
| LocalElementById("btnModalOk"); |
| } |
| |
| |
| function UniEncode(string) { |
| if (undefined == string) { |
| return ""; |
| } |
| var code = ""; |
| for (var i = 0; i < string.length; ++i) { |
| var charCode = string.charCodeAt(i).toString(16); |
| var paddingLen = 4 - charCode.length; |
| for (var j = 0; j < paddingLen; ++j) { |
| charCode = "0" + charCode; |
| } |
| |
| code += charCode; |
| } |
| return code; |
| } |
| |
| function GetSmsTime() { |
| var date = new Date(); |
| var fullYear = new String(date.getFullYear()); |
| var year = fullYear.substr(2, fullYear.length - 1); |
| var month = date.getMonth() + 1; |
| var day = date.getDate(); |
| var hour = date.getHours(); |
| var mimute = date.getMinutes(); |
| var second = date.getSeconds(); |
| var timeZone = 0 - date.getTimezoneOffset() / 60; |
| var timeZoneStr = ""; |
| if (timeZone > 0) { |
| timeZoneStr = "%2B" + timeZone; |
| } else { |
| timeZoneStr = "-" + timeZone; |
| } |
| var smsTime = year + "," + month + "," + day + "," + hour + "," + mimute + "," + second + "," + timeZoneStr; |
| return smsTime; |
| } |
| |
| |
| function UniDecode(encodeString) { |
| if (undefined == encodeString) { |
| return ""; |
| } |
| var deCodeStr = ""; |
| |
| var strLen = encodeString.length / 4; |
| for (var idx = 0; idx < strLen; ++idx) { |
| deCodeStr += String.fromCharCode(parseInt(encodeString.substr(idx * 4, 4), 16)); |
| } |
| return deCodeStr; |
| } |
| |
| function showMsgBox(title, message) { |
| ShowDlg("alertMB", 350, 150); |
| document.getElementById("lAlertMessage").innerHTML = message; |
| document.getElementById("lAlert").innerHTML = title; |
| document.getElementById("btnModalOk").value = jQuery.i18n.prop("btnModalOk"); |
| } |
| |
| function GetBrowserType() { |
| var usrAgent = navigator.userAgent; |
| if (navigator.userAgent.indexOf("MSIE") > 0) { |
| var b_version = navigator.appVersion |
| var version = b_version.split(";"); |
| var trim_Version = version[1].replace(/[ ]/g, ""); |
| if (trim_Version == "MSIE6.0") { |
| return "IE6"; |
| } else if(trim_Version == "MSIE7.0") { |
| return "IE7"; |
| } else if (trim_Version == "MSIE8.0") { |
| return "IE8"; |
| } else if (trim_Version == "MSIE9.0") { |
| return "IE9"; |
| } |
| } |
| if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) { |
| return "Firefox"; |
| } |
| if (isSafari = navigator.userAgent.indexOf("Safari") > 0) { |
| return "Safari"; //google |
| } |
| if (isCamino = navigator.userAgent.indexOf("Camino") > 0) { |
| return "Camino"; |
| } |
| if (isMozilla = navigator.userAgent.indexOf("Gecko/") > 0) { |
| return "Gecko"; |
| } |
| } |
| |
| function IsGSM7Code(str) { |
| var len = 0; |
| for( var i = 0; i < str.length; i++) { |
| var chr = str.charCodeAt(i); |
| if(((chr>=0x20&&chr<=0x7f)||0x20AC==chr||0x20AC==chr||0x0c==chr||0x0a==chr||0x0d==chr||0xa1==chr||0xa3==chr||0xa5==chr||0xa7==chr |
| ||0xbf==chr||0xc4==chr||0xc5==chr||0xc6==chr||0xc7==chr||0xc9==chr||0xd1==chr||0xd6==chr||0xd8==chr||0xdc==chr||0xdf==chr |
| ||0xe0==chr||0xe4==chr||0xe5==chr||0xe6==chr||0xe8==chr||0xe9==chr||0xec==chr||0xf11==chr||0xf2==chr||0xf6==chr||0xf8==chr||0xf9==chr||0xfc==chr |
| ||0x3c6==chr||0x3a9==chr||0x3a8==chr||0x3a3==chr||0x3a0==chr||0x39e==chr||0x39b==chr||0x398==chr||0x394==chr||0x393==chr) |
| && 0x60 != chr) { |
| ++len; |
| } |
| } |
| return len == str.length; |
| } |
| |
| function EditHrefs(s_html) { |
| var s_str = new String(s_html); |
| s_str = s_str.replace(/\bhttp\:\/\/www(\.[\w+\.\:\/\_]+)/gi, |
| "http\:\/\/¬¸$1"); |
| s_str = s_str.replace(/\b(http\:\/\/\w+\.[\w+\.\:\/\_]+)/gi, |
| "<a target=\"_blank\" href=\"$1\">$1<\/a>"); |
| s_str = s_str.replace(/\b(www\.[\w+\.\:\/\_]+)/gi, |
| "<a target=\"_blank\" href=\"http://$1\">$1</a>"); |
| s_str = s_str.replace(/\bhttp\:\/\/¬¸ (\.[\w+\.\:\/\_]+)/gi, |
| "<a target=\"_blank\" href=\"http\:\/\/www$1\">http\:\/\/www$1</a>"); |
| s_str = s_str.replace(/\b(\w+@[\w+\.?]*)/gi, |
| "<a href=\"mailto\:$1\">$1</a>"); |
| return s_str; |
| } |
| |
| function RemoveHrefs(str) { |
| str = str.replace(/<a.*?>/ig,""); |
| str = str.replace(/<\/a>/ig,""); |
| return str; |
| } |
| |
| |
| |
| function GetIpAddr(elementId){ |
| var ipAddr=""; |
| for(var idx = 1; idx < 5; ++idx){ |
| var selectorId = "#" + elementId + idx; |
| ipAddr = ipAddr + $(selectorId).val() + "."; |
| } |
| return ipAddr.substr(0,ipAddr.length-1); |
| } |
| |
| |
| function SetIpAddr(elementId, ipAddr){ |
| var IpAddrArr = ipAddr.split("."); |
| for(var idx = 1; idx < 5; ++idx){ |
| var selectorId = "#" + elementId + idx; |
| $(selectorId).val(IpAddrArr[idx-1]); |
| } |
| } |
| |
| //time format: hh:mm:ss |
| function GetTimeFromElement(elementId){ |
| var strTime=""; |
| for(var idx = 1; idx < 4; ++idx){ |
| var selectorId = "#" + elementId + idx; |
| strTime = strTime + $(selectorId).val() + ":"; |
| } |
| return strTime.substr(0,strTime.length-1); |
| } |
| |
| //time format: hh:mm:ss |
| function SetTimeToElement(elementId,time){ |
| var timeArr = time.split(":"); |
| for(var idx = 1; idx < 4; ++idx){ |
| var selectorId = "#" + elementId + idx; |
| $(selectorId).val(timeArr[idx-1]); |
| } |
| } |
| |
| |
| //date format: yyyy-mm-dd |
| function SetDateToElement(elementId,date){ |
| var timeArr = date.split("-"); |
| for(var idx = 1; idx < 4; ++idx){ |
| var selectorId = "#" + elementId + idx; |
| $(selectorId).val(timeArr[idx-1]); |
| } |
| } |
| |
| //date format: yyyy-mm-dd |
| function GetDateFromElement(elementId){ |
| var strDate = ""; |
| for(var idx = 1; idx < 4; ++idx){ |
| var selectorId = "#" + elementId + idx; |
| strDate = strDate + $(selectorId).val() + "-"; |
| } |
| return strDate.substr(0,strDate.length-1); |
| } |
| |
| //time format: hh:mm |
| function GetTimeFromElementEx(elementId) { |
| var strTime = ""; |
| for (var idx = 1; idx < 3; ++idx) { |
| var selectorId = "#" + elementId + idx; |
| strTime = strTime + $(selectorId).val() + ":"; |
| } |
| return strTime.substr(0, strTime.length - 1); |
| } |
| |
| //time format: hh:mm |
| function SetTimeToElementEx(elementId, timectrl) { |
| var timeArr = timectrl.split(":"); |
| for (var idx = 1; idx < 3; ++idx) { |
| var selectorId = "#" + elementId + idx; |
| $(selectorId).val(timeArr[idx - 1]); |
| } |
| } |
| |
| function GetPortFromElement(elementId){ |
| var strPort=""; |
| for(var idx = 1; idx < 3; ++idx){ |
| var selectorId = "#" + elementId + idx; |
| strPort = strPort + $(selectorId).val() + ":"; |
| } |
| return strPort.substr(0,strPort.length-1); |
| } |
| |
| //port format: xxxx:yyyy |
| function SetPortToElement(elementId,port){ |
| var portArr = port.split(":"); |
| for(var idx = 1; idx < 3; ++idx){ |
| var selectorId = "#" + elementId + idx; |
| $(selectorId).val(portArr[idx-1]); |
| } |
| } |
| |
| function FormatSeconds(longTime) { |
| |
| var time = parseFloat(longTime); |
| var d=0; |
| var h=0; |
| var m=0; |
| var s=0; |
| if (time != null && time != ""){ |
| if (time < 60) { |
| s = time; |
| |
| } else if (time > 60 && time < 3600) { |
| m = parseInt(time / 60); |
| s = parseInt(time % 60); |
| |
| } else if (time >= 3600 && time < 86400) { |
| h = parseInt(time / 3600); |
| m = parseInt(time % 3600 / 60); |
| s = parseInt(time % 3600 % 60 % 60); |
| |
| } else if (time >= 86400) { |
| d = parseInt(time / 86400); |
| h = parseInt(time % 86400 / 3600); |
| m = parseInt(time % 86400 % 3600 / 60) |
| s = parseInt(time % 86400 % 3600 % 60 % 60); |
| |
| } |
| } |
| |
| time = d+" - "+fix(h,2)+":"+fix(m,2)+":"+fix(s,2)+("(Days - hh:mm:ss)"); |
| return time; |
| } |
| |
| function fix(num, length) { |
| return ('' + num).length < length ? ((new Array(length + 1)).join('0') + num).slice(-length) : '' + num; |
| } |
| |
| //Contents of xml_helper.js |
| |
| /* |
| * MAP对象,实现MAP功能 |
| * |
| * 接口: |
| * size() 获取MAP元素个数 |
| * isEmpty() 判断MAP是否为空 |
| * clear() 删除MAP所有元素 |
| * put(key, value) 向MAP中增加元素(key, value) |
| * remove(key) 删除指定KEY的元素,成功返回True,失败返回False |
| * get(key) 获取指定KEY的元素值VALUE,失败返回NULL |
| * element(index) 获取指定索引的元素(使用element.key,element.value获取KEY和VALUE),失败返回NULL |
| * containsKey(key) 判断MAP中是否含有指定KEY的元素 |
| * containsValue(value) 判断MAP中是否含有指定VALUE的元素 |
| * values() 获取MAP中所有VALUE的数组(ARRAY) |
| * keys() 获取MAP中所有KEY的数组(ARRAY) |
| * |
| * 例子: |
| * var map = new Map(); |
| * |
| * map.put("key", "value"); |
| * var val = map.get("key") |
| * …… |
| * |
| */ |
| function Map() { |
| this.elements = new Array(); |
| |
| //获取MAP元素个数 |
| this.size = function() { |
| return this.elements.length; |
| } |
| |
| |
| //判断MAP是否为空 |
| this.isEmpty = function() { |
| return (this.elements.length < 1); |
| } |
| |
| //删除MAP所有元素 |
| this.clear = function() { |
| this.elements = new Array(); |
| } |
| |
| //向MAP中增加元素(key, value) |
| this.put = function(_key, _value) { |
| this.elements.push( { |
| key : _key, |
| value : _value |
| }); |
| } |
| |
| //删除指定KEY的元素,成功返回True,失败返回False |
| this.remove = function(_key) { |
| var bln = false; |
| try { |
| for (i = 0; i < this.elements.length; i++) { |
| if (this.elements[i].key == _key) { |
| this.elements.splice(i, 1); |
| return true; |
| } |
| } |
| } catch (e) { |
| bln = false; |
| } |
| return bln; |
| } |
| |
| // |
| this.setKeyValue = function(_key,_value){ |
| for (i = 0; i < this.elements.length; i++) { |
| if (this.elements[i].key == _key) { |
| this.elements[i].value = _value; |
| break; |
| } |
| } |
| } |
| |
| //获取指定KEY的元素值VALUE,失败返回NULL |
| this.get = function(_key) { |
| try { |
| for (i = 0; i < this.elements.length; i++) { |
| if (this.elements[i].key == _key) { |
| return this.elements[i].value; |
| } |
| } |
| } catch (e) { |
| return null; |
| } |
| } |
| |
| //获取指定索引的元素(使用element.key,element.value获取KEY和VALUE),失败返回NULL |
| this.element = function(_index) { |
| if (_index < 0 || _index >= this.elements.length) { |
| return null; |
| } |
| return this.elements[_index]; |
| } |
| |
| //获取指定索引的key,失败返回NULL |
| this.getKey = function(_index) { |
| if (_index < 0 || _index >= this.elements.length) { |
| return null; |
| } |
| return this.elements[_index].key; |
| } |
| |
| //获取指定索引的value,失败返回NULL |
| this.getValue = function(_index) { |
| if (_index < 0 || _index >= this.elements.length) { |
| return null; |
| } |
| return this.elements[_index].value; |
| } |
| |
| //判断MAP中是否含有指定KEY的元素 |
| this.containsKey = function(_key) { |
| var bln = false; |
| try { |
| for (i = 0; i < this.elements.length; i++) { |
| if (this.elements[i].key == _key) { |
| bln = true; |
| } |
| } |
| } catch (e) { |
| bln = false; |
| } |
| return bln; |
| } |
| |
| //判断MAP中是否含有指定VALUE的元素 |
| this.containsValue = function(_value) { |
| var bln = false; |
| try { |
| for (i = 0; i < this.elements.length; i++) { |
| if (this.elements[i].value == _value) { |
| bln = true; |
| } |
| } |
| } catch (e) { |
| bln = false; |
| } |
| return bln; |
| } |
| |
| //获取MAP中所有VALUE的数组(ARRAY) |
| this.values = function() { |
| var arr = new Array(); |
| for (i = 0; i < this.elements.length; i++) { |
| arr.push(this.elements[i].value); |
| } |
| return arr; |
| } |
| |
| //获取MAP中所有KEY的数组(ARRAY) |
| this.keys = function() { |
| var arr = new Array(); |
| for (i = 0; i < this.elements.length; i++) { |
| arr.push(this.elements[i].key); |
| } |
| return arr; |
| } |
| |
| //copy map |
| this.copy = function(){ |
| var _newMap = new Map(); |
| for(var i = 0; i < this.size(); ++i) |
| { |
| _newMap.put(this.element(i).key, this.element(i).value); |
| } |
| return _newMap; |
| } |
| |
| //返回和_map中value不同的element, |
| this.getChange = function(_map){ |
| var _newMap = new Map; |
| for(var i = 0; i < this.size(); ++i) |
| { |
| var _value = _map.get(this.element(i).key); //获取相同key在_map中对应的value |
| if(null == _value || undefined == _value) //_map中不存在 |
| { |
| /*var errMsg = "Error: Key \"" + _map.element(i).key + "\" only exists on one map." |
| alert(errMsg); |
| return null;*/ |
| _newMap.put(this.element(i).key,this.element(i).value); |
| continue; |
| } |
| if(_value != this.element(i).value) |
| { |
| _newMap.put(this.element(i).key,this.element(i).value); |
| } |
| } |
| return _newMap; |
| } |
| |
| |
| //在头部增加element |
| this.push_front = function(_key, _value){ |
| |
| this.elements.splice(0,0, { |
| key : _key, |
| value : _value}); |
| } |
| |
| } |
| |
| |
| |
| (function ($) { |
| |
| $.fn.XML_Operations = function () { |
| var text='<?xml version="1.0" encoding="US-ASCII"?>'; |
| // Opera implicitly add the xml tag so no need to do it again. |
| if(window.opera) |
| text=''; |
| this.getXMLDOC = function () { |
| |
| var xmlDoc; |
| if (window.DOMParser) { |
| parser=new DOMParser(); |
| xmlDoc=parser.parseFromString("<RGW></RGW>","text/xml"); |
| } else { // Internet Explorer |
| xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); |
| xmlDoc.async="false"; |
| xmlDoc.loadXML("<RGW></RGW>"); |
| } |
| return xmlDoc; |
| } |
| this.getXMLDOCVersion = function(text) { |
| var xmlDoc; |
| if (window.DOMParser) { |
| parser=new DOMParser(); |
| xmlDoc=parser.parseFromString(text,"text/xml"); |
| } else { // Internet Explorer |
| xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); |
| xmlDoc.async="false"; |
| xmlDoc.loadXML(text); |
| } |
| return xmlDoc; |
| } |
| this.getInternetExplorerVersion = function() { |
| var rv = -1; // Return value assumes failure. |
| if (navigator.appName == 'Microsoft Internet Explorer') { |
| var ua = navigator.userAgent; |
| var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); |
| if (re.exec(ua) != null) |
| rv = parseFloat( RegExp.$1 ); |
| } |
| return rv; |
| } |
| this.getXMLDocToString = function (oXML) { |
| var xmlString=""; |
| |
| if (window.ActiveXObject) { |
| var ver = g_objXML.getInternetExplorerVersion(); |
| if ( ver > -1 ) { |
| if (ver <= 8.0) |
| xmlString = oXML.xml; |
| else |
| xmlString = (new XMLSerializer()).serializeToString(oXML); |
| } |
| } else { |
| xmlString = (new XMLSerializer()).serializeToString(oXML); |
| } |
| return text + " " + xmlString; |
| } |
| this.createNode = function (xmlDoc,parent,element,value) { |
| var newel=xmlDoc.createElement(element); |
| if(value!=null) { |
| var _value = xmlDoc.createTextNode(value); |
| newel.appendChild(_value); |
| } |
| var _element=xmlDoc.getElementsByTagName(parent); |
| _element[0].appendChild(newel); |
| return xmlDoc; |
| } |
| |
| this.createItemNode = function (xmlDoc,parent,element,value,index) { |
| var newel=xmlDoc.createElement(element); |
| if(value!=null) { |
| // var _value = xmlDoc.createTextNode(value); |
| // newel.appendChild(_value); |
| newel.setAttribute("index", index); |
| } |
| var _element=xmlDoc.getElementsByTagName(parent); |
| |
| _element[0].appendChild(newel); |
| return xmlDoc; |
| } |
| this.createDeleteNode = function (xmlDoc,parent,element,value,index) { |
| var newel=xmlDoc.createElement(element); |
| if(value!=null) { |
| var _value = xmlDoc.createTextNode(value); |
| newel.appendChild(_value); |
| newel.setAttribute("Delete", 1); |
| } |
| var _element=xmlDoc.getElementsByTagName(parent); |
| |
| _element[0].appendChild(newel); |
| return xmlDoc; |
| } |
| |
| this.childExist = function (xmlDoc,child) { |
| var _element=xmlDoc.getElementsByTagName(child); |
| if(_element[0]!=null) |
| return true; |
| else |
| return false; |
| } |
| |
| this.createXML = function(controlMap) { |
| |
| var xmlDoc = this.getXMLDOC(text); |
| for(var i=0; i<controlMap.size(); i++) { |
| var j; |
| if(controlMap.element(i)!=null) { |
| var _key = controlMap.element(i).key; |
| var _value = controlMap.element(i).value; |
| var token = _key.split("/"); |
| for(j=0; j<token.length-1; j++) |
| if(!this.childExist(xmlDoc,token[j])) |
| xmlDoc = this.createNode(xmlDoc,token[j-1],token[j],null); |
| |
| if(token[j].indexOf("#index")!=-1) { |
| var cNode=token[j].substring(0,token[j].indexOf("#index")); |
| xmlDoc = this.createItemNode(xmlDoc,token[j-1],cNode,_value,i); |
| } else if(token[j].indexOf("#delete")!=-1) { |
| var deleteNode=token[j].substring(0,token[j].indexOf("#delete")); |
| xmlDoc = this.createDeleteNode(xmlDoc,token[j-1],deleteNode,_value,i); |
| } else { |
| xmlDoc = this.createNode(xmlDoc,token[j-1],token[j],_value); |
| } |
| |
| } |
| } |
| return xmlDoc; |
| } |
| |
| return this.each(function () { |
| }); |
| } |
| })(jQuery); |
| |
| |
| function CreateXmlDocStr(controlMap){ |
| if(null == controlMap || undefined == controlMap){ |
| return ""; |
| } |
| |
| return $().XML_Operations().getXMLDocToString($().XML_Operations().createXML(controlMap)); |
| } |
| |
| //Contents of ajax_calls.js |
| |
| /* This function sends xmldata as a string to thr server by |
| * using ajax post call. |
| * parameters are XML Name and xml Data as as string. |
| * on success it returns the respoce XML which is call posted |
| */ |
| |
| |
| function PostXml(objPath, objMethod,controlMap) { |
| |
| var bShowWaitBox = true; |
| |
| if(null == controlMap || undefined == controlMap) { |
| controlMap = new Map(); |
| bShowWaitBox = false; //don't show waitting box if get data |
| } |
| else if (objPath == "ota" ||objMethod == "router_call_reboot") |
| { |
| bShowWaitBox = false; |
| } |
| |
| controlMap.push_front("RGW/param/obj_method",objMethod); |
| controlMap.push_front("RGW/param/obj_path",objPath); |
| controlMap.push_front("RGW/param/session","000"); |
| controlMap.push_front("RGW/param/method","call"); |
| |
| var xmlData = CreateXmlDocStr(controlMap); |
| |
| var xmlDoc; |
| |
| if(bShowWaitBox) { |
| ShowDlg("PleaseWait", 120, 100); |
| } |
| |
| resetInterval(); |
| var url = window.location.protocol + "//" + window.location.host + "/xml_action.cgi?method=set"; |
| |
| $.ajax( { |
| type: "POST", |
| 'beforeSend': function(xhr) { |
| xhr.setRequestHeader("Authorization",getAuthHeader("POST")) |
| }, |
| url: url, |
| processData: false, |
| data: xmlData, |
| async: false, |
| dataType: "xml", |
| timeout: 360000, |
| success:function(data, textStatus) { |
| var err = $(data).find("error_cause").text(); |
| var errmsg; |
| if("2" == err) { |
| errmsg = " Param error of XML"; |
| alert(errmsg); |
| }else if("4" == err) { |
| errmsg = " MethodName:" + controlMap.get("RGW/param/obj_method"); |
| alert(errmsg); |
| }else if(5 == err){ |
| //var message = objMethod+":get error_cause with method"; |
| //alert(message); |
| clearAuthheader(); |
| } |
| |
| }, |
| complete:function(XMLHttpRequest, textStatus) { |
| if(200 != XMLHttpRequest.status) { |
| if ("" != XMLHttpRequest.status) |
| alert(XMLHttpRequest.statusText); |
| } else { |
| //callbackFun(XMLHttpRequest.responseXML); |
| xmlDoc = XMLHttpRequest.responseXML; |
| } |
| |
| }, |
| error: function(XMLHttpRequest, textStatus, errorThrown) { |
| |
| } |
| }); |
| |
| if(bShowWaitBox) { |
| CloseDlg(); |
| } |
| |
| |
| |
| return xmlDoc; |
| } |
| |
| |
| /* This method sets localization. It loads the Prpoerties file. |
| * parameter are locale which is name of properties file |
| * i.e. Message_en.properties is englist dict then parameter is en |
| */ |
| function setLocalization(locale) { |
| |
| if(locale != "en") |
| locale = "cn"; |
| |
| try { |
| jQuery.i18n.properties( { |
| name:'Messages', |
| path:'//192.168.1.1/properties/', |
| mode:'map', |
| language:locale, |
| callback: function() { |
| } |
| }); |
| } catch(err) { |
| var fileref=document.createElement('script'); |
| fileref.setAttribute("type","text/javascript"); |
| fileref.setAttribute("src", '//192.168.1.1/js/jquery/jquery.i18n.properties-1.0.4.js'); |
| document.getElementsByTagName("head")[0].appendChild(fileref); |
| setLocalization(locale); |
| } |
| } |
| /* |
| * API used for url authentication digest checking.. it send url to server and |
| * give responce to caller |
| */ |
| function authentication(url) { |
| |
| var content = $.ajax( { |
| url: url, |
| dataType: "text/html", |
| async:false, |
| cache:false, |
| beforeSend: function(xhr) { |
| xhr.setRequestHeader("Authorization",getAuthHeader("GET")); |
| xhr.setRequestHeader("Expires", "-1"); |
| xhr.setRequestHeader("Cache-Control","no-store, no-cache, must-revalidate"); |
| xhr.setRequestHeader("Pragma", "no-cache"); |
| } |
| }).responseText; |
| return content; |
| } |
| function getAuthType(url) { |
| var content = $.ajax( { |
| url: url, |
| type: "GET", |
| dataType: "text/html", |
| async:false, |
| cache:false, |
| beforeSend: function(xhr) { |
| xhr.setRequestHeader("Expires", "-1"); |
| xhr.setRequestHeader("Cache-Control","no-store, no-cache, must-revalidate"); |
| xhr.setRequestHeader("Pragma", "no-cache"); |
| } |
| }).getResponseHeader('WWW-Authenticate'); |
| return content; |
| } |
| |
| |
| /* This function returns HTML contect as a text to caller |
| * Parameter is htmlpath path where the HTML file is Located |
| * Returns RespoceText |
| */ |
| function CallHtmlFile(htmlName) { |
| // prevent loading html file from cache to avoid "304 not modified error." |
| htmlName = htmlName + "?t=" + (new Date()).getTime().toString(); |
| |
| resetInterval(); |
| var content; |
| if(username == "admin") { |
| content = $.ajax( { |
| type: "GET", |
| url: htmlName, |
| dataType: "html", |
| timeout: 30000, |
| async:false |
| }).responseText; |
| } else { |
| content = $.ajax( { |
| type: "GET", |
| 'beforeSend': function(xhr) { |
| xhr.setRequestHeader("Authorization",getAuthHeader("GET")) |
| }, |
| error: function(XMLHttpRequest, textStatus, errorThrown) { |
| }, |
| url: htmlName, |
| dataType: "html", |
| timeout: 30000, |
| async:false |
| }).responseText; |
| } |
| return content; |
| } |
| |
| |
| function LoadWebPage(htmlFile) { |
| $("#Content").html(CallHtmlFile(htmlFile)); |
| LocalAllElement(); |
| } |
| |
| |
| |
| function WebDav_PropfindSyncXML(xmlName, xmlData) { |
| var host = window.location.protocol + "//" + window.location.host; |
| var xmlNametemp=xmlName; |
| var url = host + "/webdav"+xmlNametemp; |
| var content; |
| //resetInterval(); |
| content=$.ajax( { |
| type: "PROPFIND", |
| 'beforeSend': function(xhr) { |
| //xhr.setRequestHeader("Authorization",webdav_getAuthHeader("PROPFIND")); |
| xhr.setRequestHeader("Depth","1"); |
| }, |
| url: url, |
| dataType: "xml", |
| contentType: "text/xml;charset=UTF-8", |
| //timeout: 60000, |
| data: xmlData, |
| async: false, |
| success:function(data, textStatus) { |
| //WebDav_Upload_Ondoing(); |
| }, |
| complete: function(XMLHttpRequest, textStatus) { |
| //WebDav_ReUpload(); |
| }, |
| error: function(XMLHttpRequest, textStatus, errorThrown) { |
| //WebDav_Upload_Ondoing(); |
| //hm(); |
| //window.opener=null; |
| //window.open('','_self'); |
| //window.close(); |
| //WebDav_Login(); |
| } |
| }).responseText; |
| |
| //var login_text = $(content).find("login_status").text(); |
| return content; |
| |
| } |
| |
| |
| |
| function WebDav_MkdirSyncXML(xmlName) { |
| var host = window.location.protocol + "//" + window.location.host; |
| var xmlNametemp=xmlName; |
| var url = host + "/webdav" + xmlNametemp; |
| var content; |
| //resetInterval(); |
| content=$.ajax( { |
| type: "MKCOL", |
| 'beforeSend': function(xhr) { |
| //xhr.setRequestHeader("Authorization",webdav_getAuthHeader("MKCOL")); |
| }, |
| url: url, |
| //dataType: "xml", |
| //contentType: ContentType, |
| //timeout: 60000, |
| data: null, |
| async: false |
| }).responseXML; |
| //var login_text = $(content).find("login_status").text(); |
| return content; |
| |
| } |
| |
| |
| function WebDav_DeleteSyncXML(xmlName) { |
| var host = window.location.protocol + "//" + window.location.host; |
| //var xmlNametemp=encodeURIComponent(xmlName); |
| var xmlNametemp=xmlName; |
| var url = host + "/webdav" + xmlNametemp; |
| var content; |
| //resetInterval(); |
| content=$.ajax( { |
| type: "DELETE", |
| 'beforeSend': function(xhr) { |
| //xhr.setRequestHeader("Authorization",webdav_getAuthHeader("DELETE")); |
| }, |
| url: url, |
| //dataType: "xml", |
| //contentType: ContentType, |
| //timeout: 60000, |
| data: null, |
| async: false |
| }).responseXML; |
| //var login_text = $(content).find("login_status").text(); |
| return content; |
| |
| } |
| |
| function WebDav_PutSyncXML_IE11(xmlName,FileType,FileDataFrom,FileDataTo,FileDataTotal,FileData) { |
| var host = window.location.protocol + "//" + window.location.host ; |
| var xmlNametemp=xmlName; |
| var url = host + "/webdav" + xmlNametemp; |
| var content; |
| content=$.ajax( { |
| type: "PUT", |
| processData: false, |
| contentType: false, |
| 'beforeSend': function(xhr) { |
| //xhr.setRequestHeader("Authorization",webdav_getAuthHeader("PUT")); |
| xhr.setRequestHeader("Content-Type", FileType); |
| if(FileDataFrom!=0) { |
| xhr.setRequestHeader("Content-Range", "bytes "+FileDataFrom+"-"+FileDataTo+"/"+FileDataTotal); |
| } |
| }, |
| |
| url: url, |
| //dataType: "xml", |
| //timeout: 60000, |
| data: FileData, |
| async: true, |
| success:function(data, textStatus) { |
| WebDav_Upload_Ondoing(); |
| }, |
| complete: function(XMLHttpRequest, textStatus) { |
| //WebDav_ReUpload(); |
| }, |
| error: function(XMLHttpRequest, textStatus, errorThrown) { |
| //WebDav_Upload_Ondoing(); |
| } |
| }).responseXML; |
| return content; |
| |
| } |
| |
| function WebDav_PutSyncXML(xmlName,FileType,FileDataFrom,FileDataTo,FileDataTotal,FileData) { |
| var host = window.location.protocol + "//" + window.location.host ; |
| var xmlNametemp=xmlName; |
| var url = host + "/webdav" + xmlNametemp; |
| var content; |
| content=$.ajax( { |
| type: "PUT", |
| processData: false, |
| contentType: false, |
| xhr: function() { |
| var xhr = $.ajaxSettings.xhr(); |
| if (!xhr.sendAsBinary) { |
| xhr.legacySend = xhr.send; |
| xhr.sendAsBinary = function(string) { |
| var bytes = Array.prototype.map.call(string, function(c) { |
| return c.charCodeAt(0) & 0xff; |
| }); |
| this.legacySend(new Uint8Array(bytes).buffer); |
| }; |
| } |
| xhr.send = xhr.sendAsBinary; |
| return xhr; |
| }, |
| 'beforeSend': function(xhr) { |
| //xhr.setRequestHeader("Authorization",webdav_getAuthHeader("PUT")); |
| xhr.setRequestHeader("Content-Type", FileType); |
| if(FileDataFrom!=0) { |
| xhr.setRequestHeader("Content-Range", "bytes "+FileDataFrom+"-"+FileDataTo+"/"+FileDataTotal); |
| } |
| }, |
| |
| url: url, |
| //dataType: "xml", |
| //timeout: 60000, |
| data: FileData, |
| async: true, |
| success:function(data, textStatus) { |
| WebDav_Upload_Ondoing(); |
| }, |
| complete: function(XMLHttpRequest, textStatus) { |
| //WebDav_ReUpload(); |
| }, |
| error: function(XMLHttpRequest, textStatus, errorThrown) { |
| //WebDav_Upload_Ondoing(); |
| } |
| }).responseXML; |
| return content; |
| |
| } |
| |
| |
| function WebDav_GetSyncXML(xmlName,ContentType) { |
| sm("PleaseWait", 150, 100); |
| $("#lPleaseWait").text(jQuery.i18n.prop("h1PleaseWait")); |
| |
| var host = window.location.protocol + "//" + window.location.host; |
| //var xmlNametemp=encodeURIComponent(xmlName); |
| var xmlNametemp=xmlName; |
| var url = host + "/webdav" + xmlNametemp; |
| var content; |
| //resetInterval(); |
| content=$.ajax( { |
| type: "Get", |
| 'beforeSend': function(xhr) { |
| //xhr.setRequestHeader("Authorization",webdav_getAuthHeader("GET")); |
| xhr.setRequestHeader("Content-Type", ContentType) |
| }, |
| url: url, |
| //dataType: "xml", |
| //contentType: ContentType, |
| //timeout: 60000, |
| //data: xmlData, |
| async: true, |
| success:function(data, textStatus) { |
| hm(); |
| }, |
| complete: function(XMLHttpRequest, textStatus) { |
| hm(); |
| }, |
| error: function(XMLHttpRequest, textStatus, errorThrown) { |
| hm(); |
| } |
| }).responseXML; |
| //var login_text = $(content).find("login_status").text(); |
| |
| return content; |
| |
| } |
| |
| |
| function WebDav_PostXml(objPath, objMethod,controlMap,timeOut) { |
| |
| if(null == controlMap || undefined == controlMap) { |
| controlMap = new Map(); |
| } |
| |
| controlMap.push_front("RGW/param/obj_method",objMethod); |
| controlMap.push_front("RGW/param/obj_path",objPath); |
| controlMap.push_front("RGW/param/session","000"); |
| controlMap.push_front("RGW/param/method","call"); |
| |
| var xmlData = CreateXmlDocStr(controlMap); |
| |
| var xmlDoc; |
| |
| if(undefined == timeOut) { |
| timeOut = 360000; |
| } |
| |
| resetInterval(); |
| var url = window.location.protocol + "//" + window.location.host + "/xml_action.cgi?method=set"; |
| |
| $.ajax( { |
| type: "POST", |
| 'beforeSend': function(xhr) { |
| xhr.setRequestHeader("Authorization",getAuthHeader("POST")) |
| }, |
| url: url, |
| processData: false, |
| data: xmlData, |
| async: false, |
| dataType: "xml", |
| timeout: timeOut, |
| success:function(data, textStatus) { |
| showAlert("lsharesettingresultsuc"); |
| var debugInfo = $(data).find("error_cause").text(); |
| if("" != debugInfo) { |
| debugInfo = debugInfo + " MethodName:" + controlMap.get("RGW/param/obj_method"); |
| alert(debugInfo); |
| } |
| }, |
| complete:function(XMLHttpRequest, textStatus) { |
| if(200 != XMLHttpRequest.status) { |
| alert(XMLHttpRequest.statusText); |
| } else { |
| //callbackFun(XMLHttpRequest.responseXML); |
| xmlDoc = XMLHttpRequest.responseXML; |
| } |
| |
| }, |
| error: function(XMLHttpRequest, textStatus, errorThrown) { |
| //alert("Ajax Error:" + textStatus); |
| hm(); |
| showAlert("lsharesettingresultsuc"); |
| } |
| }); |
| |
| return xmlDoc; |
| } |
| |
| |
| function WebDav_PostSyncXML(xmlName, xmlData) { |
| //var host = window.location.protocol + "//" + window.location.host + "/"; |
| // var url = host + xmlName; |
| var url = ""; |
| var host = window.location.protocol + "//" + window.location.host + "/"; |
| url = host+'xml_action.cgi?method=set&module=duster&file='+xmlName; |
| content=$.ajax( { |
| type: "POST", |
| 'beforeSend': function(xhr) { |
| xhr.setRequestHeader("Authorization",getAuthHeader("POST")); |
| }, |
| url: url, |
| processData: false, |
| dataType: "xml", |
| contentType: "text/xml;charset=UTF-8", |
| //timeout: 60000, |
| data: xmlData, |
| async: false, |
| success:function(data,textStatus) { |
| showAlert("lsharesettingresultsuc"); |
| }, |
| error: function(XMLHttpRequest, textStatus, errorThrown) { |
| if(XMLHttpRequest.status==200) { |
| showAlert("lsharesettingresultsuc"); |
| } else { |
| showAlert("lsharesettingresultfal"); |
| } |
| } |
| }); |
| return true; |
| |
| } |
| |
| |
| function WebDav_Shared_PropfindSyncXML(xmlName, xmlData) { |
| var host = window.location.protocol + "//" + window.location.host; |
| var xmlNametemp=xmlName; |
| var url = host + "/shared"+xmlNametemp; |
| var content; |
| //resetInterval(); |
| content=$.ajax( { |
| type: "PROPFIND", |
| 'beforeSend': function(xhr) { |
| //xhr.setRequestHeader("Authorization",webdav_getAuthHeader("PROPFIND")); |
| xhr.setRequestHeader("Depth","1"); |
| }, |
| url: url, |
| dataType: "xml", |
| contentType: "text/xml;charset=UTF-8", |
| //timeout: 60000, |
| data: xmlData, |
| async: false, |
| success:function(data, textStatus) { |
| //WebDav_Upload_Ondoing(); |
| }, |
| complete: function(XMLHttpRequest, textStatus) { |
| //WebDav_ReUpload(); |
| }, |
| error: function(XMLHttpRequest, textStatus, errorThrown) { |
| //WebDav_Upload_Ondoing(); |
| //hm(); |
| //window.opener=null; |
| //window.open('','_self'); |
| //window.close(); |
| //WebDav_Login(); |
| } |
| }).responseText; |
| |
| //var login_text = $(content).find("login_status").text(); |
| return content; |
| |
| } |
| |
| |
| |
| function WebDav_Shared_GetSyncXML(xmlName,ContentType) { |
| sm("PleaseWait", 150, 100); |
| $("#lPleaseWait").text(jQuery.i18n.prop("h1PleaseWait")); |
| |
| var host = window.location.protocol + "//" + window.location.host; |
| //var xmlNametemp=encodeURIComponent(xmlName); |
| var xmlNametemp=xmlName; |
| var url = host + "/shared" + xmlNametemp; |
| var content; |
| //resetInterval(); |
| content=$.ajax( { |
| type: "Get", |
| 'beforeSend': function(xhr) { |
| xhr.setRequestHeader("Content-Type", ContentType) |
| }, |
| url: url, |
| //dataType: "xml", |
| //contentType: ContentType, |
| //timeout: 60000, |
| //data: xmlData, |
| async: true, |
| success:function(data, textStatus) { |
| hm(); |
| }, |
| complete: function(XMLHttpRequest, textStatus) { |
| hm(); |
| }, |
| error: function(XMLHttpRequest, textStatus, errorThrown) { |
| hm(); |
| } |
| }).responseXML; |
| //var login_text = $(content).find("login_status").text(); |
| return content; |
| |
| } |
| |
| |
| |
| function WebDav_Shared_DeleteSyncXML(xmlName) { |
| var host = window.location.protocol + "//" + window.location.host; |
| //var xmlNametemp=encodeURIComponent(xmlName); |
| var xmlNametemp=xmlName; |
| var url = host + "/shared" + xmlNametemp; |
| var content; |
| //resetInterval(); |
| content=$.ajax( { |
| type: "DELETE", |
| 'beforeSend': function(xhr) { |
| }, |
| url: url, |
| //dataType: "xml", |
| //contentType: ContentType, |
| //timeout: 60000, |
| data: null, |
| async: false |
| }).responseXML; |
| //var login_text = $(content).find("login_status").text(); |
| return content; |
| |
| } |
| |
| |
| |
| function WebDav_Shared_MkdirSyncXML(xmlName) { |
| var host = window.location.protocol + "//" + window.location.host; |
| var xmlNametemp=xmlName; |
| var url = host + "/shared" + xmlNametemp; |
| var content; |
| //resetInterval(); |
| content=$.ajax( { |
| type: "MKCOL", |
| 'beforeSend': function(xhr) { |
| //xhr.setRequestHeader("Authorization",getAuthHeader("MKCOL")); |
| }, |
| url: url, |
| //dataType: "xml", |
| //contentType: ContentType, |
| //timeout: 60000, |
| data: null, |
| async: false |
| }).responseXML; |
| //var login_text = $(content).find("login_status").text(); |
| return content; |
| |
| } |
| |
| function WebDav_Shared_PutSyncXML_IE11(xmlName,FileType,FileDataFrom,FileDataTo,FileDataTotal,FileData) { |
| var host = window.location.protocol + "//" + window.location.host ; |
| var xmlNametemp=xmlName; |
| var url = host + "/shared" + xmlNametemp; |
| var content; |
| content=$.ajax( { |
| type: "PUT", |
| processData: false, |
| contentType: false, |
| 'beforeSend': function(xhr) { |
| //xhr.setRequestHeader("Authorization",getAuthHeader("PUT")); |
| xhr.setRequestHeader("Content-Type", FileType); |
| if(FileDataFrom!=0) { |
| xhr.setRequestHeader("Content-Range", "bytes "+FileDataFrom+"-"+FileDataTo+"/"+FileDataTotal); |
| } |
| }, |
| |
| url: url, |
| //dataType: "xml", |
| //timeout: 60000, |
| data: FileData, |
| async: true, |
| success:function(data, textStatus) { |
| WebDav_Shared_Upload_Ondoing(); |
| }, |
| complete: function(XMLHttpRequest, textStatus) { |
| //WebDav_Shared_Upload_Ondoing(); |
| }, |
| error: function(XMLHttpRequest, textStatus, errorThrown) { |
| //WebDav_Shared_Upload_Ondoing(); |
| } |
| }).responseXML; |
| return content; |
| |
| } |
| |
| |
| function WebDav_Shared_PutSyncXML(xmlName,FileType,FileDataFrom,FileDataTo,FileDataTotal,FileData) { |
| var host = window.location.protocol + "//" + window.location.host ; |
| var xmlNametemp=xmlName; |
| var url = host + "/shared" + xmlNametemp; |
| var content; |
| content=$.ajax( { |
| type: "PUT", |
| processData: false, |
| contentType: false, |
| xhr: function() { |
| var xhr = $.ajaxSettings.xhr(); |
| if (!xhr.sendAsBinary) { |
| xhr.legacySend = xhr.send; |
| xhr.sendAsBinary = function(string) { |
| var bytes = Array.prototype.map.call(string, function(c) { |
| return c.charCodeAt(0) & 0xff; |
| }); |
| this.legacySend(new Uint8Array(bytes).buffer); |
| }; |
| } |
| xhr.send = xhr.sendAsBinary; |
| return xhr; |
| }, |
| 'beforeSend': function(xhr) { |
| //xhr.setRequestHeader("Authorization",getAuthHeader("PUT")); |
| xhr.setRequestHeader("Content-Type", FileType); |
| if(FileDataFrom!=0) { |
| xhr.setRequestHeader("Content-Range", "bytes "+FileDataFrom+"-"+FileDataTo+"/"+FileDataTotal); |
| } |
| }, |
| |
| url: url, |
| //dataType: "xml", |
| //timeout: 60000, |
| data: FileData, |
| async: true, |
| success:function(data, textStatus) { |
| WebDav_Shared_Upload_Ondoing(); |
| }, |
| complete: function(XMLHttpRequest, textStatus) { |
| //WebDav_Shared_Upload_Ondoing(); |
| }, |
| error: function(XMLHttpRequest, textStatus, errorThrown) { |
| //WebDav_Shared_Upload_Ondoing(); |
| } |
| }).responseXML; |
| return content; |
| |
| } |
| |
| |
| function GetXML(strUrl) { |
| return $.ajax( { |
| type: "GET", |
| 'beforeSend': function(xhr) { |
| xhr.setRequestHeader("Authorization", getAuthHeader("GET")) |
| }, |
| url: strUrl, |
| dataType: "xml", |
| timeout: 60000, |
| async: false |
| }).responseXML; |
| } |
| |
| function firmwareUpload_IE11(FileType,FileDataFrom,FileDataTo,FileDataTotal,FileData) { |
| var host = window.location.protocol + "//" + window.location.host ; |
| var url = host + getHeader("GET","upgrade"); |
| var content; |
| content=$.ajax( { |
| type: "POST", |
| processData: false, |
| contentType: "application/octet-stream", |
| 'beforeSend': function(xhr) { |
| if (0 == firmwareUploadOngoing) { |
| xhr.setRequestHeader("Content-Type", firmwareTotalSize); |
| } |
| // xhr.setRequestHeader("Content-Type", FileType); |
| xhr.setRequestHeader("Authorization",getAuthHeader("POST")); |
| if(FileDataFrom !=0) { |
| xhr.setRequestHeader("Content-Range", "bytes "+FileDataFrom+"-"+FileDataTo+"/"+FileDataTotal); |
| } |
| }, |
| |
| url: url, |
| data: FileData, |
| async: true, |
| success:function(data, textStatus) { |
| upgradeFirmwareOngoing(); |
| }, |
| complete: function(XMLHttpRequest, textStatus) { |
| }, |
| error: function(XMLHttpRequest, textStatus, errorThrown) { |
| upgradeFirmwareError(); |
| } |
| }).responseXML; |
| return content; |
| |
| } |
| |
| function firmwareUpload(FileType,FileDataFrom,FileDataTo,FileDataTotal,FileData) { |
| var host = window.location.protocol + "//" + window.location.host ; |
| var url = host + getHeader("GET","upgrade"); |
| var content; |
| content=$.ajax( { |
| type: "POST", |
| processData: false, |
| contentType: "application/octet-stream", |
| xhr: function() { |
| var xhr = $.ajaxSettings.xhr(); |
| if (!xhr.sendAsBinary) { |
| xhr.legacySend = xhr.send; |
| xhr.sendAsBinary = function(string) { |
| var bytes = Array.prototype.map.call(string, function(c) { |
| return c.charCodeAt(0) & 0xff; |
| }); |
| this.legacySend(new Uint8Array(bytes).buffer); |
| }; |
| } |
| xhr.send = xhr.sendAsBinary; |
| return xhr; |
| }, |
| 'beforeSend': function(xhr) { |
| if (0 == firmwareUploadOngoing) { |
| xhr.setRequestHeader("Content-Type", firmwareTotalSize); |
| } |
| xhr.setRequestHeader("Authorization",getAuthHeader("POST")); |
| |
| //if(FileDataFrom!=0) { |
| //xhr.setRequestHeader("Content-Range", "bytes "+FileDataFrom+"-"+FileDataTo+"/"+FileDataTotal); |
| //} |
| }, |
| |
| url: url, |
| data: FileData, |
| async: false, |
| success:function(data, textStatus) { |
| var err = $(data).find("upload_status").text(); |
| upgradeFirmwareOngoing(); |
| }, |
| complete: function(XMLHttpRequest, textStatus) { |
| }, |
| error: function(XMLHttpRequest, textStatus, errorThrown) { |
| upgradeFirmwareError(); |
| } |
| }).responseXML; |
| return content; |
| |
| } |
| |
| //Contents of layout_manager.js |
| |
| var g_menues = new Object(); |
| var g_objContent = null; |
| var g_navtabNum =0; |
| var g_objXML = $().XML_Operations(); |
| var _dashboardInterval = 30000; |
| var _connectedDeviceInterval = 60000; |
| var _trafficstatisticsInterval = 60000; |
| var _networkActivityInterval = 60000; |
| var _storageSettingsInterval = 30000; |
| var _WiFiInterval = 25000; |
| |
| var _dashboardIntervalID; |
| var _connectedDeviceIntervalID; |
| var _trafficstatisticsIntervalID; |
| var _networkActivityIntervalID; |
| var _storageSettingsIntervalID; |
| var _WiFiIntervalID; |
| /* This function get the XML from the server via ajax. |
| * Get is Method and success fucntion is callback funciton when the request success |
| */ |
| document.onkeydown = function (e) { |
| if(null == g_objContent) |
| return true; |
| var ev = window.event || e; |
| var code = ev.keyCode || ev.which; |
| if (code == 116) { |
| ev.keyCode ? ev.keyCode = 0 : ev.which = 0; |
| cancelBubble = true; |
| g_objContent.onLoad(true); |
| return false; |
| } |
| } |
| |
| |
| |
| function callXML(xml,sFucntion) { |
| |
| $.ajax({ |
| type: "GET", |
| url: xml, |
| dataType: "xml", |
| async: false, |
| success: sFucntion |
| |
| }); |
| } |
| |
| /* This is important function which parses the UIxml file |
| * Creates the Menu and submenu depending upon XML items |
| * |
| */ |
| function parseXml(xml) { |
| var menuIndex = 0; |
| g_menues = xml; |
| var thirdlevelmeunstr ; |
| var tabName; |
| var meun; |
| var linkHref = "#"; |
| $(xml).find("Tab").each(function() { |
| |
| tabName=jQuery.i18n.prop($(this).attr("Name").toString()); |
| menuIndex++; |
| if (menuIndex == 1) { |
| linkHref = "/dashboard"; |
| } else if (menuIndex == 2) { |
| linkHref = "/internet/internet_connection"; |
| } else if (menuIndex == 3) { |
| linkHref = "/home_network/dhcp_settings"; |
| } else if (menuIndex == 4) { |
| linkHref = "/phonebook/all_contact"; |
| } else if (menuIndex == 5) { |
| linkHref = "/sms/device_inbox"; |
| } else if (menuIndex == 6) { |
| linkHref = "/wifi/info_set"; |
| } else if (menuIndex == 7) { |
| linkHref = "/router/user_manage"; |
| } |
| document.getElementById('menu').innerHTML +="<li><a href='" + linkHref + "' id="+menuIndex+">"+tabName+"</a></li>"; |
| }); |
| g_navtabNum = menuIndex; |
| } |
| /* |
| * Create the submeny from XML items |
| */ |
| function createMenu(index,bDisplayForm) { |
| removeMenuClass(); |
| document.getElementById(index.toString()).className = "on"; |
| var idx = 0; |
| var linkHref = "#"; |
| |
| $(g_menues).find("Tab").each(function() { |
| |
| if(idx==index-1) { |
| |
| var tabName=jQuery.i18n.prop($(this).attr("Name").toString()); |
| |
| if($(this).attr("type").toString()=='submenuabsent') { |
| |
| clearRefreshTimers(); |
| g_objContent = eval('$("#mainColumn").'+ $(this).attr("implFunction").toString() + '({})'); |
| g_objContent.onLoad(true); |
| |
| } else { |
| document.getElementById('mainColumn').innerHTML ="<div class='leftBar'><ul class='leftMenu' id='submenu'></ul></div><div id='Content' class='content'></div><br class='clear /><br class='clear />"; |
| var firstmenu; |
| var firstmenuisSubMenu = false; |
| var i=0; |
| $(this).find("Menu").each(function() { |
| if (idx == 1) { |
| if (i == 0) { |
| linkHref = "/internet/internet_connection"; |
| } else if (i == 1) { |
| linkHref = "/internet/manual_network"; |
| } else if (i == 2) { |
| linkHref = "/internet/pin_puk"; |
| } else if (i == 3) { |
| linkHref = "/internet/mep"; |
| } else if (i == 4) { |
| linkHref = "/internet/ims"; |
| } |
| } else if (idx == 2) { |
| if (i == 0) { |
| linkHref = "/home_network/dhcp_settings"; |
| } else if (i == 1) { |
| linkHref = "/home_network/network_activity"; |
| } else if (i == 2) { |
| linkHref = "/home_network/connected_device"; |
| } else if (i == 3) { |
| linkHref = "/home_network/traffic_settings"; |
| } else if (i == 4) { |
| linkHref = "/home_network/ussd"; |
| } else if (i == 5) { |
| linkHref = "/home_network/stk"; |
| } |
| } else if (idx == 3) { |
| if (i == 0) { |
| linkHref = "/phonebook/all_contact"; |
| } else if (i == 1) { |
| linkHref = "/phonebook/loaction_all"; |
| } else if (i == 2) { |
| linkHref = "/phonebook/sim_contact"; |
| } |
| } else if (idx == 4) { |
| if (i == 0) { |
| linkHref = "/sms/device_inbox"; |
| } else if (i == 1) { |
| linkHref = "/sms/sim_inbox"; |
| } else if (i == 2) { |
| linkHref = "/sms/sms_outbox"; |
| } else if (i == 3) { |
| linkHref = "/sms/sms_drafts"; |
| } else if (i == 4) { |
| linkHref = "/sms/sms_set"; |
| } |
| } else if (idx == 5) { |
| if (i == 0) { |
| linkHref = "/wifi/info_set"; |
| } else if (i == 1) { |
| linkHref = "/wifi/mac_filter"; |
| } else if (i == 2) { |
| linkHref = "/wifi/ip_filter"; |
| } |
| } else if (idx == 6) { |
| if (i == 0) { |
| linkHref = "/router/user_manage"; |
| } else if (i == 1) { |
| linkHref = "/router/account_manage"; |
| } else if (i == 2) { |
| linkHref = "/router/soft_update"; |
| } else if (i == 3) { |
| linkHref = "/router/conf_manage"; |
| } else if (i == 4) { |
| linkHref = "/router/time_setting"; |
| } else if (i == 5) { |
| linkHref = "/router/webdav"; |
| } else if (i == 6) { |
| linkHref = "/router/webdav_share_setting"; |
| } |
| } |
| var menustr = "\"" + $(this).attr("id").toString() + "\"" ; |
| if(i==0) { |
| firstmenu = $(this).attr("id").toString(); |
| if($(this).attr("type").toString()=='submenupresent') |
| firstmenuisSubMenu = true; |
| } |
| if($(this).attr("type").toString()=='submenupresent') { |
| document.getElementById('submenu').innerHTML += "<li id="+menustr+"><a href='" + linkHref + "' >"+ jQuery.i18n.prop($(this).attr("id").toString())+"</a></li>"; |
| |
| var html = "<li class='hide'><ul class='thirdmenu'>"; |
| $(this).find("ThirdlevelMenu").each(function() { |
| var thirdlevelmeunstr = "\"" + $(this).attr("id").toString() + "\"" ; |
| var strImplFunction = " name=\"" + $(this).attr("implFunction").toString() + "\"" ; |
| if (thirdlevelmeunstr == '"mAllConnect_Devices"') { |
| linkHref = "/home_network/connectdevice_traffic"; |
| } else if (thirdlevelmeunstr == '"mTrafficStatistical"') { |
| linkHref = "/home_network/traffic_statistic"; |
| } else if (thirdlevelmeunstr == '"mLoactionCommon"') { |
| linkHref = "/phonebook/loaction_common"; |
| } else if (thirdlevelmeunstr == '"mLoactionFriends"') { |
| linkHref = "/phonebook/loaction_friends"; |
| } else if (thirdlevelmeunstr == '"mLoactionFamliy"') { |
| linkHref = "/phonebook/loaction_famliy"; |
| } else if (thirdlevelmeunstr == '"mLoactionColleague"') { |
| linkHref = "/phonebook/loaction_colleague"; |
| } else if (thirdlevelmeunstr == '"mWifiPortMap"') { |
| linkHref = "/wifi/port_map"; |
| } else if (thirdlevelmeunstr == '"mWifiPortTrigger"') { |
| linkHref = "/wifi/port_trigger"; |
| } else if (thirdlevelmeunstr == '"mWifiDmzSet"') { |
| linkHref = "/wifi/dmz_set"; |
| } else if (thirdlevelmeunstr == '"mWifiDnfilter"') { |
| linkHref = "/wifi/dn_filter"; |
| } |
| html+= "<li style ='list-style:none' class='menu-three-level' id="+thirdlevelmeunstr+ strImplFunction +"><a href='" + linkHref + "' >"+ jQuery.i18n.prop($(this).attr("id").toString())+"</a></li>"; |
| }); |
| html+="</ul></li>"; |
| document.getElementById('submenu').innerHTML +=html; |
| |
| } else { |
| var strImplFunction = " name=\"" + $(this).attr("implFunction").toString() + "\"" ; |
| document.getElementById('submenu').innerHTML += "<li id=" + menustr+ strImplFunction + "><a href='" + linkHref + "' >"+ jQuery.i18n.prop($(this).attr("id").toString())+"</a></li>"; |
| } |
| |
| |
| i++; |
| |
| }); |
| if(undefined == bDisplayForm){ |
| if(!firstmenuisSubMenu) |
| displayForm(firstmenu); |
| else |
| displaySubForm(firstmenu); |
| |
| } |
| |
| } |
| } |
| idx++; |
| }); |
| } |
| //var helpPage = "help_en.html"; |
| function removeMenuClass() { |
| if(g_navtabNum>0) |
| for(var j=1; j<=g_navtabNum; j++) |
| document.getElementById(j.toString()).className = ""; |
| } |
| /* |
| * Function for passing the JavaScript |
| */ |
| function createMenuFromXML() { |
| callXML("//192.168.1.1/xml/ui_" + g_platformName + ".xml",parseXml); |
| /*adjust main menu layout according the menu number |
| add by llzhou 9/1/2013*/ |
| |
| $(".navigation ul li").width(($(".header").width()-8*2)/g_navtabNum-1); |
| |
| } |
| /* |
| * Check which item is selected and take appropriate action to execute the |
| * panel class, and call his onLoad function as well as set the XML Name |
| */ |
| |
| function displaySubForm(clickedItem) { |
| |
| |
| clearRefreshTimers(); |
| |
| $(".leftMenu .on").removeClass("on"); |
| |
| var menuSelector = "#" + clickedItem; |
| |
| $(menuSelector).siblings(".hide").css("display", "none").end() |
| .next(".hide").css("display", "list-item"); |
| |
| $(menuSelector).addClass("on"); |
| var threeMenuObj = $(menuSelector).next(".hide:first").children(".thirdmenu:first").children(".menu-three-level:first"); |
| threeMenuObj.addClass("on"); |
| g_objContent = eval('$("#Content").'+ threeMenuObj.attr("name") + '("'+ threeMenuObj.attr("id")+'")'); |
| g_objContent.onLoad(true); |
| } |
| |
| function displayForm(clickedItem) { |
| clearRefreshTimers(); |
| |
| var menuSelector = "#" + clickedItem; |
| if(!$(menuSelector).parents("ul").hasClass("thirdmenu")){ |
| $(".leftMenu .hide").css("display", "none"); |
| } |
| $(menuSelector).siblings().removeClass("on").end() |
| .addClass("on"); |
| |
| g_objContent = eval('$("#Content").'+ $(menuSelector).attr("name") + '("'+ $(menuSelector).attr("id")+'")'); |
| g_objContent.onLoad(true); |
| |
| if(g_objContent == null) |
| document.getElementById("Content").innerHTML = ""; |
| } |
| |
| |
| |
| function clearRefreshTimers() { |
| clearInterval(_dashboardIntervalID); |
| clearInterval(_connectedDeviceIntervalID); |
| clearInterval(_trafficstatisticsIntervalID); |
| clearInterval(_networkActivityIntervalID); |
| clearInterval(_storageSettingsIntervalID); |
| clearInterval(_WiFiIntervalID); |
| } |
| function dashboardOnClick(subMenuID) { |
| var selMenuIdx = 1; |
| $(g_menues).find("Tab").each(function() { |
| $(this).find("Menu").each(function() { |
| var menuId = $(this).attr("id").toString(); |
| if("submenupresent" == $(this).attr("type")){ |
| $(this).find("ThirdlevelMenu").each(function(){ |
| if(subMenuID == $(this).attr("id").toString()){ |
| createMenu(selMenuIdx,false); |
| var menuSelector = "#" + menuId; |
| var submenuSelector = "#" + subMenuID; |
| $(menuSelector).siblings().removeClass("on").end().addClass("on").next(".hide").css("display", "list-item"); |
| $(submenuSelector).addClass("on"); |
| displayForm(subMenuID); |
| return; |
| } |
| }); |
| } |
| else if (subMenuID == menuId) { |
| createMenu(selMenuIdx,false); |
| displayForm(subMenuID); |
| return; |
| } |
| }); |
| ++selMenuIdx; |
| }); |
| |
| } |
| |
| function setData() { |
| if(g_objContent!=null) |
| g_objContent.SaveData(); |
| } |
| |
| //Contents of validator.js |
| |
| function IsNumber(obj) { |
| if( typeof(obj) === 'string' ) |
| { |
| var r = /^-?\d+$/; |
| return r.test(obj); |
| } |
| if(typeof(obj) === "number") |
| { |
| if(obj.toString().indexOf(".") != -1) |
| return false; |
| else |
| return true; |
| } |
| return false; |
| } |
| |
| function textBoxMinLength(control,value) { |
| if(document.getElementById(control).value.length < value) |
| return false; |
| else |
| return true; |
| } |
| function IsChineseChar(value) { |
| if(/.*[\u0100-\uffff]+.*$/.test(value)) |
| { |
| return true; |
| } |
| else |
| { |
| return false; |
| } |
| } |
| |
| function textBoxMaxLength(control,value) { |
| if(document.getElementById(control).value.length > value) |
| return false; |
| else |
| return true; |
| } |
| |
| function textBoxLength(control,value) { |
| if(document.getElementById(control).value.length == value) |
| return true; |
| else |
| return false; |
| } |
| |
| function IsEmail(emailAddr) { |
| var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/; |
| if (pattern.test(emailAddr)) { |
| return true; |
| } |
| else { |
| return false; |
| } |
| } |
| |
| function IsPhoneNumber(phoneNumber) { |
| var pattern = /(^[0-9]{3,4}\-[0-9]{3,15}$)|(^\+?[0-9]{3,20}$)|(^\([0-9]{3,4}\)[0-9]{3,15}$)/; |
| if (pattern.test(phoneNumber)) { |
| return true; |
| } |
| else { |
| return false; |
| } |
| } |
| |
| |
| function isChineseChar(value) { |
| if(/.*[\u0100-\uffff]+.*$/.test(value)) |
| { |
| return true; |
| } |
| else |
| { |
| return false; |
| } |
| } |
| |
| function deviceNameValidation(str) { |
| if (isChineseChar(str)) { |
| return false; } |
| |
| if (str.toString().indexOf("#") != -1) |
| return false; |
| else if (str.toString().indexOf(":") != -1) |
| return false; |
| else if (str.toString().indexOf(" ") != -1) |
| return false; |
| else if (str.toString().indexOf("&") != -1) |
| return false; |
| else if (str.toString().indexOf(";") != -1) |
| return false; |
| else if (str.toString().indexOf("~") != -1) |
| return false; |
| else if (str.toString().indexOf("|") != -1) |
| return false; |
| else if (str.toString().indexOf("<") != -1) |
| return false; |
| else if (str.toString().indexOf(">") != -1) |
| return false; |
| else if (str.toString().indexOf("$") != -1) |
| return false; |
| else if (str.toString().indexOf("%") != -1) |
| return false; |
| else if (str.toString().indexOf("^") != -1) |
| return false; |
| else if (str.toString().indexOf("!") != -1) |
| return false; |
| else if (str.toString().indexOf("@") != -1) |
| return false; |
| else if (str.toString().indexOf(",") != -1) |
| return false; |
| else |
| return true;} |
| |
| function IsIPv6(ipv6Addr) { |
| return ipv6Addr.match(/:/g) != null |
| && ipv6Addr.match(/:/g).length <= 15 |
| && /::/.test(str) |
| ? /^([\da-f]{1,4}(:|::)){1,6}[\da-f]{1,4}$/i.test(str) |
| : /^([\da-f]{1,4}:){15}[\da-f]{1,4}$/i.test(str); |
| } |
| |
| function IsIPv4(ipv4Addr) { |
| var exp=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/; |
| return null == ipv4Addr.match(exp) ? false: true; |
| return true; |
| } |
| |
| function IsUrl(strUrl){ |
| var regUrl = /(http\:\/\/)?([\w.]+)(\/[\w- \.\/\?%&=]*)?/gi; |
| if (regUrl.test(strUrl)) { |
| return true; |
| } |
| else { |
| return false; |
| } |
| } |
| |
| function IsHexStr(str){ |
| pattern = /^[0-9a-fA-F]+$/; |
| if (pattern.test(str)) { |
| return true; |
| } |
| else { |
| return false; |
| } |
| } |
| |
| function IsASCIIStr(str){ |
| pattern = /^[\x00-\x7F]+$/; |
| if (pattern.test(str)) { |
| return true; |
| } |
| else { |
| return false; |
| } |
| } |
| |
| function IsEnglishLetter(str){ |
| pattern = /[a-zA-Z]+/; |
| if (pattern.test(str)) { |
| return true; |
| } |
| else { |
| return false; |
| } |
| } |
| |
| function IsMACAddr(mac) { |
| var regex = /^([0-9a-f]{2}([:-]|$)){6}$|([0-9a-f]{4}([.]|$)){3}$/i; |
| if (!regex.test(mac)) |
| return false; |
| else |
| return true; |
| } |
| |
| //time format: hh:mm:ss |
| function IsTime(time) { |
| var regex = /^([0-1]?\d{1}|2[0-3]):[0-5]?\d{1}:([0-5]?\d{1})$/; |
| if (!regex.test(time)) |
| return false; |
| else |
| return true; |
| } |
| |
| //time format: hh:mm |
| function IsTimeEx(time) { |
| //var regex = /^(([0-1]\d)|(2[0-4])):[0-5]\d$/; |
| var regex =/^([0-1]{1}\d|2[0-3]):([0-5]\d)$/; |
| if (!regex.test(time)) |
| return false; |
| else |
| return true; |
| } |
| |
| //date format: yyyy-mm-dd |
| function IsData(date) { |
| var regex = /^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/; |
| if (!regex.test(date)) |
| return false; |
| else |
| return true; |
| } |
| |
| //port format: xxxx:yyyy |
| function IsPort(port){ |
| var portArr = port.split(":"); |
| for(var idx = 0; idx < 2; ++idx){ |
| if("" == portArr[idx]) |
| return false; |
| |
| if(portArr[idx]>65535 || portArr[idx] < 0) |
| return false; |
| } |
| if(portArr[0] > portArr[1]) |
| return false; |
| |
| return true; |
| } |
| |
| function IsRuleName(ruleName){ |
| if("" == ruleName) return false; |
| if(!IsASCIIStr(ruleName)) return false; |
| |
| return true; |
| } |
| |
| function validate_pin(pin) { |
| var ret = true; |
| |
| if(pin.length < 4 || pin.length > 8) |
| ret = false; |
| |
| if(!IsNumber(pin)) |
| ret = false; |
| |
| return ret; |
| } |
| |
| function validate_puk(puk) { |
| var ret = true; |
| |
| if(puk.length < 4 || puk.length > 10) |
| ret = false; |
| |
| if (/\W/.test(puk)) |
| ret = false; |
| |
| return ret; |
| } |
| |
| //Contents of ip_address.js |
| |
| (function ($) { |
| $.fn.ip_address = function (oInit) { |
| var divID = oInit; |
| |
| this.setIP = function (ip) { |
| if(ip=='' || undefined == ip || "NaN" == ip){ |
| for(var i=0;i<4;i++) |
| document.getElementById(divID+"IPAddr"+i).value = ''; |
| }else { |
| var ary = ip.split("."); |
| for(i=0;i<4;i++) |
| document.getElementById(divID+"IPAddr"+i).value = ary[i]; |
| } |
| } |
| |
| this.getIP = function () { |
| var ip=""; |
| for(var i=0;i<3;i++) |
| ip+=document.getElementById(divID+"IPAddr"+i).value+"."; |
| ip+=document.getElementById(divID+"IPAddr3").value; |
| return ip; |
| } |
| this.validIPV4 = function () { |
| return IsIPv4(this.getIP()); |
| } |
| |
| this.validIPV6 = function () { |
| return IsIPv6(this.getIP()); |
| } |
| this.disableIP = function (var0,var1,var2,var3) { |
| |
| document.getElementById(divID+"IPAddr0").readOnly = var0; |
| document.getElementById(divID+"IPAddr1").readOnly = var1; |
| document.getElementById(divID+"IPAddr2").readOnly = var2; |
| document.getElementById(divID+"IPAddr3").readOnly = var3; |
| } |
| |
| this.getDivID = function () { |
| return divID; |
| } |
| this.clearHTML = function () { |
| this.innerHTML = ""; |
| } |
| this.formatIP = function (ip){ |
| var ary = ip.split("."); |
| document.getElementById(divID+"IPAddr0").value = ary[0]; |
| document.getElementById(divID+"IPAddr2").value = ary[1]; |
| this.formatIP2(); |
| } |
| |
| this.formatIP2 = function () { |
| document.getElementById(divID+"IPAddr2").value = document.getElementById("IPAddr3").value; |
| } |
| |
| return this.each(function () { |
| var id1=divID+"IPAddr0"; |
| var id2=divID+"IPAddr1"; |
| var id3=divID+"IPAddr2"; |
| var id4=divID+"IPAddr3"; |
| |
| var HTML ="<input type='text' id="+ id1+ " maxlength='3' class='sml' onkeyup='setFocusIP(\""+id1+"\")'> </input><strong>·</strong>"; |
| HTML+="<input type='text' id="+ id2 +" maxlength='3' class='sml' onkeyup='setFocusIP(\""+id2+"\")'> </input><strong>·</strong>"; |
| HTML+="<input type='text' id="+ id3 +" maxlength='3' class='sml' onkeyup='setFocusIP(\""+id3+"\")'> </input><strong>·</strong>"; |
| HTML+="<input type='text' id="+ id4 +" maxlength='3' class='sml'></input>"; |
| this.innerHTML += HTML; |
| }); |
| } |
| })(jQuery); |
| function setFocusIP(controlID){ |
| var str=document.getElementById(controlID).value; |
| var ipSeg = str.split(".", 3); |
| |
| if(str.length==3 ||ipSeg.length > 1) { |
| document.getElementById(controlID).value = ipSeg[0]; |
| if ("" == ipSeg[0]) |
| return; |
| |
| var c = controlID.toString().charAt(controlID.length-1); |
| c++; |
| controlID = controlID.substring(0, controlID.length-1); |
| controlID=controlID+c; |
| document.getElementById(controlID.toString()).focus(); |
| } |
| } |
| |
| //Contents of mac_address.js |
| |
| (function ($) { |
| $.fn.mac_address = function (oInit) { |
| var divID = oInit; |
| |
| this.setMacAddr = function (macAddr) { |
| if(macAddr=='' || undefined == macAddr || "NaN" == macAddr) { |
| for(var i=0; i<6; i++) |
| document.getElementById(divID+"MacAddr"+i).value = ''; |
| } else { |
| var ary = macAddr.split(":"); |
| for(i=0; i<6; i++) |
| document.getElementById(divID+"MacAddr"+i).value = ary[i]; |
| } |
| } |
| |
| this.getMacAddr = function () { |
| var macAddr=""; |
| for(var i=0; i<5; i++) |
| macAddr += document.getElementById(divID+"MacAddr"+i).value+":"; |
| macAddr += document.getElementById(divID+"MacAddr5").value; |
| return macAddr; |
| } |
| |
| |
| this.validMacAddr = function () { |
| return IsMACAddr(this.getMacAddr()); |
| } |
| |
| this.getDivID = function () { |
| return divID; |
| } |
| this.clearHTML = function () { |
| this.innerHTML = ""; |
| } |
| |
| |
| |
| |
| return this.each(function () { |
| var id1=divID+"MacAddr0"; |
| var id2=divID+"MacAddr1"; |
| var id3=divID+"MacAddr2"; |
| var id4=divID+"MacAddr3"; |
| var id5=divID+"MacAddr4"; |
| var id6=divID+"MacAddr5"; |
| |
| |
| var HTML = "<input type='text' id="+ id1+ " maxlength='2' class='sml' onkeyup='setFocusMac(\""+id1+"\")'> </input><strong>:</strong>" |
| + "<input type='text' id="+ id2 +" maxlength='2' class='sml' onkeyup='setFocusMac(\""+id2+"\")'> </input><strong>:</strong>" |
| + "<input type='text' id="+ id3 +" maxlength='2' class='sml' onkeyup='setFocusMac(\""+id3+"\")'> </input><strong>:</strong>" |
| + "<input type='text' id="+ id4 +" maxlength='2' class='sml' onkeyup='setFocusMac(\""+id4+"\")'> </input><strong>:</strong>" |
| + "<input type='text' id="+ id5 +" maxlength='2' class='sml' onkeyup='setFocusMac(\""+id5+"\")'> </input><strong>:</strong>" |
| + "<input type='text' id="+ id6 +" maxlength='2' class='sml'>"; |
| this.innerHTML += HTML; |
| }); |
| } |
| })(jQuery); |
| |
| |
| function setFocusMac(controlID) { |
| var str=document.getElementById(controlID).value; |
| if(str.length==2) { |
| var c = controlID.toString().charAt(controlID.length-1); |
| c++; |
| controlID = controlID.substring(0, controlID.length-1); |
| controlID=controlID+c; |
| document.getElementById(controlID.toString()).focus(); |
| } |
| } |