").append( jQuery.parseHTML( responseText ) ).find( selector ) :
+
+ // Otherwise use the full result
+ responseText );
+
+ }).complete( callback && function( jqXHR, status ) {
+ self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
+ });
+ }
+
+ return this;
+};
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ){
+ jQuery.fn[ type ] = function( fn ){
+ return this.on( type, fn );
+ };
+});
+
+jQuery.each( [ "get", "post" ], function( i, method ) {
+ jQuery[ method ] = function( url, data, callback, type ) {
+ // shift arguments if data argument was omitted
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = undefined;
+ }
+
+ return jQuery.ajax({
+ url: url,
+ type: method,
+ dataType: type,
+ data: data,
+ success: callback
+ });
+ };
+});
+
+jQuery.extend({
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+ etag: {},
+
+ ajaxSettings: {
+ url: ajaxLocation,
+ type: "GET",
+ isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
+ global: true,
+ processData: true,
+ async: true,
+ contentType: "application/x-www-form-urlencoded; charset=UTF-8",
+ /*
+ timeout: 0,
+ data: null,
+ dataType: null,
+ username: null,
+ password: null,
+ cache: null,
+ throws: false,
+ traditional: false,
+ headers: {},
+ */
+
+ accepts: {
+ "*": allTypes,
+ text: "text/plain",
+ html: "text/html",
+ xml: "application/xml, text/xml",
+ json: "application/json, text/javascript"
+ },
+
+ contents: {
+ xml: /xml/,
+ html: /html/,
+ json: /json/
+ },
+
+ responseFields: {
+ xml: "responseXML",
+ text: "responseText"
+ },
+
+ // Data converters
+ // Keys separate source (or catchall "*") and destination types with a single space
+ converters: {
+
+ // Convert anything to text
+ "* text": window.String,
+
+ // Text to html (true = no transformation)
+ "text html": true,
+
+ // Evaluate text as a json expression
+ "text json": jQuery.parseJSON,
+
+ // Parse text as xml
+ "text xml": jQuery.parseXML
+ },
+
+ // For options that shouldn't be deep extended:
+ // you can add your own custom options here if
+ // and when you create one that shouldn't be
+ // deep extended (see ajaxExtend)
+ flatOptions: {
+ url: true,
+ context: true
+ }
+ },
+
+ // Creates a full fledged settings object into target
+ // with both ajaxSettings and settings fields.
+ // If target is omitted, writes into ajaxSettings.
+ ajaxSetup: function( target, settings ) {
+ return settings ?
+
+ // Building a settings object
+ ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
+
+ // Extending ajaxSettings
+ ajaxExtend( jQuery.ajaxSettings, target );
+ },
+
+ ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
+ ajaxTransport: addToPrefiltersOrTransports( transports ),
+
+ // Main method
+ ajax: function( url, options ) {
+
+ // If url is an object, simulate pre-1.5 signature
+ if ( typeof url === "object" ) {
+ options = url;
+ url = undefined;
+ }
+
+ // Force options to be an object
+ options = options || {};
+
+ var // Cross-domain detection vars
+ parts,
+ // Loop variable
+ i,
+ // URL without anti-cache param
+ cacheURL,
+ // Response headers as string
+ responseHeadersString,
+ // timeout handle
+ timeoutTimer,
+
+ // To know if global events are to be dispatched
+ fireGlobals,
+
+ transport,
+ // Response headers
+ responseHeaders,
+ // Create the final options object
+ s = jQuery.ajaxSetup( {}, options ),
+ // Callbacks context
+ callbackContext = s.context || s,
+ // Context for global events is callbackContext if it is a DOM node or jQuery collection
+ globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
+ jQuery( callbackContext ) :
+ jQuery.event,
+ // Deferreds
+ deferred = jQuery.Deferred(),
+ completeDeferred = jQuery.Callbacks("once memory"),
+ // Status-dependent callbacks
+ statusCode = s.statusCode || {},
+ // Headers (they are sent all at once)
+ requestHeaders = {},
+ requestHeadersNames = {},
+ // The jqXHR state
+ state = 0,
+ // Default abort message
+ strAbort = "canceled",
+ // Fake xhr
+ jqXHR = {
+ readyState: 0,
+
+ // Builds headers hashtable if needed
+ getResponseHeader: function( key ) {
+ var match;
+ if ( state === 2 ) {
+ if ( !responseHeaders ) {
+ responseHeaders = {};
+ while ( (match = rheaders.exec( responseHeadersString )) ) {
+ responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
+ }
+ }
+ match = responseHeaders[ key.toLowerCase() ];
+ }
+ return match == null ? null : match;
+ },
+
+ // Raw string
+ getAllResponseHeaders: function() {
+ return state === 2 ? responseHeadersString : null;
+ },
+
+ // Caches the header
+ setRequestHeader: function( name, value ) {
+ var lname = name.toLowerCase();
+ if ( !state ) {
+ name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
+ requestHeaders[ name ] = value;
+ }
+ return this;
+ },
+
+ // Overrides response content-type header
+ overrideMimeType: function( type ) {
+ if ( !state ) {
+ s.mimeType = type;
+ }
+ return this;
+ },
+
+ // Status-dependent callbacks
+ statusCode: function( map ) {
+ var code;
+ if ( map ) {
+ if ( state < 2 ) {
+ for ( code in map ) {
+ // Lazy-add the new callback in a way that preserves old ones
+ statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
+ }
+ } else {
+ // Execute the appropriate callbacks
+ jqXHR.always( map[ jqXHR.status ] );
+ }
+ }
+ return this;
+ },
+
+ // Cancel the request
+ abort: function( statusText ) {
+ var finalText = statusText || strAbort;
+ if ( transport ) {
+ transport.abort( finalText );
+ }
+ done( 0, finalText );
+ return this;
+ }
+ };
+
+ // Attach deferreds
+ deferred.promise( jqXHR ).complete = completeDeferred.add;
+ jqXHR.success = jqXHR.done;
+ jqXHR.error = jqXHR.fail;
+
+ // Remove hash character (#7531: and string promotion)
+ // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
+ // Handle falsy url in the settings object (#10093: consistency with old signature)
+ // We also use the url parameter if available
+ s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
+
+ // Alias method option to type as per ticket #12004
+ s.type = options.method || options.type || s.method || s.type;
+
+ // Extract dataTypes list
+ s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( core_rnotwhite ) || [""];
+
+ // A cross-domain request is in order when we have a protocol:host:port mismatch
+ if ( s.crossDomain == null ) {
+ parts = rurl.exec( s.url.toLowerCase() );
+ s.crossDomain = !!( parts &&
+ ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
+ ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
+ ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
+ );
+ }
+
+ // Convert data if not already a string
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
+ s.data = jQuery.param( s.data, s.traditional );
+ }
+
+ // Apply prefilters
+ inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
+
+ // If request was aborted inside a prefilter, stop there
+ if ( state === 2 ) {
+ return jqXHR;
+ }
+
+ // We can fire global events as of now if asked to
+ fireGlobals = s.global;
+
+ // Watch for a new set of requests
+ if ( fireGlobals && jQuery.active++ === 0 ) {
+ jQuery.event.trigger("ajaxStart");
+ }
+
+ // Uppercase the type
+ s.type = s.type.toUpperCase();
+
+ // Determine if request has content
+ s.hasContent = !rnoContent.test( s.type );
+
+ // Save the URL in case we're toying with the If-Modified-Since
+ // and/or If-None-Match header later on
+ cacheURL = s.url;
+
+ // More options handling for requests with no content
+ if ( !s.hasContent ) {
+
+ // If data is available, append data to url
+ if ( s.data ) {
+ cacheURL = ( s.url += ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
+ // #9682: remove data so that it's not used in an eventual retry
+ delete s.data;
+ }
+
+ // Add anti-cache in url if needed
+ if ( s.cache === false ) {
+ s.url = rts.test( cacheURL ) ?
+
+ // If there is already a '_' parameter, set its value
+ cacheURL.replace( rts, "$1_=" + ajax_nonce++ ) :
+
+ // Otherwise add one to the end
+ cacheURL + ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ajax_nonce++;
+ }
+ }
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ if ( jQuery.lastModified[ cacheURL ] ) {
+ jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
+ }
+ if ( jQuery.etag[ cacheURL ] ) {
+ jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
+ }
+ }
+
+ // Set the correct header, if data is being sent
+ if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
+ jqXHR.setRequestHeader( "Content-Type", s.contentType );
+ }
+
+ // Set the Accepts header for the server, depending on the dataType
+ jqXHR.setRequestHeader(
+ "Accept",
+ s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
+ s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
+ s.accepts[ "*" ]
+ );
+
+ // Check for headers option
+ for ( i in s.headers ) {
+ jqXHR.setRequestHeader( i, s.headers[ i ] );
+ }
+
+ // Allow custom headers/mimetypes and early abort
+ if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
+ // Abort if not done already and return
+ return jqXHR.abort();
+ }
+
+ // aborting is no longer a cancellation
+ strAbort = "abort";
+
+ // Install callbacks on deferreds
+ for ( i in { success: 1, error: 1, complete: 1 } ) {
+ jqXHR[ i ]( s[ i ] );
+ }
+
+ // Get transport
+ transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
+
+ // If no transport, we auto-abort
+ if ( !transport ) {
+ done( -1, "No Transport" );
+ } else {
+ jqXHR.readyState = 1;
+
+ // Send global event
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
+ }
+ // Timeout
+ if ( s.async && s.timeout > 0 ) {
+ timeoutTimer = setTimeout(function() {
+ jqXHR.abort("timeout");
+ }, s.timeout );
+ }
+
+ try {
+ state = 1;
+ transport.send( requestHeaders, done );
+ } catch ( e ) {
+ // Propagate exception as error if not done
+ if ( state < 2 ) {
+ done( -1, e );
+ // Simply rethrow otherwise
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ // Callback for when everything is done
+ function done( status, nativeStatusText, responses, headers ) {
+ var isSuccess, success, error, response, modified,
+ statusText = nativeStatusText;
+
+ // Called once
+ if ( state === 2 ) {
+ return;
+ }
+
+ // State is "done" now
+ state = 2;
+
+ // Clear timeout if it exists
+ if ( timeoutTimer ) {
+ clearTimeout( timeoutTimer );
+ }
+
+ // Dereference transport for early garbage collection
+ // (no matter how long the jqXHR object will be used)
+ transport = undefined;
+
+ // Cache response headers
+ responseHeadersString = headers || "";
+
+ // Set readyState
+ jqXHR.readyState = status > 0 ? 4 : 0;
+
+ // Get response data
+ if ( responses ) {
+ response = ajaxHandleResponses( s, jqXHR, responses );
+ }
+
+ // If successful, handle type chaining
+ if ( status >= 200 && status < 300 || status === 304 ) {
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ modified = jqXHR.getResponseHeader("Last-Modified");
+ if ( modified ) {
+ jQuery.lastModified[ cacheURL ] = modified;
+ }
+ modified = jqXHR.getResponseHeader("etag");
+ if ( modified ) {
+ jQuery.etag[ cacheURL ] = modified;
+ }
+ }
+
+ // if no content
+ if ( status === 204 ) {
+ isSuccess = true;
+ statusText = "nocontent";
+
+ // if not modified
+ } else if ( status === 304 ) {
+ isSuccess = true;
+ statusText = "notmodified";
+
+ // If we have data, let's convert it
+ } else {
+ isSuccess = ajaxConvert( s, response );
+ statusText = isSuccess.state;
+ success = isSuccess.data;
+ error = isSuccess.error;
+ isSuccess = !error;
+ }
+ } else {
+ // We extract error from statusText
+ // then normalize statusText and status for non-aborts
+ error = statusText;
+ if ( status || !statusText ) {
+ statusText = "error";
+ if ( status < 0 ) {
+ status = 0;
+ }
+ }
+ }
+
+ // Set data for the fake xhr object
+ jqXHR.status = status;
+ jqXHR.statusText = ( nativeStatusText || statusText ) + "";
+
+ // Success/Error
+ if ( isSuccess ) {
+ deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
+ } else {
+ deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
+ }
+
+ // Status-dependent callbacks
+ jqXHR.statusCode( statusCode );
+ statusCode = undefined;
+
+ if ( fireGlobals ) {
+ globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
+ [ jqXHR, s, isSuccess ? success : error ] );
+ }
+
+ // Complete
+ completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
+
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
+ // Handle the global AJAX counter
+ if ( !( --jQuery.active ) ) {
+ jQuery.event.trigger("ajaxStop");
+ }
+ }
+ }
+
+ return jqXHR;
+ },
+
+ getScript: function( url, callback ) {
+ return jQuery.get( url, undefined, callback, "script" );
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get( url, data, callback, "json" );
+ }
+});
+
+/* Handles responses to an ajax request:
+ * - sets all responseXXX fields accordingly
+ * - finds the right dataType (mediates between content-type and expected dataType)
+ * - returns the corresponding response
+ */
+function ajaxHandleResponses( s, jqXHR, responses ) {
+ var firstDataType, ct, finalDataType, type,
+ contents = s.contents,
+ dataTypes = s.dataTypes,
+ responseFields = s.responseFields;
+
+ // Fill responseXXX fields
+ for ( type in responseFields ) {
+ if ( type in responses ) {
+ jqXHR[ responseFields[type] ] = responses[ type ];
+ }
+ }
+
+ // Remove auto dataType and get content-type in the process
+ while( dataTypes[ 0 ] === "*" ) {
+ dataTypes.shift();
+ if ( ct === undefined ) {
+ ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
+ }
+ }
+
+ // Check if we're dealing with a known content-type
+ if ( ct ) {
+ for ( type in contents ) {
+ if ( contents[ type ] && contents[ type ].test( ct ) ) {
+ dataTypes.unshift( type );
+ break;
+ }
+ }
+ }
+
+ // Check to see if we have a response for the expected dataType
+ if ( dataTypes[ 0 ] in responses ) {
+ finalDataType = dataTypes[ 0 ];
+ } else {
+ // Try convertible dataTypes
+ for ( type in responses ) {
+ if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
+ finalDataType = type;
+ break;
+ }
+ if ( !firstDataType ) {
+ firstDataType = type;
+ }
+ }
+ // Or just use first one
+ finalDataType = finalDataType || firstDataType;
+ }
+
+ // If we found a dataType
+ // We add the dataType to the list if needed
+ // and return the corresponding response
+ if ( finalDataType ) {
+ if ( finalDataType !== dataTypes[ 0 ] ) {
+ dataTypes.unshift( finalDataType );
+ }
+ return responses[ finalDataType ];
+ }
+}
+
+// Chain conversions given the request and the original response
+function ajaxConvert( s, response ) {
+ var conv2, current, conv, tmp,
+ converters = {},
+ i = 0,
+ // Work with a copy of dataTypes in case we need to modify it for conversion
+ dataTypes = s.dataTypes.slice(),
+ prev = dataTypes[ 0 ];
+
+ // Apply the dataFilter if provided
+ if ( s.dataFilter ) {
+ response = s.dataFilter( response, s.dataType );
+ }
+
+ // Create converters map with lowercased keys
+ if ( dataTypes[ 1 ] ) {
+ for ( conv in s.converters ) {
+ converters[ conv.toLowerCase() ] = s.converters[ conv ];
+ }
+ }
+
+ // Convert to each sequential dataType, tolerating list modification
+ for ( ; (current = dataTypes[++i]); ) {
+
+ // There's only work to do if current dataType is non-auto
+ if ( current !== "*" ) {
+
+ // Convert response if prev dataType is non-auto and differs from current
+ if ( prev !== "*" && prev !== current ) {
+
+ // Seek a direct converter
+ conv = converters[ prev + " " + current ] || converters[ "* " + current ];
+
+ // If none found, seek a pair
+ if ( !conv ) {
+ for ( conv2 in converters ) {
+
+ // If conv2 outputs current
+ tmp = conv2.split(" ");
+ if ( tmp[ 1 ] === current ) {
+
+ // If prev can be converted to accepted input
+ conv = converters[ prev + " " + tmp[ 0 ] ] ||
+ converters[ "* " + tmp[ 0 ] ];
+ if ( conv ) {
+ // Condense equivalence converters
+ if ( conv === true ) {
+ conv = converters[ conv2 ];
+
+ // Otherwise, insert the intermediate dataType
+ } else if ( converters[ conv2 ] !== true ) {
+ current = tmp[ 0 ];
+ dataTypes.splice( i--, 0, current );
+ }
+
+ break;
+ }
+ }
+ }
+ }
+
+ // Apply converter (if not an equivalence)
+ if ( conv !== true ) {
+
+ // Unless errors are allowed to bubble, catch and return them
+ if ( conv && s["throws"] ) {
+ response = conv( response );
+ } else {
+ try {
+ response = conv( response );
+ } catch ( e ) {
+ return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
+ }
+ }
+ }
+ }
+
+ // Update prev for next iteration
+ prev = current;
+ }
+ }
+
+ return { state: "success", data: response };
+}
+// Install script dataType
+jQuery.ajaxSetup({
+ accepts: {
+ script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
+ },
+ contents: {
+ script: /(?:java|ecma)script/
+ },
+ converters: {
+ "text script": function( text ) {
+ jQuery.globalEval( text );
+ return text;
+ }
+ }
+});
+
+// Handle cache's special case and global
+jQuery.ajaxPrefilter( "script", function( s ) {
+ if ( s.cache === undefined ) {
+ s.cache = false;
+ }
+ if ( s.crossDomain ) {
+ s.type = "GET";
+ s.global = false;
+ }
+});
+
+// Bind script tag hack transport
+jQuery.ajaxTransport( "script", function(s) {
+
+ // This transport only deals with cross domain requests
+ if ( s.crossDomain ) {
+
+ var script,
+ head = document.head || jQuery("head")[0] || document.documentElement;
+
+ return {
+
+ send: function( _, callback ) {
+
+ script = document.createElement("script");
+
+ script.async = true;
+
+ if ( s.scriptCharset ) {
+ script.charset = s.scriptCharset;
+ }
+
+ script.src = s.url;
+
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function( _, isAbort ) {
+
+ if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
+
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
+
+ // Remove the script
+ if ( script.parentNode ) {
+ script.parentNode.removeChild( script );
+ }
+
+ // Dereference the script
+ script = null;
+
+ // Callback if not abort
+ if ( !isAbort ) {
+ callback( 200, "success" );
+ }
+ }
+ };
+
+ // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
+ // Use native DOM manipulation to avoid our domManip AJAX trickery
+ head.insertBefore( script, head.firstChild );
+ },
+
+ abort: function() {
+ if ( script ) {
+ script.onload( undefined, true );
+ }
+ }
+ };
+ }
+});
+var oldCallbacks = [],
+ rjsonp = /(=)\?(?=&|$)|\?\?/;
+
+// Default jsonp settings
+jQuery.ajaxSetup({
+ jsonp: "callback",
+ jsonpCallback: function() {
+ var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( ajax_nonce++ ) );
+ this[ callback ] = true;
+ return callback;
+ }
+});
+
+// Detect, normalize options and install callbacks for jsonp requests
+jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
+
+ var callbackName, overwritten, responseContainer,
+ jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
+ "url" :
+ typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
+ );
+
+ // Handle iff the expected data type is "jsonp" or we have a parameter to set
+ if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
+
+ // Get callback name, remembering preexisting value associated with it
+ callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
+ s.jsonpCallback() :
+ s.jsonpCallback;
+
+ // Insert callback into url or form data
+ if ( jsonProp ) {
+ s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
+ } else if ( s.jsonp !== false ) {
+ s.url += ( ajax_rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
+ }
+
+ // Use data converter to retrieve json after script execution
+ s.converters["script json"] = function() {
+ if ( !responseContainer ) {
+ jQuery.error( callbackName + " was not called" );
+ }
+ return responseContainer[ 0 ];
+ };
+
+ // force json dataType
+ s.dataTypes[ 0 ] = "json";
+
+ // Install callback
+ overwritten = window[ callbackName ];
+ window[ callbackName ] = function() {
+ responseContainer = arguments;
+ };
+
+ // Clean-up function (fires after converters)
+ jqXHR.always(function() {
+ // Restore preexisting value
+ window[ callbackName ] = overwritten;
+
+ // Save back as free
+ if ( s[ callbackName ] ) {
+ // make sure that re-using the options doesn't screw things around
+ s.jsonpCallback = originalSettings.jsonpCallback;
+
+ // save the callback name for future use
+ oldCallbacks.push( callbackName );
+ }
+
+ // Call if it was a function and we have a response
+ if ( responseContainer && jQuery.isFunction( overwritten ) ) {
+ overwritten( responseContainer[ 0 ] );
+ }
+
+ responseContainer = overwritten = undefined;
+ });
+
+ // Delegate to script
+ return "script";
+ }
+});
+var xhrCallbacks, xhrSupported,
+ xhrId = 0,
+ // #5280: Internet Explorer will keep connections alive if we don't abort on unload
+ xhrOnUnloadAbort = window.ActiveXObject && function() {
+ // Abort all pending requests
+ var key;
+ for ( key in xhrCallbacks ) {
+ xhrCallbacks[ key ]( undefined, true );
+ }
+ };
+
+// Functions to create xhrs
+function createStandardXHR() {
+ try {
+ return new window.XMLHttpRequest();
+ } catch( e ) {}
+}
+
+function createActiveXHR() {
+ try {
+ return new window.ActiveXObject("Microsoft.XMLHTTP");
+ } catch( e ) {}
+}
+
+// Create the request object
+// (This is still attached to ajaxSettings for backward compatibility)
+jQuery.ajaxSettings.xhr = window.ActiveXObject ?
+ /* Microsoft failed to properly
+ * implement the XMLHttpRequest in IE7 (can't request local files),
+ * so we use the ActiveXObject when it is available
+ * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
+ * we need a fallback.
+ */
+ function() {
+ return !this.isLocal && createStandardXHR() || createActiveXHR();
+ } :
+ // For all other browsers, use the standard XMLHttpRequest object
+ createStandardXHR;
+
+// Determine support properties
+xhrSupported = jQuery.ajaxSettings.xhr();
+jQuery.support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
+xhrSupported = jQuery.support.ajax = !!xhrSupported;
+
+// Create transport if the browser can provide an xhr
+if ( xhrSupported ) {
+
+ jQuery.ajaxTransport(function( s ) {
+ // Cross domain only allowed if supported through XMLHttpRequest
+ if ( !s.crossDomain || jQuery.support.cors ) {
+
+ var callback;
+
+ return {
+ send: function( headers, complete ) {
+
+ // Get a new xhr
+ var handle, i,
+ xhr = s.xhr();
+
+ // Open the socket
+ // Passing null username, generates a login popup on Opera (#2865)
+ if ( s.username ) {
+ xhr.open( s.type, s.url, s.async, s.username, s.password );
+ } else {
+ xhr.open( s.type, s.url, s.async );
+ }
+
+ // Apply custom fields if provided
+ if ( s.xhrFields ) {
+ for ( i in s.xhrFields ) {
+ xhr[ i ] = s.xhrFields[ i ];
+ }
+ }
+
+ // Override mime type if needed
+ if ( s.mimeType && xhr.overrideMimeType ) {
+ xhr.overrideMimeType( s.mimeType );
+ }
+
+ // X-Requested-With header
+ // For cross-domain requests, seeing as conditions for a preflight are
+ // akin to a jigsaw puzzle, we simply never set it to be sure.
+ // (it can always be set on a per-request basis or even using ajaxSetup)
+ // For same-domain requests, won't change header if already provided.
+ if ( !s.crossDomain && !headers["X-Requested-With"] ) {
+ headers["X-Requested-With"] = "XMLHttpRequest";
+ }
+
+ // Need an extra try/catch for cross domain requests in Firefox 3
+ try {
+ for ( i in headers ) {
+ xhr.setRequestHeader( i, headers[ i ] );
+ }
+ } catch( err ) {}
+
+ // Do send the request
+ // This may raise an exception which is actually
+ // handled in jQuery.ajax (so no try/catch here)
+ xhr.send( ( s.hasContent && s.data ) || null );
+
+ // Listener
+ callback = function( _, isAbort ) {
+ var status, responseHeaders, statusText, responses;
+
+ // Firefox throws exceptions when accessing properties
+ // of an xhr when a network error occurred
+ // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
+ try {
+
+ // Was never called and is aborted or complete
+ if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
+
+ // Only called once
+ callback = undefined;
+
+ // Do not keep as active anymore
+ if ( handle ) {
+ xhr.onreadystatechange = jQuery.noop;
+ if ( xhrOnUnloadAbort ) {
+ delete xhrCallbacks[ handle ];
+ }
+ }
+
+ // If it's an abort
+ if ( isAbort ) {
+ // Abort it manually if needed
+ if ( xhr.readyState !== 4 ) {
+ xhr.abort();
+ }
+ } else {
+ responses = {};
+ status = xhr.status;
+ responseHeaders = xhr.getAllResponseHeaders();
+
+ // When requesting binary data, IE6-9 will throw an exception
+ // on any attempt to access responseText (#11426)
+ if ( typeof xhr.responseText === "string" ) {
+ responses.text = xhr.responseText;
+ }
+
+ // Firefox throws an exception when accessing
+ // statusText for faulty cross-domain requests
+ try {
+ statusText = xhr.statusText;
+ } catch( e ) {
+ // We normalize with Webkit giving an empty statusText
+ statusText = "";
+ }
+
+ // Filter status for non standard behaviors
+
+ // If the request is local and we have data: assume a success
+ // (success with no data won't get notified, that's the best we
+ // can do given current implementations)
+ if ( !status && s.isLocal && !s.crossDomain ) {
+ status = responses.text ? 200 : 404;
+ // IE - #1450: sometimes returns 1223 when it should be 204
+ } else if ( status === 1223 ) {
+ status = 204;
+ }
+ }
+ }
+ } catch( firefoxAccessException ) {
+ if ( !isAbort ) {
+ complete( -1, firefoxAccessException );
+ }
+ }
+
+ // Call complete if needed
+ if ( responses ) {
+ complete( status, statusText, responses, responseHeaders );
+ }
+ };
+
+ if ( !s.async ) {
+ // if we're in sync mode we fire the callback
+ callback();
+ } else if ( xhr.readyState === 4 ) {
+ // (IE6 & IE7) if it's in cache and has been
+ // retrieved directly we need to fire the callback
+ setTimeout( callback );
+ } else {
+ handle = ++xhrId;
+ if ( xhrOnUnloadAbort ) {
+ // Create the active xhrs callbacks list if needed
+ // and attach the unload handler
+ if ( !xhrCallbacks ) {
+ xhrCallbacks = {};
+ jQuery( window ).unload( xhrOnUnloadAbort );
+ }
+ // Add to list of active xhrs callbacks
+ xhrCallbacks[ handle ] = callback;
+ }
+ xhr.onreadystatechange = callback;
+ }
+ },
+
+ abort: function() {
+ if ( callback ) {
+ callback( undefined, true );
+ }
+ }
+ };
+ }
+ });
+}
+var fxNow, timerId,
+ rfxtypes = /^(?:toggle|show|hide)$/,
+ rfxnum = new RegExp( "^(?:([+-])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
+ rrun = /queueHooks$/,
+ animationPrefilters = [ defaultPrefilter ],
+ tweeners = {
+ "*": [function( prop, value ) {
+ var end, unit,
+ tween = this.createTween( prop, value ),
+ parts = rfxnum.exec( value ),
+ target = tween.cur(),
+ start = +target || 0,
+ scale = 1,
+ maxIterations = 20;
+
+ if ( parts ) {
+ end = +parts[2];
+ unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );
+
+ // We need to compute starting value
+ if ( unit !== "px" && start ) {
+ // Iteratively approximate from a nonzero starting point
+ // Prefer the current property, because this process will be trivial if it uses the same units
+ // Fallback to end or a simple constant
+ start = jQuery.css( tween.elem, prop, true ) || end || 1;
+
+ do {
+ // If previous iteration zeroed out, double until we get *something*
+ // Use a string for doubling factor so we don't accidentally see scale as unchanged below
+ scale = scale || ".5";
+
+ // Adjust and apply
+ start = start / scale;
+ jQuery.style( tween.elem, prop, start + unit );
+
+ // Update scale, tolerating zero or NaN from tween.cur()
+ // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
+ } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
+ }
+
+ tween.unit = unit;
+ tween.start = start;
+ // If a +=/-= token was provided, we're doing a relative animation
+ tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end;
+ }
+ return tween;
+ }]
+ };
+
+// Animations created synchronously will run synchronously
+function createFxNow() {
+ setTimeout(function() {
+ fxNow = undefined;
+ });
+ return ( fxNow = jQuery.now() );
+}
+
+function createTweens( animation, props ) {
+ jQuery.each( props, function( prop, value ) {
+ var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
+ index = 0,
+ length = collection.length;
+ for ( ; index < length; index++ ) {
+ if ( collection[ index ].call( animation, prop, value ) ) {
+
+ // we're done with this property
+ return;
+ }
+ }
+ });
+}
+
+function Animation( elem, properties, options ) {
+ var result,
+ stopped,
+ index = 0,
+ length = animationPrefilters.length,
+ deferred = jQuery.Deferred().always( function() {
+ // don't match elem in the :animated selector
+ delete tick.elem;
+ }),
+ tick = function() {
+ if ( stopped ) {
+ return false;
+ }
+ var currentTime = fxNow || createFxNow(),
+ remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
+ // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
+ temp = remaining / animation.duration || 0,
+ percent = 1 - temp,
+ index = 0,
+ length = animation.tweens.length;
+
+ for ( ; index < length ; index++ ) {
+ animation.tweens[ index ].run( percent );
+ }
+
+ deferred.notifyWith( elem, [ animation, percent, remaining ]);
+
+ if ( percent < 1 && length ) {
+ return remaining;
+ } else {
+ deferred.resolveWith( elem, [ animation ] );
+ return false;
+ }
+ },
+ animation = deferred.promise({
+ elem: elem,
+ props: jQuery.extend( {}, properties ),
+ opts: jQuery.extend( true, { specialEasing: {} }, options ),
+ originalProperties: properties,
+ originalOptions: options,
+ startTime: fxNow || createFxNow(),
+ duration: options.duration,
+ tweens: [],
+ createTween: function( prop, end ) {
+ var tween = jQuery.Tween( elem, animation.opts, prop, end,
+ animation.opts.specialEasing[ prop ] || animation.opts.easing );
+ animation.tweens.push( tween );
+ return tween;
+ },
+ stop: function( gotoEnd ) {
+ var index = 0,
+ // if we are going to the end, we want to run all the tweens
+ // otherwise we skip this part
+ length = gotoEnd ? animation.tweens.length : 0;
+ if ( stopped ) {
+ return this;
+ }
+ stopped = true;
+ for ( ; index < length ; index++ ) {
+ animation.tweens[ index ].run( 1 );
+ }
+
+ // resolve when we played the last frame
+ // otherwise, reject
+ if ( gotoEnd ) {
+ deferred.resolveWith( elem, [ animation, gotoEnd ] );
+ } else {
+ deferred.rejectWith( elem, [ animation, gotoEnd ] );
+ }
+ return this;
+ }
+ }),
+ props = animation.props;
+
+ propFilter( props, animation.opts.specialEasing );
+
+ for ( ; index < length ; index++ ) {
+ result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
+ if ( result ) {
+ return result;
+ }
+ }
+
+ createTweens( animation, props );
+
+ if ( jQuery.isFunction( animation.opts.start ) ) {
+ animation.opts.start.call( elem, animation );
+ }
+
+ jQuery.fx.timer(
+ jQuery.extend( tick, {
+ elem: elem,
+ anim: animation,
+ queue: animation.opts.queue
+ })
+ );
+
+ // attach callbacks from options
+ return animation.progress( animation.opts.progress )
+ .done( animation.opts.done, animation.opts.complete )
+ .fail( animation.opts.fail )
+ .always( animation.opts.always );
+}
+
+function propFilter( props, specialEasing ) {
+ var value, name, index, easing, hooks;
+
+ // camelCase, specialEasing and expand cssHook pass
+ for ( index in props ) {
+ name = jQuery.camelCase( index );
+ easing = specialEasing[ name ];
+ value = props[ index ];
+ if ( jQuery.isArray( value ) ) {
+ easing = value[ 1 ];
+ value = props[ index ] = value[ 0 ];
+ }
+
+ if ( index !== name ) {
+ props[ name ] = value;
+ delete props[ index ];
+ }
+
+ hooks = jQuery.cssHooks[ name ];
+ if ( hooks && "expand" in hooks ) {
+ value = hooks.expand( value );
+ delete props[ name ];
+
+ // not quite $.extend, this wont overwrite keys already present.
+ // also - reusing 'index' from above because we have the correct "name"
+ for ( index in value ) {
+ if ( !( index in props ) ) {
+ props[ index ] = value[ index ];
+ specialEasing[ index ] = easing;
+ }
+ }
+ } else {
+ specialEasing[ name ] = easing;
+ }
+ }
+}
+
+jQuery.Animation = jQuery.extend( Animation, {
+
+ tweener: function( props, callback ) {
+ if ( jQuery.isFunction( props ) ) {
+ callback = props;
+ props = [ "*" ];
+ } else {
+ props = props.split(" ");
+ }
+
+ var prop,
+ index = 0,
+ length = props.length;
+
+ for ( ; index < length ; index++ ) {
+ prop = props[ index ];
+ tweeners[ prop ] = tweeners[ prop ] || [];
+ tweeners[ prop ].unshift( callback );
+ }
+ },
+
+ prefilter: function( callback, prepend ) {
+ if ( prepend ) {
+ animationPrefilters.unshift( callback );
+ } else {
+ animationPrefilters.push( callback );
+ }
+ }
+});
+
+function defaultPrefilter( elem, props, opts ) {
+ /*jshint validthis:true */
+ var prop, index, length,
+ value, dataShow, toggle,
+ tween, hooks, oldfire,
+ anim = this,
+ style = elem.style,
+ orig = {},
+ handled = [],
+ hidden = elem.nodeType && isHidden( elem );
+
+ // handle queue: false promises
+ if ( !opts.queue ) {
+ hooks = jQuery._queueHooks( elem, "fx" );
+ if ( hooks.unqueued == null ) {
+ hooks.unqueued = 0;
+ oldfire = hooks.empty.fire;
+ hooks.empty.fire = function() {
+ if ( !hooks.unqueued ) {
+ oldfire();
+ }
+ };
+ }
+ hooks.unqueued++;
+
+ anim.always(function() {
+ // doing this makes sure that the complete handler will be called
+ // before this completes
+ anim.always(function() {
+ hooks.unqueued--;
+ if ( !jQuery.queue( elem, "fx" ).length ) {
+ hooks.empty.fire();
+ }
+ });
+ });
+ }
+
+ // height/width overflow pass
+ if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
+ // Make sure that nothing sneaks out
+ // Record all 3 overflow attributes because IE does not
+ // change the overflow attribute when overflowX and
+ // overflowY are set to the same value
+ opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
+
+ // Set display property to inline-block for height/width
+ // animations on inline elements that are having width/height animated
+ if ( jQuery.css( elem, "display" ) === "inline" &&
+ jQuery.css( elem, "float" ) === "none" ) {
+
+ // inline-level elements accept inline-block;
+ // block-level elements need to be inline with layout
+ if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
+ style.display = "inline-block";
+
+ } else {
+ style.zoom = 1;
+ }
+ }
+ }
+
+ if ( opts.overflow ) {
+ style.overflow = "hidden";
+ if ( !jQuery.support.shrinkWrapBlocks ) {
+ anim.always(function() {
+ style.overflow = opts.overflow[ 0 ];
+ style.overflowX = opts.overflow[ 1 ];
+ style.overflowY = opts.overflow[ 2 ];
+ });
+ }
+ }
+
+
+ // show/hide pass
+ for ( index in props ) {
+ value = props[ index ];
+ if ( rfxtypes.exec( value ) ) {
+ delete props[ index ];
+ toggle = toggle || value === "toggle";
+ if ( value === ( hidden ? "hide" : "show" ) ) {
+ continue;
+ }
+ handled.push( index );
+ }
+ }
+
+ length = handled.length;
+ if ( length ) {
+ dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
+ if ( "hidden" in dataShow ) {
+ hidden = dataShow.hidden;
+ }
+
+ // store state if its toggle - enables .stop().toggle() to "reverse"
+ if ( toggle ) {
+ dataShow.hidden = !hidden;
+ }
+ if ( hidden ) {
+ jQuery( elem ).show();
+ } else {
+ anim.done(function() {
+ jQuery( elem ).hide();
+ });
+ }
+ anim.done(function() {
+ var prop;
+ jQuery._removeData( elem, "fxshow" );
+ for ( prop in orig ) {
+ jQuery.style( elem, prop, orig[ prop ] );
+ }
+ });
+ for ( index = 0 ; index < length ; index++ ) {
+ prop = handled[ index ];
+ tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 );
+ orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop );
+
+ if ( !( prop in dataShow ) ) {
+ dataShow[ prop ] = tween.start;
+ if ( hidden ) {
+ tween.end = tween.start;
+ tween.start = prop === "width" || prop === "height" ? 1 : 0;
+ }
+ }
+ }
+ }
+}
+
+function Tween( elem, options, prop, end, easing ) {
+ return new Tween.prototype.init( elem, options, prop, end, easing );
+}
+jQuery.Tween = Tween;
+
+Tween.prototype = {
+ constructor: Tween,
+ init: function( elem, options, prop, end, easing, unit ) {
+ this.elem = elem;
+ this.prop = prop;
+ this.easing = easing || "swing";
+ this.options = options;
+ this.start = this.now = this.cur();
+ this.end = end;
+ this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
+ },
+ cur: function() {
+ var hooks = Tween.propHooks[ this.prop ];
+
+ return hooks && hooks.get ?
+ hooks.get( this ) :
+ Tween.propHooks._default.get( this );
+ },
+ run: function( percent ) {
+ var eased,
+ hooks = Tween.propHooks[ this.prop ];
+
+ if ( this.options.duration ) {
+ this.pos = eased = jQuery.easing[ this.easing ](
+ percent, this.options.duration * percent, 0, 1, this.options.duration
+ );
+ } else {
+ this.pos = eased = percent;
+ }
+ this.now = ( this.end - this.start ) * eased + this.start;
+
+ if ( this.options.step ) {
+ this.options.step.call( this.elem, this.now, this );
+ }
+
+ if ( hooks && hooks.set ) {
+ hooks.set( this );
+ } else {
+ Tween.propHooks._default.set( this );
+ }
+ return this;
+ }
+};
+
+Tween.prototype.init.prototype = Tween.prototype;
+
+Tween.propHooks = {
+ _default: {
+ get: function( tween ) {
+ var result;
+
+ if ( tween.elem[ tween.prop ] != null &&
+ (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
+ return tween.elem[ tween.prop ];
+ }
+
+ // passing an empty string as a 3rd parameter to .css will automatically
+ // attempt a parseFloat and fallback to a string if the parse fails
+ // so, simple values such as "10px" are parsed to Float.
+ // complex values such as "rotate(1rad)" are returned as is.
+ result = jQuery.css( tween.elem, tween.prop, "" );
+ // Empty strings, null, undefined and "auto" are converted to 0.
+ return !result || result === "auto" ? 0 : result;
+ },
+ set: function( tween ) {
+ // use step hook for back compat - use cssHook if its there - use .style if its
+ // available and use plain properties where available
+ if ( jQuery.fx.step[ tween.prop ] ) {
+ jQuery.fx.step[ tween.prop ]( tween );
+ } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
+ jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
+ } else {
+ tween.elem[ tween.prop ] = tween.now;
+ }
+ }
+ }
+};
+
+// Remove in 2.0 - this supports IE8's panic based approach
+// to setting things on disconnected nodes
+
+Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
+ set: function( tween ) {
+ if ( tween.elem.nodeType && tween.elem.parentNode ) {
+ tween.elem[ tween.prop ] = tween.now;
+ }
+ }
+};
+
+jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
+ var cssFn = jQuery.fn[ name ];
+ jQuery.fn[ name ] = function( speed, easing, callback ) {
+ return speed == null || typeof speed === "boolean" ?
+ cssFn.apply( this, arguments ) :
+ this.animate( genFx( name, true ), speed, easing, callback );
+ };
+});
+
+jQuery.fn.extend({
+ fadeTo: function( speed, to, easing, callback ) {
+
+ // show any hidden elements after setting opacity to 0
+ return this.filter( isHidden ).css( "opacity", 0 ).show()
+
+ // animate to the value specified
+ .end().animate({ opacity: to }, speed, easing, callback );
+ },
+ animate: function( prop, speed, easing, callback ) {
+ var empty = jQuery.isEmptyObject( prop ),
+ optall = jQuery.speed( speed, easing, callback ),
+ doAnimation = function() {
+ // Operate on a copy of prop so per-property easing won't be lost
+ var anim = Animation( this, jQuery.extend( {}, prop ), optall );
+ doAnimation.finish = function() {
+ anim.stop( true );
+ };
+ // Empty animations, or finishing resolves immediately
+ if ( empty || jQuery._data( this, "finish" ) ) {
+ anim.stop( true );
+ }
+ };
+ doAnimation.finish = doAnimation;
+
+ return empty || optall.queue === false ?
+ this.each( doAnimation ) :
+ this.queue( optall.queue, doAnimation );
+ },
+ stop: function( type, clearQueue, gotoEnd ) {
+ var stopQueue = function( hooks ) {
+ var stop = hooks.stop;
+ delete hooks.stop;
+ stop( gotoEnd );
+ };
+
+ if ( typeof type !== "string" ) {
+ gotoEnd = clearQueue;
+ clearQueue = type;
+ type = undefined;
+ }
+ if ( clearQueue && type !== false ) {
+ this.queue( type || "fx", [] );
+ }
+
+ return this.each(function() {
+ var dequeue = true,
+ index = type != null && type + "queueHooks",
+ timers = jQuery.timers,
+ data = jQuery._data( this );
+
+ if ( index ) {
+ if ( data[ index ] && data[ index ].stop ) {
+ stopQueue( data[ index ] );
+ }
+ } else {
+ for ( index in data ) {
+ if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
+ stopQueue( data[ index ] );
+ }
+ }
+ }
+
+ for ( index = timers.length; index--; ) {
+ if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
+ timers[ index ].anim.stop( gotoEnd );
+ dequeue = false;
+ timers.splice( index, 1 );
+ }
+ }
+
+ // start the next in the queue if the last step wasn't forced
+ // timers currently will call their complete callbacks, which will dequeue
+ // but only if they were gotoEnd
+ if ( dequeue || !gotoEnd ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ finish: function( type ) {
+ if ( type !== false ) {
+ type = type || "fx";
+ }
+ return this.each(function() {
+ var index,
+ data = jQuery._data( this ),
+ queue = data[ type + "queue" ],
+ hooks = data[ type + "queueHooks" ],
+ timers = jQuery.timers,
+ length = queue ? queue.length : 0;
+
+ // enable finishing flag on private data
+ data.finish = true;
+
+ // empty the queue first
+ jQuery.queue( this, type, [] );
+
+ if ( hooks && hooks.cur && hooks.cur.finish ) {
+ hooks.cur.finish.call( this );
+ }
+
+ // look for any active animations, and finish them
+ for ( index = timers.length; index--; ) {
+ if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
+ timers[ index ].anim.stop( true );
+ timers.splice( index, 1 );
+ }
+ }
+
+ // look for any animations in the old queue and finish them
+ for ( index = 0; index < length; index++ ) {
+ if ( queue[ index ] && queue[ index ].finish ) {
+ queue[ index ].finish.call( this );
+ }
+ }
+
+ // turn off finishing flag
+ delete data.finish;
+ });
+ }
+});
+
+// Generate parameters to create a standard animation
+function genFx( type, includeWidth ) {
+ var which,
+ attrs = { height: type },
+ i = 0;
+
+ // if we include width, step value is 1 to do all cssExpand values,
+ // if we don't include width, step value is 2 to skip over Left and Right
+ includeWidth = includeWidth? 1 : 0;
+ for( ; i < 4 ; i += 2 - includeWidth ) {
+ which = cssExpand[ i ];
+ attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
+ }
+
+ if ( includeWidth ) {
+ attrs.opacity = attrs.width = type;
+ }
+
+ return attrs;
+}
+
+// Generate shortcuts for custom animations
+jQuery.each({
+ slideDown: genFx("show"),
+ slideUp: genFx("hide"),
+ slideToggle: genFx("toggle"),
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" },
+ fadeToggle: { opacity: "toggle" }
+}, function( name, props ) {
+ jQuery.fn[ name ] = function( speed, easing, callback ) {
+ return this.animate( props, speed, easing, callback );
+ };
+});
+
+jQuery.speed = function( speed, easing, fn ) {
+ var opt = speed && typeof speed === "object" ? jQuery.extend( {}, 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 :
+ opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
+
+ // normalize opt.queue - true/undefined/null -> "fx"
+ if ( opt.queue == null || opt.queue === true ) {
+ opt.queue = "fx";
+ }
+
+ // Queueing
+ opt.old = opt.complete;
+
+ opt.complete = function() {
+ if ( jQuery.isFunction( opt.old ) ) {
+ opt.old.call( this );
+ }
+
+ if ( opt.queue ) {
+ jQuery.dequeue( this, opt.queue );
+ }
+ };
+
+ return opt;
+};
+
+jQuery.easing = {
+ linear: function( p ) {
+ return p;
+ },
+ swing: function( p ) {
+ return 0.5 - Math.cos( p*Math.PI ) / 2;
+ }
+};
+
+jQuery.timers = [];
+jQuery.fx = Tween.prototype.init;
+jQuery.fx.tick = function() {
+ var timer,
+ timers = jQuery.timers,
+ i = 0;
+
+ fxNow = jQuery.now();
+
+ for ( ; i < timers.length; i++ ) {
+ timer = timers[ i ];
+ // Checks the timer has not already been removed
+ if ( !timer() && timers[ i ] === timer ) {
+ timers.splice( i--, 1 );
+ }
+ }
+
+ if ( !timers.length ) {
+ jQuery.fx.stop();
+ }
+ fxNow = undefined;
+};
+
+jQuery.fx.timer = function( timer ) {
+ if ( timer() && jQuery.timers.push( timer ) ) {
+ jQuery.fx.start();
+ }
+};
+
+jQuery.fx.interval = 13;
+
+jQuery.fx.start = function() {
+ if ( !timerId ) {
+ timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
+ }
+};
+
+jQuery.fx.stop = function() {
+ clearInterval( timerId );
+ timerId = null;
+};
+
+jQuery.fx.speeds = {
+ slow: 600,
+ fast: 200,
+ // Default speed
+ _default: 400
+};
+
+// Back Compat <1.8 extension point
+jQuery.fx.step = {};
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.animated = function( elem ) {
+ return jQuery.grep(jQuery.timers, function( fn ) {
+ return elem === fn.elem;
+ }).length;
+ };
+}
+jQuery.fn.offset = function( options ) {
+ if ( arguments.length ) {
+ return options === undefined ?
+ this :
+ this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ var docElem, win,
+ box = { top: 0, left: 0 },
+ elem = this[ 0 ],
+ doc = elem && elem.ownerDocument;
+
+ if ( !doc ) {
+ return;
+ }
+
+ docElem = doc.documentElement;
+
+ // Make sure it's not a disconnected DOM node
+ if ( !jQuery.contains( docElem, elem ) ) {
+ return box;
+ }
+
+ // If we don't have gBCR, just use 0,0 rather than error
+ // BlackBerry 5, iOS 3 (original iPhone)
+ if ( typeof elem.getBoundingClientRect !== core_strundefined ) {
+ box = elem.getBoundingClientRect();
+ }
+ win = getWindow( doc );
+ return {
+ top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
+ left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
+ };
+};
+
+jQuery.offset = {
+
+ setOffset: function( elem, options, i ) {
+ var position = jQuery.css( elem, "position" );
+
+ // set position first, in-case top/left are set even on static elem
+ if ( position === "static" ) {
+ elem.style.position = "relative";
+ }
+
+ var curElem = jQuery( elem ),
+ curOffset = curElem.offset(),
+ curCSSTop = jQuery.css( elem, "top" ),
+ curCSSLeft = jQuery.css( elem, "left" ),
+ calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
+ props = {}, curPosition = {}, curTop, curLeft;
+
+ // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
+ if ( calculatePosition ) {
+ curPosition = curElem.position();
+ curTop = curPosition.top;
+ curLeft = curPosition.left;
+ } else {
+ curTop = parseFloat( curCSSTop ) || 0;
+ curLeft = parseFloat( curCSSLeft ) || 0;
+ }
+
+ if ( jQuery.isFunction( options ) ) {
+ options = options.call( elem, i, curOffset );
+ }
+
+ if ( options.top != null ) {
+ props.top = ( options.top - curOffset.top ) + curTop;
+ }
+ if ( options.left != null ) {
+ props.left = ( options.left - curOffset.left ) + curLeft;
+ }
+
+ if ( "using" in options ) {
+ options.using.call( elem, props );
+ } else {
+ curElem.css( props );
+ }
+ }
+};
+
+
+jQuery.fn.extend({
+
+ position: function() {
+ if ( !this[ 0 ] ) {
+ return;
+ }
+
+ var offsetParent, offset,
+ parentOffset = { top: 0, left: 0 },
+ elem = this[ 0 ];
+
+ // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is it's only offset parent
+ if ( jQuery.css( elem, "position" ) === "fixed" ) {
+ // we assume that getBoundingClientRect is available when computed position is fixed
+ offset = elem.getBoundingClientRect();
+ } else {
+ // Get *real* offsetParent
+ offsetParent = this.offsetParent();
+
+ // Get correct offsets
+ offset = this.offset();
+ if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
+ parentOffset = offsetParent.offset();
+ }
+
+ // Add offsetParent borders
+ parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
+ parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
+ }
+
+ // Subtract parent offsets and 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
+ return {
+ top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
+ left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
+ };
+ },
+
+ offsetParent: function() {
+ return this.map(function() {
+ var offsetParent = this.offsetParent || document.documentElement;
+ while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position") === "static" ) ) {
+ offsetParent = offsetParent.offsetParent;
+ }
+ return offsetParent || document.documentElement;
+ });
+ }
+});
+
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
+ var top = /Y/.test( prop );
+
+ jQuery.fn[ method ] = function( val ) {
+ return jQuery.access( this, function( elem, method, val ) {
+ var win = getWindow( elem );
+
+ if ( val === undefined ) {
+ return win ? (prop in win) ? win[ prop ] :
+ win.document.documentElement[ method ] :
+ elem[ method ];
+ }
+
+ if ( win ) {
+ win.scrollTo(
+ !top ? val : jQuery( win ).scrollLeft(),
+ top ? val : jQuery( win ).scrollTop()
+ );
+
+ } else {
+ elem[ method ] = val;
+ }
+ }, method, val, arguments.length, null );
+ };
+});
+
+function getWindow( elem ) {
+ return jQuery.isWindow( elem ) ?
+ elem :
+ elem.nodeType === 9 ?
+ elem.defaultView || elem.parentWindow :
+ false;
+}
+// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
+jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
+ jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
+ // margin is only for outerHeight, outerWidth
+ jQuery.fn[ funcName ] = function( margin, value ) {
+ var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
+ extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
+
+ return jQuery.access( this, function( elem, type, value ) {
+ var doc;
+
+ if ( jQuery.isWindow( elem ) ) {
+ // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
+ // isn't a whole lot we can do. See pull request at this URL for discussion:
+ // https://github.com/jquery/jquery/pull/764
+ return elem.document.documentElement[ "client" + name ];
+ }
+
+ // Get document width or height
+ if ( elem.nodeType === 9 ) {
+ doc = elem.documentElement;
+
+ // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
+ // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
+ return Math.max(
+ elem.body[ "scroll" + name ], doc[ "scroll" + name ],
+ elem.body[ "offset" + name ], doc[ "offset" + name ],
+ doc[ "client" + name ]
+ );
+ }
+
+ return value === undefined ?
+ // Get width or height on the element, requesting but not forcing parseFloat
+ jQuery.css( elem, type, extra ) :
+
+ // Set width or height on the element
+ jQuery.style( elem, type, value, extra );
+ }, type, chainable ? margin : undefined, chainable, null );
+ };
+ });
+});
+// Limit scope pollution from any deprecated API
+// (function() {
+
+// })();
+// Expose jQuery to the global object
+window.jQuery = window.$ = jQuery;
+
+// Expose jQuery as an AMD module, but only for AMD loaders that
+// understand the issues with loading multiple versions of jQuery
+// in a page that all might call define(). The loader will indicate
+// they have special allowances for multiple jQuery versions by
+// specifying define.amd.jQuery = true. Register as a named module,
+// since jQuery can be concatenated with other files that may use define,
+// but not use a proper concatenation script that understands anonymous
+// AMD modules. A named AMD is safest and most robust way to register.
+// Lowercase jquery is used because AMD module names are derived from
+// file names, and jQuery is normally delivered in a lowercase file name.
+// Do this after creating the global so that if an AMD module wants to call
+// noConflict to hide this version of jQuery, it will work.
+if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
+ define( "jquery", [], function () { return jQuery; } );
+}
+
+})( window );
diff --git a/js/common.js b/js/common.js
index 8b2d6dff..fd367c91 100644
--- a/js/common.js
+++ b/js/common.js
@@ -1,1023 +1,1037 @@
define(['jquery', 'reference', 'jquery.ui'],
- function($, reference) {
- function SortNumeric(x, y) {
- return x - y;
- }
+ function($, reference) {
+ function SortNumeric(x, y) {
+ return x - y;
+ }
- String.prototype.trim = function() {
- return this.replace(/^\s+|\s+$/g, "");
- };
+ String.prototype.trim = function() {
+ return this.replace(/^\s+|\s+$/g, "");
+ };
- String.prototype.ltrim = function() {
- return this.replace(/^\s+/, "");
- };
+ String.prototype.ltrim = function() {
+ return this.replace(/^\s+/, "");
+ };
- String.prototype.rtrim = function() {
- return this.replace(/\s+$/, "");
- };
- var Util = {
- HandleLink: function(e) {
- Search($(e.target).text());
- Settings.SaveResults();
- },
- HandleHiddenLink: function(e) {
- Search($(e.target).find(".searchvalue").text());
- Settings.SaveResults();
- },
- RemoveResult: function(e) {
- $(e.target).parent().parent().remove();
- Settings.SaveResults();
- },
- HandleError: function(e) {
- // for now we're going to put the error in the main result div.
- var t = $("
" + e + "");
- $("#result").prepend(t);
- t.find(".removeresult").click(function(e) {
- Util.RemoveResult(e);
- });
- return false;
- }
- };
- var Traverse = function (node, testament) {
- try {
- var treeText = "";
- if (node != null) {
- if (node.hasChildNodes()) {
- if (node.nodeName == "s") {
- // you need to test if this is the OT or NT and set the attribute accordingly.
- var t = "";
- if (testament == "old") {
- t = "H";
- }
- if (testament == "new") {
- t = "G";
- }
- treeText += "
" + t + node.getAttribute("n") + "" + Traverse(node.childNodes.item(0), testament) + "";
- } else {
- treeText += '<' + node.nodeName + '>';
- for (var i = 0; i < node.childNodes.length; i++) {
- treeText += Traverse(node.childNodes.item(i), testament);
- }
- treeText += '' + node.nodeName + '>';
- }
- } else {
- if (node.nodeValue != null) {
- if (node.nodeValue.search(/^(\,|\.|\:|\?|\;|\!)/) != -1) {
- treeText += node.nodeValue;
- } else {
- treeText += " " + node.nodeValue;
- }
- }
- }
- }
- return treeText;
- }
- catch (err) {
- Util.HandleError(err);
- }
- return null;
- };
- var Search = function (sv) {
- try {
- var qs = sv.split(";");
+ String.prototype.rtrim = function() {
+ return this.replace(/\s+$/, "");
+ };
+ var Util = {
+ HandleLink: function(e) {
+ Search($(e.target).text());
+ Settings.SaveResults();
+ },
+ HandleHiddenLink: function(e) {
+ Search($(e.target).find(".searchvalue").text());
+ Settings.SaveResults();
+ },
+ RemoveResult: function(e) {
+ $(e.target).parent().parent().remove();
+ Settings.SaveResults();
+ },
+ HandleError: function(e) {
+ // for now we're going to put the error in the main result div.
+ var t = $("
" + e + "");
+ $("#result").prepend(t);
+ t.find(".removeresult").click(function(e) {
+ Util.RemoveResult(e);
+ });
+ return false;
+ },
+ GetUrlVars: function() {
+ // Read a page's GET URL variables and return them as an associative array.
+ var vars = [], hash;
+ var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
+ for(var i = 0; i < hashes.length; i++)
+ {
+ hash = hashes[i].split('=');
+ vars.push(hash[0]);
+ vars[hash[0]] = hash[1];
+ }
+ return vars;
+ }
+ };
+ var Traverse = function (node, testament) {
+ try {
+ var treeText = "";
+ if (node != null) {
+ if (node.hasChildNodes()) {
+ if (node.nodeName == "s") {
+ // you need to test if this is the OT or NT and set the attribute accordingly.
+ var t = "";
+ if (testament == "old") {
+ t = "H";
+ }
+ if (testament == "new") {
+ t = "G";
+ }
+ treeText += "
" + t + node.getAttribute("n") + "" + Traverse(node.childNodes.item(0), testament) + "";
+ } else {
+ treeText += '<' + node.nodeName + '>';
+ for (var i = 0; i < node.childNodes.length; i++) {
+ treeText += Traverse(node.childNodes.item(i), testament);
+ }
+ treeText += '' + node.nodeName + '>';
+ }
+ } else {
+ if (node.nodeValue != null) {
+ if (node.nodeValue.search(/^(\,|\.|\:|\?|\;|\!)/) != -1) {
+ treeText += node.nodeValue;
+ } else {
+ treeText += " " + node.nodeValue;
+ }
+ }
+ }
+ }
+ return treeText;
+ }
+ catch (err) {
+ Util.HandleError(err);
+ }
+ return null;
+ };
+ var Search = function (sv) {
+ try {
+ var qs = sv.split(";");
- for (var x in qs) {
- var q = qs[x].trim();
- if (q != "") {
- // its a search term.
- if (q.search(/[0-9]/i) == -1) {
- // get new results.
- Words.FindReferences(q);
- } else if (q.search(/(H|G)[0-9]/i) != -1) {
- // its a strongs lookup
- var dict = q.substring(0, 1);
- if (dict.search(/h/i) != -1) {
- dict = "heb";
- } else {
- dict = "grk";
- }
- q = q.substring(1, q.length);
- var Ss = q.split(' ');
+ for (var x in qs) {
+ var q = qs[x].trim();
+ if (q != "") {
+ // its a search term.
+ if (q.search(/[0-9]/i) == -1) {
+ // get new results.
+ Words.FindReferences(q);
+ } else if (q.search(/(H|G)[0-9]/i) != -1) {
+ // its a strongs lookup
+ var dict = q.substring(0, 1);
+ if (dict.search(/h/i) != -1) {
+ dict = "heb";
+ } else {
+ dict = "grk";
+ }
+ q = q.substring(1, q.length);
+ var Ss = q.split(' ');
- var results = [];
- for (var s in Ss) {
- results.push(Strongs.GetStrongs(Ss[s], dict));
- }
+ var results = [];
+ for (var s in Ss) {
+ results.push(Strongs.GetStrongs(Ss[s], dict));
+ }
- for (var result in results) {
- // display results.
- if ($("#display-strongs-as-dialog")[0].checked) {
- Strongs.DisplayStrongsDialog(results[result]);
- } else {
- Strongs.DisplayStrongs(results[result]);
+ for (var result in results) {
+ // display results.
+ if ($("#display-strongs-as-dialog")[0].checked) {
+ Strongs.DisplayStrongsDialog(results[result]);
+ } else {
+ Strongs.DisplayStrongs(results[result]);
- }
- }
+ }
+ }
- } else {
- // its a verse reference.
- var passage = "";
- if (q.trim() != "") {
- var myref = reference.Parse(q.trim());
- var r = Bible.GetPassage(myref.book, myref.startchapter, myref.endchapter, myref.startverse, myref.endverse);
+ } else {
+ // its a verse reference.
+ var passage = "";
+ if (q.trim() != "") {
+ var myref = reference.Parse(q.trim());
+ var r = Bible.GetPassage(myref.book, myref.startchapter, myref.endchapter, myref.startverse, myref.endverse);
- Bible.DisplayPassage(r.cs, myref, r.testament);
- }
- }
- }
- }
- $( "#result" ).sortable({
- axis: "x",
- handle: ".handle"
- });
- Settings.SaveResults();
- }
- catch (err) {
- Util.HandleError(err);
- }
+ Bible.DisplayPassage(r.cs, myref, r.testament);
+ }
+ }
+ }
+ }
+ $( "#result" ).sortable({
+ axis: "x",
+ handle: ".handle"
+ });
+ Settings.SaveResults();
+ }
+ catch (err) {
+ Util.HandleError(err);
+ }
- return false;
- };
- var Settings = {
- Load: function() {
- if(typeof(Storage)!=="undefined") {
- if (localStorage.Panes !== "undefined") {
- $("#resultwrap").css("float", localStorage.Panes);
- $("#searchresultswrap").css("float", localStorage.Panes);
- }
+ return false;
+ };
+ var Settings = {
+ Load: function(skipresults) {
+ if(typeof(Storage)!=="undefined") {
+ // sometimes we want to load the settings, but not the results previously in the window.
+ if (skipresults == "undefined" || skipresults == false) {
+ if (localStorage.Panes !== "undefined") {
+ $("#resultwrap").css("float", localStorage.Panes);
+ $("#searchresultswrap").css("float", localStorage.Panes);
+ }
+ }
+ if (localStorage.Search !== "undefined" && localStorage.Search == "none") {
+ $("#searchresultswrap").css("display", "none");
+ $("#showhidesearch").html("Show Search");
+ $("#resultwrap").css("width", "100%");
- if (localStorage.Search !== "undefined" && localStorage.Search == "none") {
- $("#searchresultswrap").css("display", "none");
- $("#showhidesearch").html("Show Search");
- $("#resultwrap").css("width", "100%");
+ } else {
+ $("#searchresultswrap").css("display", "block");
+ $("#showhidesearch").html("Hide Search");
+ $("#resultwrap").css("width", "70%");
+ }
- } else {
- $("#searchresultswrap").css("display", "block");
- $("#showhidesearch").html("Hide Search");
- $("#resultwrap").css("width", "70%");
- }
+ if (localStorage.FontSize !== "undefined") {
+ $("#result").css("font-size", localStorage.FontSize);
+ }
+ if (localStorage.Font !== "undefined") {
+ $("#result").css("font-family", localStorage.Font);
+ $("#changefont").val(localStorage.Font);
+ }
+ if (localStorage.StrongsAsDialog !== "undefined" && localStorage.StrongsAsDialog == "false") {
+ $("#display-strongs-as-dialog")[0].checked = false;
+ } else {
+ $("#display-strongs-as-dialog")[0].checked = true;
+ }
- if (localStorage.FontSize !== "undefined") {
- $("#result").css("font-size", localStorage.FontSize);
- }
- if (localStorage.Font !== "undefined") {
- $("#result").css("font-family", localStorage.Font);
- $("#changefont").val(localStorage.Font);
- }
- if (localStorage.StrongsAsDialog !== "undefined" && localStorage.StrongsAsDialog == "false") {
- $("#display-strongs-as-dialog")[0].checked = false;
- } else {
- $("#display-strongs-as-dialog")[0].checked = true;
- }
+ if (localStorage.Results !== "undefined" && localStorage.SearchResults !== "undefined") {
+ $("#resultwrap").html(localStorage.Results);
+ $("#searchresultswrap").html(localStorage.SearchResults);
+ $("#resultwrap").find(".hiddenlink").click(function(e) {
+ Util.HandleHiddenLink(e);
+ });
+ $("#resultwrap").find(".removeresult").click(function(e) {
+ Util.RemoveResult(e);
+ });
+ $("#searchresultswrap").find(".link").click(function(e) {
+ Util.HandleLink(e);
+ });
+ }
+ }
+ },
+ Save: function() {
+ if(typeof(Storage)!=="undefined")
+ {
+ localStorage.Panes = $("#resultwrap").css("float");
+ localStorage.Search = $("#searchresultswrap").css("display");
+ localStorage.FontSize = $("#result").css("font-size");
+ localStorage.Font = $("#result").css("font-family");
+ localStorage.StrongsAsDialog = $("#display-strongs-as-dialog")[0].checked;
+ }
+ },
+ ShowHideSearch: function() {
+ var o = $("#showhidesearch");
+ var s = $("#searchresultswrap");
+ var r = $("#resultwrap");
- if (localStorage.Results !== "undefined" && localStorage.SearchResults !== "undefined") {
- $("#resultwrap").html(localStorage.Results);
- $("#searchresultswrap").html(localStorage.SearchResults);
- $("#resultwrap").find(".hiddenlink").click(function(e) {
- Util.HandleHiddenLink(e);
- });
- $("#resultwrap").find(".removeresult").click(function(e) {
- Util.RemoveResult(e);
- });
- $("#searchresultswrap").find(".link").click(function(e) {
- Util.HandleLink(e);
- });
- }
- }
- },
- Save: function() {
- if(typeof(Storage)!=="undefined")
- {
- localStorage.Panes = $("#resultwrap").css("float");
- localStorage.Search = $("#searchresultswrap").css("display");
- localStorage.FontSize = $("#result").css("font-size");
- localStorage.Font = $("#result").css("font-family");
- localStorage.StrongsAsDialog = $("#display-strongs-as-dialog")[0].checked;
- }
- },
- ShowHideSearch: function() {
- var o = $("#showhidesearch");
- var s = $("#searchresultswrap");
- var r = $("#resultwrap");
+ if (s.css("display") != "none") {
+ s.css("display", "none");
+ o.html("Show Search");
+ r.css("width", "100%");
+ } else {
+ s.css("display", "block");
+ o.html("Hide Search");
+ r.css("width", "70%");
+ }
+ this.Save();
+ },
+ SwitchPanes: function() {
+ var s = $("#searchresultswrap");
+ var r = $("#resultwrap");
+ var v = s.css("float");
+ if (v == "right") {
+ s.css("float", "left");
+ r.css("float", "left");
+ } else {
+ s.css("float", "right");
+ r.css("float", "right");
+ }
+ this.Save();
+ },
+ IncreaseResultFontSize: function() {
+ var s = $("#result").css("font-size");
+ $("#result").css("font-size", parseInt(s) + 1);
+ this.Save();
+ },
+ DecreaseResultFontSize: function() {
+ var s = $("#result").css("font-size");
+ $("#result").css("font-size", parseInt(s) - 1);
+ this.Save();
+ },
+ ChangeResultFont: function(fontfamily) {
+ $("#result").css("font-family", fontfamily);
+ this.Save();
+ },
+ ChangeDisplayStrongsInDialog: function(fontfamily) {
+ this.Save();
+ },
+ SaveResults: function() {
+ localStorage.Results = $("#resultwrap").html();
+ localStorage.SearchResults = $("#searchresultswrap").html();
+ }
+ };
+ var Bible = {
+ DisplayPassage: function(cs, ref, testament) {
+ try {
+ var r = "";
+ // make the end verse pretty.
+ var tvs = cs[cs.length - 1].vss.length;
- if (s.css("display") != "none") {
- s.css("display", "none");
- o.html("Show Search");
- r.css("width", "100%");
- } else {
- s.css("display", "block");
- o.html("Hide Search");
- r.css("width", "70%");
- }
- this.Save();
- },
- SwitchPanes: function() {
- var s = $("#searchresultswrap");
- var r = $("#resultwrap");
- var v = s.css("float");
- if (v == "right") {
- s.css("float", "left");
- r.css("float", "left");
- } else {
- s.css("float", "right");
- r.css("float", "right");
- }
- this.Save();
- },
- IncreaseResultFontSize: function() {
- var s = $("#result").css("font-size");
- $("#result").css("font-size", parseInt(s) + 1);
- this.Save();
- },
- DecreaseResultFontSize: function() {
- var s = $("#result").css("font-size");
- $("#result").css("font-size", parseInt(s) - 1);
- this.Save();
- },
- ChangeResultFont: function(fontfamily) {
- $("#result").css("font-family", fontfamily);
- this.Save();
- },
- ChangeDisplayStrongsInDialog: function(fontfamily) {
- this.Save();
- },
- SaveResults: function() {
- localStorage.Results = $("#resultwrap").html();
- localStorage.SearchResults = $("#searchresultswrap").html();
- }
- };
- var Bible = {
- DisplayPassage: function(cs, ref, testament) {
- try {
- var r = "";
- // make the end verse pretty.
- var tvs = cs[cs.length - 1].vss.length;
+ for (var j = 0; j < cs.length; j++) {
+ if (Number(ref.startchapter) < Number(ref.endchapter)) {
+ r += "
Chapter: " + cs[j].ch + "";
+ }
+ var vss = cs[j].vss;
- for (var j = 0; j < cs.length; j++) {
- if (Number(ref.startchapter) < Number(ref.endchapter)) {
- r += "
Chapter: " + cs[j].ch + "";
- }
- var vss = cs[j].vss;
+ for (var m = 0; m < vss.length; m++) {
+ var v = vss[m];
- for (var m = 0; m < vss.length; m++) {
- var v = vss[m];
+ r += "
" + v.v + ". ";
- r += "
" + v.v + ". ";
+ for (var w = 0; w < v.w.length; w++) {
+ if (v.w[w].s != undefined) {
+ var strongs_pre = "";
+ if (testament == "old") {
+ strongs_pre = "H";
+ }
+ if (testament == "new") {
+ strongs_pre = "G";
+ }
+ var sp = "";
+ if (v.w[w].t.substr(v.w[w].t.length-1) == " ") {
+ sp = " ";
+ }
+ r += "
" + strongs_pre + v.w[w].s + "" + v.w[w].t.trim() + ""+sp;
+ } else {
+ r += v.w[w].t;
+ }
+ }
+ r += "
";
+ }
+ }
+ var t = $("
" + "" + ref.toString() + "
" + r + "");
- for (var w = 0; w < v.w.length; w++) {
- if (v.w[w].s != undefined) {
- var strongs_pre = "";
- if (testament == "old") {
- strongs_pre = "H";
- }
- if (testament == "new") {
- strongs_pre = "G";
- }
- var sp = "";
- if (v.w[w].t.substr(v.w[w].t.length-1) == " ") {
- sp = " ";
- }
- r += "
" + strongs_pre + v.w[w].s + "" + v.w[w].t.trim() + ""+sp;
- } else {
- r += v.w[w].t;
- }
- }
- r += "
";
- }
- }
- var t = $("
" + "" + ref.toString() + "
" + r + "");
+ t.find(".hiddenlink").click(function(e) {
+ Util.HandleHiddenLink(e);
+ });
+ t.find(".removeresult").click(function(e) {
+ Util.RemoveResult(e);
+ });
+ $("#result").prepend(t);
+ }
+ catch (err) {
+ Util.HandleError(err);
+ }
+ },
+ GetPassage: function(b, sch, ech, sv, ev) {
+ try {
+ var chapters = []; // the verses from the chapter.
+ var cs = []; // the verses requested.
+ var r = {};
- t.find(".hiddenlink").click(function(e) {
- Util.HandleHiddenLink(e);
- });
- t.find(".removeresult").click(function(e) {
- Util.RemoveResult(e);
- });
- $("#result").prepend(t);
- }
- catch (err) {
- Util.HandleError(err);
- }
- },
- GetPassage: function(b, sch, ech, sv, ev) {
- try {
- var chapters = []; // the verses from the chapter.
- var cs = []; // the verses requested.
- var r = {};
+ for (var i = sch; i <= ech; i++) {
+ var url = "bibles/kjv_strongs/" + b + "-" + i + ".json";
+ $.ajax({
+ async: false,
+ type: "GET",
+ url: url,
+ dataType: "json",
+ success: function(d, t, x) {
+ chapters.push(d);
+ },
+ error: function(request, status, error) {
+ Util.HandleError(error, request);
+ }
+ });
+ }
- for (var i = sch; i <= ech; i++) {
- var url = "bibles/kjv_strongs/" + b + "-" + i + ".json";
- $.ajax({
- async: false,
- type: "GET",
- url: url,
- dataType: "json",
- success: function(d, t, x) {
- chapters.push(d);
- },
- error: function(request, status, error) {
- Util.HandleError(error, request);
- }
- });
- }
+ for (var j = 0; j < chapters.length; j++) {
+ var vss = [];
+ var start;
+ var end;
- for (var j = 0; j < chapters.length; j++) {
- var vss = [];
- var start;
- var end;
+ // figure out the start verse.
+ if (j == 0) {
+ start = sv;
+ } else {
+ start = 1;
+ }
- // figure out the start verse.
- if (j == 0) {
- start = sv;
- } else {
- start = 1;
- }
+ // figure out the end verse
+ if ((j + 1) == chapters.length) {
+ end = ev;
+ } else {
+ end = "*";
+ }
- // figure out the end verse
- if ((j + 1) == chapters.length) {
- end = ev;
- } else {
- end = "*";
- }
+ // get the verses requested.
+ var tvs = chapters[j].vss.length;
+ if (end == "*" || end > tvs) {
+ end = tvs;
+ }
- // get the verses requested.
- var tvs = chapters[j].vss.length;
- if (end == "*" || end > tvs) {
- end = tvs;
- }
+ for (i = start; i <= end; i++) {
+ // we're using c based indexes here, so the index is 1 less than the verse #.
+ vss.push(chapters[j].vss[i-1]);
+ }
- for (i = start; i <= end; i++) {
- // we're using c based indexes here, so the index is 1 less than the verse #.
- vss.push(chapters[j].vss[i-1]);
- }
+ cs.push({
+ "ch": chapters[j].ch,
+ "vss": vss
+ });
+ }
- cs.push({
- "ch": chapters[j].ch,
- "vss": vss
- });
- }
+ r.cs = cs;
+ if (b >= 40) {
+ r.testament = "new";
+ } else {
+ r.testament = "old";
+ }
+ return r;
+ } catch (err) {
+ Util.HandleError(err);
+ }
+ return null;
+ }
+ };
+ var Strongs = {
+ GetStrongs: function(sn, dict) {
+ try {
+ var self = this;
+ var results = {};
+ var url = dict + parseInt((sn - 1) / 100) + ".xml";
+ if (dict == "grk") {
+ results.prefix = "G";
+ } else {
+ results.prefix = "H";
+ }
+ results.sn = sn;
- r.cs = cs;
- if (b >= 40) {
- r.testament = "new";
- } else {
- r.testament = "old";
- }
- return r;
- } catch (err) {
- Util.HandleError(err);
- }
- return null;
- }
- };
- var Strongs = {
- GetStrongs: function(sn, dict) {
- try {
- var self = this;
- var results = {};
- var url = dict + parseInt((sn - 1) / 100) + ".xml";
- if (dict == "grk") {
- results.prefix = "G";
- } else {
- results.prefix = "H";
- }
- results.sn = sn;
+ $.ajax({
+ async: false,
+ type: "GET",
+ url: "xml/" + url,
+ dataType: "xml",
+ success: function(d, t, x) {
+ results.strongs = d;
+ },
+ error: function(request, status, error) {
+ Util.HandleError(error, request);
+ }
+ });
- $.ajax({
- async: false,
- type: "GET",
- url: "xml/" + url,
- dataType: "xml",
- success: function(d, t, x) {
- results.strongs = d;
- },
- error: function(request, status, error) {
- Util.HandleError(error, request);
- }
- });
+ $.ajax({
+ async: false,
+ type: "GET",
+ url: "xml/cr" + url,
+ dataType: "xml",
+ success: function(d, t, x) {
+ results.crossrefs = d;
+ },
+ error: function(request, status, error) {
+ Util.HandleError(error, request);
+ }
+ });
- $.ajax({
- async: false,
- type: "GET",
- url: "xml/cr" + url,
- dataType: "xml",
- success: function(d, t, x) {
- results.crossrefs = d;
- },
- error: function(request, status, error) {
- Util.HandleError(error, request);
- }
- });
+ if (dict == "grk") {
+ url = "xml/rs" + parseInt((sn - 1) / 1000) + ".xml";
+ // rmac is a two get process.
+ $.ajax({
+ async: false,
+ type: "GET",
+ url: url,
+ dataType: "xml",
+ success: function(d, t, x) {
+ results.rmac = d;
+ },
+ error: function(request, status, error) {
+ Util.HandleError(error, request);
+ }
+ });
- if (dict == "grk") {
- url = "xml/rs" + parseInt((sn - 1) / 1000) + ".xml";
- // rmac is a two get process.
- $.ajax({
- async: false,
- type: "GET",
- url: url,
- dataType: "xml",
- success: function(d, t, x) {
- results.rmac = d;
- },
- error: function(request, status, error) {
- Util.HandleError(error, request);
- }
- });
+ // deal with RMAC
+ results.rmaccode = $(results.rmac).find('s[id="' + sn + '"]').attr("r");
+ url = "xml/r-" + results.rmaccode.substring(0, 1) + ".xml";
+ $.ajax({
+ async: false,
+ type: "GET",
+ url: url,
+ dataType: "xml",
+ success: function(d, t, x) {
+ results.rmac = d;
+ },
+ error: function(request, status, error) {
+ Util.HandleError(error, request);
+ }
+ });
+ }
+ return results;
+ } catch (err) {
+ Util.HandleError(err);
+ }
+ return null;
+ },
+ BuildStrongs: function(r) {
+ try {
+ // first deal with strongs data.
+ var entry = $(r.strongs).find("i#" + r.prefix + r.sn);
+ var title = $(entry).find("t").text();
+ var trans = $(entry).find("tr").text();
+ var pron = $(entry).find("p").text();
+ var desc = Traverse($(entry).find("d")[0]);
- // deal with RMAC
- results.rmaccode = $(results.rmac).find('s[id="' + sn + '"]').attr("r");
- url = "xml/r-" + results.rmaccode.substring(0, 1) + ".xml";
- $.ajax({
- async: false,
- type: "GET",
- url: url,
- dataType: "xml",
- success: function(d, t, x) {
- results.rmac = d;
- },
- error: function(request, status, error) {
- Util.HandleError(error, request);
- }
- });
- }
- return results;
- } catch (err) {
- Util.HandleError(err);
- }
- return null;
- },
- BuildStrongs: function(r) {
- try {
- // first deal with strongs data.
- var entry = $(r.strongs).find("i#" + r.prefix + r.sn);
- var title = $(entry).find("t").text();
- var trans = $(entry).find("tr").text();
- var pron = $(entry).find("p").text();
- var desc = Traverse($(entry).find("d")[0]);
+ var re = /([hg][0-9]{1,4})/gi;
- var re = /([hg][0-9]{1,4})/gi;
+ desc = desc.replace(re, "
$1");
- desc = desc.replace(re, "
$1");
+ // now deal with cross references.
+ var cr = $(r.crossrefs).find("i#" + r.prefix + r.sn).find("rs");
- // now deal with cross references.
- var cr = $(r.crossrefs).find("i#" + r.prefix + r.sn).find("rs");
+ var crtxt = "
Cross References: Show";
- var crtxt = "Cross References: Show";
+ cr.each(function(i) {
+ crtxt += "" + $(this).find("t").text() + ": ";
- cr.each(function(i) {
- crtxt += "" + $(this).find("t").text() + ": ";
+ $(this).find("r").each(function(j) {
+ var ref = $(this).attr("r").split(";");
+ crtxt += "" + reference.bookName(ref[0]) + " " + ref[1] + ":" + ref[2] + ", ";
+ });
+ crtxt = crtxt.substr(0, crtxt.length - 2);
+ crtxt += "
";
+ });
+ crtxt += " ";
- $(this).find("r").each(function(j) {
- var ref = $(this).attr("r").split(";");
- crtxt += "" + reference.bookName(ref[0]) + " " + ref[1] + ":" + ref[2] + ", ";
- });
- crtxt = crtxt.substr(0, crtxt.length - 2);
- crtxt += "
";
- });
- crtxt += " ";
+ // ...processing statements go here...
+ var rtxt = "";
+ if (r.prefix == "G") {
+ rtxt += "
Robinsons Morphological Analysis Code: " + r.rmaccode + " Show";
+ ;
+ $(r.rmac).find('i[id="' + r.rmaccode.toUpperCase() + '"]').find("d").each(function() {
+ rtxt += $(this).text() + "
";
+ });
+ rtxt += " ";
+ }
+ // put together the display.
- // ...processing statements go here...
- var rtxt = "";
- if (r.prefix == "G") {
- rtxt += "
Robinsons Morphological Analysis Code: " + r.rmaccode + " Show";
- ;
- $(r.rmac).find('i[id="' + r.rmaccode.toUpperCase() + '"]').find("d").each(function() {
- rtxt += $(this).text() + "
";
- });
- rtxt += " ";
- }
- // put together the display.
+ // ok. we have to do this because click events seem to be cumulative with jquery.
+ var t = $("
" + trans + " (" + r.sn + ") - " + pron + " - " + title + " - " + desc + "
" + rtxt + crtxt + "");
- // ok. we have to do this because click events seem to be cumulative with jquery.
- var t = $("
" + trans + " (" + r.sn + ") - " + pron + " - " + title + " - " + desc + "
" + rtxt + crtxt + "");
+ t.find(".link").click(function(e) {
+ Util.HandleLink(e);
+ });
+ t.find(".removeresult").click(function(e) {
+ Util.RemoveResult(e);
+ });
- t.find(".link").click(function(e) {
- Util.HandleLink(e);
- });
- t.find(".removeresult").click(function(e) {
- Util.RemoveResult(e);
- });
+ t.find(".showhide").click(function(e) {
+ Strongs.ShowHide(e);
+ });
- t.find(".showhide").click(function(e) {
- Strongs.ShowHide(e);
- });
+ return t;
+ } catch (err) {
+ Util.HandleError(err);
+ }
+ return null;
+ },
+ DisplayStrongs: function(r) {
+ try {
+ var t = Strongs.BuildStrongs(r);
- return t;
- } catch (err) {
- Util.HandleError(err);
- }
- return null;
- },
- DisplayStrongs: function(r) {
- try {
- var t = Strongs.BuildStrongs(r);
+ $("#result").prepend(t);
+ return false;
+ } catch (err) {
+ Util.HandleError(err);
+ }
+ return null;
+ },
+ DisplayStrongsDialog: function(r) {
+ try {
+ var t = Strongs.BuildStrongs(r);
+ var d = $("
").append(t);
+ d.dialog({
+ draggable:true,
+ width: 600,
+ height: 500,
+ resizable: true,
+ title: "Strongs Definition"
+ // TODO(walljm): Figure out why this break stuff.
+ //buttons: {
+ // "Close": function() {
+ // $( this ).dialog( "close" );
+ // }
+ //}
+ });
+ return false;
+ } catch (err) {
+ Util.HandleError(err);
+ }
+ return null;
+ },
+ ShowHide: function(e) {
+ var o = $(e.target);
+ var c = o.parent().find(".contents");
- $("#result").prepend(t);
- return false;
- } catch (err) {
- Util.HandleError(err);
- }
- return null;
- },
- DisplayStrongsDialog: function(r) {
- try {
- var t = Strongs.BuildStrongs(r);
- var d = $("
").append(t);
- d.dialog({
- draggable:true,
- width: 600,
- height: 500,
- resizable: true,
- title: "Strongs Definition"
- // TODO(walljm): Figure out why this break stuff.
- //buttons: {
- // "Close": function() {
- // $( this ).dialog( "close" );
- // }
- //}
- });
- return false;
- } catch (err) {
- Util.HandleError(err);
- }
- return null;
- },
- ShowHide: function(e) {
- var o = $(e.target);
- var c = o.parent().find(".contents");
+ if (c.css("display") != "none") {
+ c.css("display", "none");
+ o.html("Show");
+ } else {
+ c.css("display", "inline");
+ o.html("Hide");
+ }
+ }
+ };
+ var Words = {
+ ConvertResultsToArray: function(r) {
+ try {
+ var results = new Array();
+ $(r).each(function() {
+ results.push([$(this).attr("b"), $(this).attr("ch"), $(this).attr("v")]);
+ });
+ return results;
+ } catch (err) {
+ Util.HandleError(err);
+ }
+ return null;
+ },
+ DisplayResults: function(results, q) {
+ try {
+ var txt = "
";
- if (c.css("display") != "none") {
- c.css("display", "none");
- o.html("Show");
- } else {
- c.css("display", "inline");
- o.html("Hide");
- }
- }
- };
- var Words = {
- ConvertResultsToArray: function(r) {
- try {
- var results = new Array();
- $(r).each(function() {
- results.push([$(this).attr("b"), $(this).attr("ch"), $(this).attr("v")]);
- });
- return results;
- } catch (err) {
- Util.HandleError(err);
- }
- return null;
- },
- DisplayResults: function(results, q) {
- try {
- var txt = "
";
+ var t = $(txt);
- var t = $(txt);
+ t.find(".link").click(function(e) {
+ Util.HandleLink(e);
+ });
- t.find(".link").click(function(e) {
- Util.HandleLink(e);
- });
+ $("#searchresults").html(t);
+ $("#searchTotal").html(results.length);
+ return false;
+ } catch (err) {
+ Util.HandleError(err);
+ }
+ return null;
+ },
+ FindReferences: function(qry) {
+ try {
+ qry = qry.toLowerCase();
+ var qs = qry.split(" ");
+ var words = this.BuildIndexArray().sort();
+ var results = new Array();
- $("#searchresults").html(t);
- $("#searchTotal").html(results.length);
- return false;
- } catch (err) {
- Util.HandleError(err);
- }
- return null;
- },
- FindReferences: function(qry) {
- try {
- qry = qry.toLowerCase();
- var qs = qry.split(" ");
- var words = this.BuildIndexArray().sort();
- var results = new Array();
+ // Loop through each query term.
+ for (i = 0; i < qs.length; i++) {
+ var q = qs[i].replace("'", ""); // we don't included ticks in our words.
- // Loop through each query term.
- for (i = 0; i < qs.length; i++) {
- var q = qs[i].replace("'", ""); // we don't included ticks in our words.
+ // For each query term, figure out which xml file it is in, and get it.
+ // getSearchRefs returns an array of references.
+ for (var w = 0; w < words.length; w++) {
+ // If we are at the end of the array, we want to use a different test.
+ if (w == 0) {
+ if (q <= words[w]) {
+ results.unshift(this.GetSearchReferences("index/" + words[w] + "idx.json", q));
+ break;
+ }
+ } else {
+ if (q <= words[w] && q > words[w - 1]) {
+ results.unshift(this.GetSearchReferences("index/" + words[w] + "idx.json", q));
+ break;
+ }
+ }
+ }
+ } // End of loop through query terms
- // For each query term, figure out which xml file it is in, and get it.
- // getSearchRefs returns an array of references.
- for (var w = 0; w < words.length; w++) {
- // If we are at the end of the array, we want to use a different test.
- if (w == 0) {
- if (q <= words[w]) {
- results.unshift(this.GetSearchReferences("index/" + words[w] + "idx.json", q));
- break;
- }
- } else {
- if (q <= words[w] && q > words[w - 1]) {
- results.unshift(this.GetSearchReferences("index/" + words[w] + "idx.json", q));
- break;
- }
- }
- }
- } // End of loop through query terms
+ // Now we need to test results. If there is more than one item in the array, we need to find the set
+ // that is shared by all of them. IF not, we can just return those refs.
+ if (results.length == 1) {
+ this.DisplayResults(results[0], qry);
+ } else {
+ var shared = this.FindSharedSet(results);
+ if (shared == null) {
+ shared = [];
+ }
+ this.DisplayResults(shared, qry);
+ }
- // Now we need to test results. If there is more than one item in the array, we need to find the set
- // that is shared by all of them. IF not, we can just return those refs.
- if (results.length == 1) {
- this.DisplayResults(results[0], qry);
- } else {
- var shared = this.FindSharedSet(results);
- if (shared == null) {
- shared = [];
- }
- this.DisplayResults(shared, qry);
- }
+ return false;
- return false;
+ } catch (err) {
+ Util.HandleError(err);
+ }
+ return null;
+ },
+ GetSearchReferences: function(url, query) {
+ try {
+ // getSearchRefs takes a url and uses ajax to retrieve the references and returns an array of references.
+ var r;
- } catch (err) {
- Util.HandleError(err);
- }
- return null;
- },
- GetSearchReferences: function(url, query) {
- try {
- // getSearchRefs takes a url and uses ajax to retrieve the references and returns an array of references.
- var r;
+ $.ajax({
+ async: false,
+ type: "GET",
+ url: url,
+ dataType: "json",
+ success: function(d, t, x) {
+ r = d;
+ },
+ error: function(request, status, error) {
+ Util.HandleError(error, request);
+ }
+ });
- $.ajax({
- async: false,
- type: "GET",
- url: url,
- dataType: "json",
- success: function(d, t, x) {
- r = d;
- },
- error: function(request, status, error) {
- Util.HandleError(error, request);
- }
- });
+ // find the right word
+ var refs = $.grep(r, function(o,i) {
+ return o.word == query;
+ });
+ if (refs.length > 0) {
+ return refs[0].refs;
+ } else {
+ return null;
+ }
+ } catch (err) {
+ Util.HandleError(err);
+ }
+ return null;
+ },
+ BuildIndexArray: function() {
+ var words = new Array();
+ words.unshift('abiram');
+ words.unshift('accepteth');
+ words.unshift('acquit');
+ words.unshift('adna');
+ words.unshift('affecteth');
+ words.unshift('aharhel');
+ words.unshift('aijeleth');
+ words.unshift('almug');
+ words.unshift('amiable');
+ words.unshift('ancients');
+ words.unshift('anything');
+ words.unshift('appointeth');
+ words.unshift('areopagus');
+ words.unshift('art');
+ words.unshift('ashteroth');
+ words.unshift('astaroth');
+ words.unshift('availeth');
+ words.unshift('azotus');
+ words.unshift('badness');
+ words.unshift('baptizing');
+ words.unshift('bat');
+ words.unshift('bechorath');
+ words.unshift('beguile');
+ words.unshift('bemoaning');
+ words.unshift('beside');
+ words.unshift('bezek');
+ words.unshift('bitterly');
+ words.unshift('bloodthirsty');
+ words.unshift('bolted');
+ words.unshift('bountifulness');
+ words.unshift('breastplates');
+ words.unshift('broth');
+ words.unshift('bunni');
+ words.unshift('cain');
+ words.unshift('cankered');
+ words.unshift('carry');
+ words.unshift('celebrate');
+ words.unshift('chapel');
+ words.unshift('cheese');
+ words.unshift('chilmad');
+ words.unshift('circumcision');
+ words.unshift('closer');
+ words.unshift('come');
+ words.unshift('communication');
+ words.unshift('concerning');
+ words.unshift('confusion');
+ words.unshift('consummation');
+ words.unshift('convince');
+ words.unshift('couch');
+ words.unshift('covers');
+ words.unshift('crisping');
+ words.unshift('curse');
+ words.unshift('damnable');
+ words.unshift('deacons');
+ words.unshift('decision');
+ words.unshift('defileth');
+ words.unshift('depart');
+ words.unshift('despisest');
+ words.unshift('diblathaim');
+ words.unshift('directly');
+ words.unshift('dishonesty');
+ words.unshift('distracted');
+ words.unshift('dominion');
+ words.unshift('dreamer');
+ words.unshift('dulcimer');
+ words.unshift('eastward');
+ words.unshift('eighteenth');
+ words.unshift('elihoreph');
+ words.unshift('embrace');
+ words.unshift('endeavored');
+ words.unshift('ensign');
+ words.unshift('ephraim');
+ words.unshift('eshtemoa');
+ words.unshift('evening');
+ words.unshift('excellest');
+ words.unshift('extended');
+ words.unshift('fairer');
+ words.unshift('fastings');
+ words.unshift('feign');
+ words.unshift('fight');
+ words.unshift('fishermen');
+ words.unshift('flint');
+ words.unshift('foolishness');
+ words.unshift('forever');
+ words.unshift('forts');
+ words.unshift('fresh');
+ words.unshift('furnish');
+ words.unshift('gallio');
+ words.unshift('gebal');
+ words.unshift('gezrites');
+ words.unshift('girt');
+ words.unshift('goath');
+ words.unshift('government');
+ words.unshift('greeteth');
+ words.unshift('guiltless');
+ words.unshift('haggai');
+ words.unshift('hamstrung');
+ words.unshift('happy');
+ words.unshift('harum');
+ words.unshift('hattush');
+ words.unshift('heard');
+ words.unshift('heir');
+ words.unshift('herbs');
+ words.unshift('hezronites');
+ words.unshift('hivite');
+ words.unshift('honored');
+ words.unshift('hostages');
+ words.unshift('huntest');
+ words.unshift('idalah');
+ words.unshift('impenitent');
+ words.unshift('inferior');
+ words.unshift('insomuch');
+ words.unshift('ira');
+ words.unshift('isuah');
+ words.unshift('jabneh');
+ words.unshift('japhia');
+ words.unshift('jeduthun');
+ words.unshift('jerahmeelites');
+ words.unshift('jew');
+ words.unshift('joined');
+ words.unshift('joy');
+ words.unshift('kadmonites');
+ words.unshift('kid');
+ words.unshift('kneaded');
+ words.unshift('lack');
+ words.unshift('languish');
+ words.unshift('lazarus');
+ words.unshift('legions');
+ words.unshift('libnath');
+ words.unshift('likhi');
+ words.unshift('lock');
+ words.unshift('louder');
+ words.unshift('lysias');
+ words.unshift('magpiash');
+ words.unshift('malchus');
+ words.unshift('marble');
+ words.unshift('mastery');
+ words.unshift('meddle');
+ words.unshift('members');
+ words.unshift('mesech');
+ words.unshift('midian');
+ words.unshift('ministered');
+ words.unshift('mithnite');
+ words.unshift('morasthite');
+ words.unshift('mower');
+ words.unshift('myrtle');
+ words.unshift('naphish');
+ words.unshift('necks');
+ words.unshift('net');
+ words.unshift('noadiah');
+ words.unshift('nursed');
+ words.unshift('occurrent');
+ words.unshift('omnipotent');
+ words.unshift('orchard');
+ words.unshift('outside');
+ words.unshift('owed');
+ words.unshift('palti');
+ words.unshift('partition');
+ words.unshift('paulus');
+ words.unshift('peoples');
+ words.unshift('persecute');
+ words.unshift('phares');
+ words.unshift('pilate');
+ words.unshift('plagues');
+ words.unshift('plentiful');
+ words.unshift('poorer');
+ words.unshift('powerful');
+ words.unshift('presented');
+ words.unshift('prison');
+ words.unshift('promoted');
+ words.unshift('provision');
+ words.unshift('purely');
+ words.unshift('quarter');
+ words.unshift('rahab');
+ words.unshift('ravening');
+ words.unshift('rebuking');
+ words.unshift('refined');
+ words.unshift('release');
+ words.unshift('rent');
+ words.unshift('requirest');
+ words.unshift('return');
+ words.unshift('rezon');
+ words.unshift('riseth');
+ words.unshift('roof');
+ words.unshift('rump');
+ words.unshift('sail');
+ words.unshift('sanctuaries');
+ words.unshift('savors');
+ words.unshift('scorpions');
+ words.unshift('second');
+ words.unshift('sellers');
+ words.unshift('served');
+ words.unshift('shaft');
+ words.unshift('sharaim');
+ words.unshift('shedder');
+ words.unshift('shepho');
+ words.unshift('shimshai');
+ words.unshift('shophan');
+ words.unshift('shuppim');
+ words.unshift('sihor');
+ words.unshift('sippai');
+ words.unshift('slandereth');
+ words.unshift('smelling');
+ words.unshift('softer');
+ words.unshift('sores');
+ words.unshift('sparrows');
+ words.unshift('spoil');
+ words.unshift('staff');
+ words.unshift('steel');
+ words.unshift('stool');
+ words.unshift('stretched');
+ words.unshift('stumblingblocks');
+ words.unshift('suffice');
+ words.unshift('surnamed');
+ words.unshift('swore');
+ words.unshift('take');
+ words.unshift('task');
+ words.unshift('temani');
+ words.unshift('testator');
+ words.unshift('thessalonica');
+ words.unshift('threatening');
+ words.unshift('tie');
+ words.unshift('titus');
+ words.unshift('torments');
+ words.unshift('translation');
+ words.unshift('tributaries');
+ words.unshift('tubal');
+ words.unshift('unchangeable');
+ words.unshift('unlawful');
+ words.unshift('upbraideth');
+ words.unshift('uzza');
+ words.unshift('verily');
+ words.unshift('visage');
+ words.unshift('walk');
+ words.unshift('washing');
+ words.unshift('wayside');
+ words.unshift('wellspring');
+ words.unshift('whisperer');
+ words.unshift('win');
+ words.unshift('withereth');
+ words.unshift('work');
+ words.unshift('wrest');
+ words.unshift('yours');
+ words.unshift('zealously');
+ words.unshift('zetham');
+ words.unshift('zophim');
+ words.unshift('zuzims');
+ return words;
+ },
+ FindSharedSet: function(results) {
+ try {
+ // FindSharedSet takes an array of reference arrays, and figures out which references are shared
+ // by all arrays/sets, then returns a single array of references.
- // find the right word
- var refs = $.grep(r, function(o,i) {
- return o.word == query;
- });
- if (refs.length > 0) {
- return refs[0].refs;
- } else {
- return null;
- }
- } catch (err) {
- Util.HandleError(err);
- }
- return null;
- },
- BuildIndexArray: function() {
- var words = new Array();
- words.unshift('abiram');
- words.unshift('accepteth');
- words.unshift('acquit');
- words.unshift('adna');
- words.unshift('affecteth');
- words.unshift('aharhel');
- words.unshift('aijeleth');
- words.unshift('almug');
- words.unshift('amiable');
- words.unshift('ancients');
- words.unshift('anything');
- words.unshift('appointeth');
- words.unshift('areopagus');
- words.unshift('art');
- words.unshift('ashteroth');
- words.unshift('astaroth');
- words.unshift('availeth');
- words.unshift('azotus');
- words.unshift('badness');
- words.unshift('baptizing');
- words.unshift('bat');
- words.unshift('bechorath');
- words.unshift('beguile');
- words.unshift('bemoaning');
- words.unshift('beside');
- words.unshift('bezek');
- words.unshift('bitterly');
- words.unshift('bloodthirsty');
- words.unshift('bolted');
- words.unshift('bountifulness');
- words.unshift('breastplates');
- words.unshift('broth');
- words.unshift('bunni');
- words.unshift('cain');
- words.unshift('cankered');
- words.unshift('carry');
- words.unshift('celebrate');
- words.unshift('chapel');
- words.unshift('cheese');
- words.unshift('chilmad');
- words.unshift('circumcision');
- words.unshift('closer');
- words.unshift('come');
- words.unshift('communication');
- words.unshift('concerning');
- words.unshift('confusion');
- words.unshift('consummation');
- words.unshift('convince');
- words.unshift('couch');
- words.unshift('covers');
- words.unshift('crisping');
- words.unshift('curse');
- words.unshift('damnable');
- words.unshift('deacons');
- words.unshift('decision');
- words.unshift('defileth');
- words.unshift('depart');
- words.unshift('despisest');
- words.unshift('diblathaim');
- words.unshift('directly');
- words.unshift('dishonesty');
- words.unshift('distracted');
- words.unshift('dominion');
- words.unshift('dreamer');
- words.unshift('dulcimer');
- words.unshift('eastward');
- words.unshift('eighteenth');
- words.unshift('elihoreph');
- words.unshift('embrace');
- words.unshift('endeavored');
- words.unshift('ensign');
- words.unshift('ephraim');
- words.unshift('eshtemoa');
- words.unshift('evening');
- words.unshift('excellest');
- words.unshift('extended');
- words.unshift('fairer');
- words.unshift('fastings');
- words.unshift('feign');
- words.unshift('fight');
- words.unshift('fishermen');
- words.unshift('flint');
- words.unshift('foolishness');
- words.unshift('forever');
- words.unshift('forts');
- words.unshift('fresh');
- words.unshift('furnish');
- words.unshift('gallio');
- words.unshift('gebal');
- words.unshift('gezrites');
- words.unshift('girt');
- words.unshift('goath');
- words.unshift('government');
- words.unshift('greeteth');
- words.unshift('guiltless');
- words.unshift('haggai');
- words.unshift('hamstrung');
- words.unshift('happy');
- words.unshift('harum');
- words.unshift('hattush');
- words.unshift('heard');
- words.unshift('heir');
- words.unshift('herbs');
- words.unshift('hezronites');
- words.unshift('hivite');
- words.unshift('honored');
- words.unshift('hostages');
- words.unshift('huntest');
- words.unshift('idalah');
- words.unshift('impenitent');
- words.unshift('inferior');
- words.unshift('insomuch');
- words.unshift('ira');
- words.unshift('isuah');
- words.unshift('jabneh');
- words.unshift('japhia');
- words.unshift('jeduthun');
- words.unshift('jerahmeelites');
- words.unshift('jew');
- words.unshift('joined');
- words.unshift('joy');
- words.unshift('kadmonites');
- words.unshift('kid');
- words.unshift('kneaded');
- words.unshift('lack');
- words.unshift('languish');
- words.unshift('lazarus');
- words.unshift('legions');
- words.unshift('libnath');
- words.unshift('likhi');
- words.unshift('lock');
- words.unshift('louder');
- words.unshift('lysias');
- words.unshift('magpiash');
- words.unshift('malchus');
- words.unshift('marble');
- words.unshift('mastery');
- words.unshift('meddle');
- words.unshift('members');
- words.unshift('mesech');
- words.unshift('midian');
- words.unshift('ministered');
- words.unshift('mithnite');
- words.unshift('morasthite');
- words.unshift('mower');
- words.unshift('myrtle');
- words.unshift('naphish');
- words.unshift('necks');
- words.unshift('net');
- words.unshift('noadiah');
- words.unshift('nursed');
- words.unshift('occurrent');
- words.unshift('omnipotent');
- words.unshift('orchard');
- words.unshift('outside');
- words.unshift('owed');
- words.unshift('palti');
- words.unshift('partition');
- words.unshift('paulus');
- words.unshift('peoples');
- words.unshift('persecute');
- words.unshift('phares');
- words.unshift('pilate');
- words.unshift('plagues');
- words.unshift('plentiful');
- words.unshift('poorer');
- words.unshift('powerful');
- words.unshift('presented');
- words.unshift('prison');
- words.unshift('promoted');
- words.unshift('provision');
- words.unshift('purely');
- words.unshift('quarter');
- words.unshift('rahab');
- words.unshift('ravening');
- words.unshift('rebuking');
- words.unshift('refined');
- words.unshift('release');
- words.unshift('rent');
- words.unshift('requirest');
- words.unshift('return');
- words.unshift('rezon');
- words.unshift('riseth');
- words.unshift('roof');
- words.unshift('rump');
- words.unshift('sail');
- words.unshift('sanctuaries');
- words.unshift('savors');
- words.unshift('scorpions');
- words.unshift('second');
- words.unshift('sellers');
- words.unshift('served');
- words.unshift('shaft');
- words.unshift('sharaim');
- words.unshift('shedder');
- words.unshift('shepho');
- words.unshift('shimshai');
- words.unshift('shophan');
- words.unshift('shuppim');
- words.unshift('sihor');
- words.unshift('sippai');
- words.unshift('slandereth');
- words.unshift('smelling');
- words.unshift('softer');
- words.unshift('sores');
- words.unshift('sparrows');
- words.unshift('spoil');
- words.unshift('staff');
- words.unshift('steel');
- words.unshift('stool');
- words.unshift('stretched');
- words.unshift('stumblingblocks');
- words.unshift('suffice');
- words.unshift('surnamed');
- words.unshift('swore');
- words.unshift('take');
- words.unshift('task');
- words.unshift('temani');
- words.unshift('testator');
- words.unshift('thessalonica');
- words.unshift('threatening');
- words.unshift('tie');
- words.unshift('titus');
- words.unshift('torments');
- words.unshift('translation');
- words.unshift('tributaries');
- words.unshift('tubal');
- words.unshift('unchangeable');
- words.unshift('unlawful');
- words.unshift('upbraideth');
- words.unshift('uzza');
- words.unshift('verily');
- words.unshift('visage');
- words.unshift('walk');
- words.unshift('washing');
- words.unshift('wayside');
- words.unshift('wellspring');
- words.unshift('whisperer');
- words.unshift('win');
- words.unshift('withereth');
- words.unshift('work');
- words.unshift('wrest');
- words.unshift('yours');
- words.unshift('zealously');
- words.unshift('zetham');
- words.unshift('zophim');
- words.unshift('zuzims');
- return words;
- },
- FindSharedSet: function(results) {
- try {
- // FindSharedSet takes an array of reference arrays, and figures out which references are shared
- // by all arrays/sets, then returns a single array of references.
+ for (var j in results) {
+ var refs = results[j];
+ if (refs != null) {
+ for (var i = 0; i < refs.length; i++) {
+ var r = refs[i].split(":");
+ // convert references to single integers.
+ // Book * 100000, Chapter * 1000, Verse remains same, add all together.
+ var ref = parseInt(r[0]) * 100000000;
+ ref = ref + parseInt(r[1]) * 10000;
+ ref = ref + parseInt(r[2]);
+ results[j][i] = ref;
+ }
+ } else {
+ return null;
+ }
+ }
- for (var j in results) {
- var refs = results[j];
- if (refs != null) {
- for (var i = 0; i < refs.length; i++) {
- var r = refs[i].split(":");
- // convert references to single integers.
- // Book * 100000, Chapter * 1000, Verse remains same, add all together.
- var ref = parseInt(r[0]) * 100000000;
- ref = ref + parseInt(r[1]) * 10000;
- ref = ref + parseInt(r[2]);
- results[j][i] = ref;
- }
- } else {
- return null;
- }
- }
+ // get the first result
+ var result = results[0];
- // get the first result
- var result = results[0];
+ // for each additional result, get the shared set
+ for (i = 1; i < results.length; i++) {
+ result = this.ReturnSharedSet(results[i], result);
+ }
- // for each additional result, get the shared set
- for (i = 1; i < results.length; i++) {
- result = this.ReturnSharedSet(results[i], result);
- }
+ // convert the references back into book, chapter and verse.
+ for (i = 0; i < result.length; i++) {
+ ref = result[i];
+ result[i] = parseInt(ref / 100000000)+":"+parseInt((ref % 100000000) / 10000)+":"+((ref % 100000000) % 10000);
+ }
- // convert the references back into book, chapter and verse.
- for (i = 0; i < result.length; i++) {
- ref = result[i];
- result[i] = parseInt(ref / 100000000)+":"+parseInt((ref % 100000000) / 10000)+":"+((ref % 100000000) % 10000);
- }
-
- return result;
- } catch (err) {
- Util.HandleError(err);
- }
- return null;
- },
- ReturnSharedSet: function(x, y) {
- try {
- ///
- /// Takes two javascript arrays and returns an array
- /// containing a set of values shared by arrays.
- ///
- // declare iterator
- var i = 0;
- // declare terminator
- var t = (x.length < y.length) ? x.length : y.length;
- // sort the arrays
- x.sort(SortNumeric);
- y.sort(SortNumeric);
- // in this loop, we remove from the arrays, the
- // values that aren't shared between them.
- while (i < t) {
- if (x[i] == y[i]) {
- i++;
- }
- if (x[i] < y[i]) {
- x.splice(i, 1);
- }
- if (x[i] > y[i]) {
- y.splice(i, 1);
- }
- t = (x.length < y.length) ? x.length : y.length;
- // we have to make sure to remove any extra values
- // at the end of an array when we reach the end of
- // the other.
- if (t == i && t < x.length) {
- x.splice(i, x.length - i);
- }
- if (t == i && t < y.length) {
- y.splice(i, x.length - i);
- }
- }
- // we could return y, because at this time, both arrays
- // are identical.
- return x;
- } catch (err) {
- Util.HandleError(err);
- }
- return null;
- }
- };
- return {
- Traverse: Traverse,
- Search: Search,
- Settings: Settings,
- Util: Util,
- Bible: Bible,
- Strongs: Strongs,
- Words: Words
- };
- }
- );
+ return result;
+ } catch (err) {
+ Util.HandleError(err);
+ }
+ return null;
+ },
+ ReturnSharedSet: function(x, y) {
+ try {
+ ///
+ /// Takes two javascript arrays and returns an array
+ /// containing a set of values shared by arrays.
+ ///
+ // declare iterator
+ var i = 0;
+ // declare terminator
+ var t = (x.length < y.length) ? x.length : y.length;
+ // sort the arrays
+ x.sort(SortNumeric);
+ y.sort(SortNumeric);
+ // in this loop, we remove from the arrays, the
+ // values that aren't shared between them.
+ while (i < t) {
+ if (x[i] == y[i]) {
+ i++;
+ }
+ if (x[i] < y[i]) {
+ x.splice(i, 1);
+ }
+ if (x[i] > y[i]) {
+ y.splice(i, 1);
+ }
+ t = (x.length < y.length) ? x.length : y.length;
+ // we have to make sure to remove any extra values
+ // at the end of an array when we reach the end of
+ // the other.
+ if (t == i && t < x.length) {
+ x.splice(i, x.length - i);
+ }
+ if (t == i && t < y.length) {
+ y.splice(i, x.length - i);
+ }
+ }
+ // we could return y, because at this time, both arrays
+ // are identical.
+ return x;
+ } catch (err) {
+ Util.HandleError(err);
+ }
+ return null;
+ }
+ };
+ return {
+ Traverse: Traverse,
+ Search: Search,
+ Settings: Settings,
+ Util: Util,
+ Bible: Bible,
+ Strongs: Strongs,
+ Words: Words
+ };
+ }
+ );
diff --git a/js/main.js b/js/main.js
index 7ef593bc..4555a4ac 100644
--- a/js/main.js
+++ b/js/main.js
@@ -1,5 +1,5 @@
require(["jquery", "db", "common", "reference", "jquery.cookie", "jquery.ui"],
- function($, db, common, ref) {
+ function($, db, common, ref) {
$(document).ready(function()
{
$("#searchform").submit(function()
@@ -22,9 +22,14 @@ require(["jquery", "db", "common", "reference", "jquery.cookie", "jquery.ui"],
common.Settings.SwitchPanes();
return false;
});
- $("#showhelp").click(function()
+ $("#showhelp").click(function()
{
- $("#help").dialog({draggable:true, width: 700, height: 650, resizable: true});
+ $("#help").dialog({
+ draggable:true,
+ width: 700,
+ height: 650,
+ resizable: true
+ });
});
$("#showhidesearch").click(function()
{
@@ -48,7 +53,21 @@ require(["jquery", "db", "common", "reference", "jquery.cookie", "jquery.ui"],
handle: ".p-handle"
});
- // remember the settings...
- common.Settings.Load();
+ // load querystring
+ var ref = decodeURIComponent(common.Util.GetUrlVars().r);
+ if (ref !== "undefined") {
+ // remember the settings, first, because if you have results, the load process would wipe out the passage you want to load.
+ common.Settings.Load();
+
+ // now load the passage from the querystring.
+ common.Search(ref);
+ $("#searchvalue").val(ref);
+ } else {
+ common.Settings.Load();
+ }
+
+
+
+
});
-});
+ });