Author: marcus
Date: Wed Sep 24 21:20:33 2014
New Revision: 1627422

URL: http://svn.apache.org/r1627422
Log:
Updates

Modified:
    openoffice/ooo-site/trunk/content/download/download_url.js

Modified: openoffice/ooo-site/trunk/content/download/download_url.js
URL: 
http://svn.apache.org/viewvc/openoffice/ooo-site/trunk/content/download/download_url.js?rev=1627422&r1=1627421&r2=1627422&view=diff
==============================================================================
--- openoffice/ooo-site/trunk/content/download/download_url.js (original)
+++ openoffice/ooo-site/trunk/content/download/download_url.js Wed Sep 24 
21:20:33 2014
@@ -39,7 +39,10 @@ DL.init = function( release_mode ) {
        DL.initVariables( 1 );
 
        // Parse the browser URL for an ISO code as language.
-       DL.getURLQuery();
+       var query = DL.getURLQuery();
+       if ( query ) {
+               DL.URL_LANG = query;
+       }
 
        // Fill the OS, language and version select boxes.
        DL.fillOSSelection();
@@ -67,12 +70,19 @@ DL.init = function( release_mode ) {
 }
 
 /*
- * Get the URL parameter from browser to assign as ISO code language
+ * Get the value from an browser URL query
  * @param:  None
- * @return: None
+ * @return: q_value - The value from the browser URL query 
  */
 DL.getURLQuery = function() {
-       // Parse the URL if an ISO code for a language is set that should be 
used.
+       // Parse the URL for a query if it contains a value that should be used 
as an language ISO code.
+
+       // Does the browser URL contain a query with "?" and "=" characters at 
all?
+       if( decodeURI( window.location ).indexOf( "?" ) == -1 &&
+           decodeURI( window.location ).indexOf( "=" ) == -1 ) {
+               // If not return an empty string and exit.
+               return "";
+       }
 
        var query               = new Object();
        var q_pair              = window.location.search.substring( 1 ).split( 
"?" );
@@ -80,28 +90,29 @@ DL.getURLQuery = function() {
        var q_name, q_value     = "";
 
        for ( var i = 0; i < q_pair.length; i++ ) {
+               // Assign the position of the "=" character, so where the name 
ends and the value starts.
                position = q_pair[ i ].indexOf( "=" );
 
-               if ( position == -1 ) {
+               // If the position is not found (-1) then just go on.
+               if ( position === -1 ) {
                        continue;
                }
 
+               // Assign the name of the query pair.
                q_name          = q_pair[ i ].substring( 0, position );
+               // Assign the value of the query pair.
                q_value         = q_pair[ i ].substring( position + 1 );
                query[ q_name ] = decodeURI( q_value );
        }
-
+/*
        alert( ""
        + "Query pair: "  + "\t" + q_pair  + "\n"
        + "Query name: "  + "\t" + q_name  + "\n"
        + "Query value: " + "\t" + q_value + "\n"
        + "" );
-
-       if ( query[ q_name ] ) {
-               DL.URL_LANG = query[ q_name ];
-       }
-
-       return;
+*/
+       // Return the query value.
+       return q_value;
 }
 
 /*
@@ -126,8 +137,9 @@ DL.initVariables = function( init_all ) 
 
        // The following are used in "download.js" only.
 
-       // All global variables.
+       // Initialize global variables.
        if( init_all === 1 ) {
+               // Use all global variables.
                DL.RELEASE_MODE         = 1;     // The release mode (1 = 
stable release (default), 2 = beta release, etc.).
                DL.URL_LANG             = "";    // The language as ISO code as 
parameter in the browser URL.
                DL.LANG_ISO             = "";    // The language as ISO code.


Reply via email to