Author: marcus
Date: Mon Jun 16 19:56:19 2014
New Revision: 1602981

URL: http://svn.apache.org/r1602981
Log:
Re-worked the error variables, created new function to check first on problems 
for download links

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

Modified: openoffice/ooo-site/trunk/content/download/download.js
URL: 
http://svn.apache.org/viewvc/openoffice/ooo-site/trunk/content/download/download.js?rev=1602981&r1=1602980&r2=1602981&view=diff
==============================================================================
--- openoffice/ooo-site/trunk/content/download/download.js (original)
+++ openoffice/ooo-site/trunk/content/download/download.js Mon Jun 16 19:56:19 
2014
@@ -17,7 +17,7 @@
  * function showWindow         ( target_url )
  * function showErrorMessage   ( error_text )
  * function isLangSupported    ()
- * function getLink            ( rel_mode )
+ * function checkLinkExceptions ()
  * function getLinkSel         ()
  * function getPlatform                ()
  * function getReleaseMatrixPos        ()
@@ -29,7 +29,7 @@
 /*
  * Init function
  */
-function init( a ) {
+function init( mode ) {
        // Set global variables.
        initVars( 1 );
 
@@ -48,8 +48,10 @@ function init( a ) {
        setVerSel();
 
        
-       // Get release mode and analyze mode from "index.html" respective 
"analyze.html".
-       R_MODE = a;
+       // When release mode = 2, it is a beta release. Otherwise assume 
"stable release" as default.
+       if( mode === 2 )
+               R_MODE = mode;
+
        getLinkSel();
 
        return;
@@ -61,22 +63,26 @@ function init( a ) {
 function initVars( init_all ) {
        // Define variables without "var" to make them globally available.
 
-       // The following are used in "download.js" only.
+       // The following are used in "download.js". and "index.html".
+
+       // All elements with ID in the sub-green box.
        element_ids_sub_green = [ "dl_rel_info", "dl_rel_notes", "dl_f_info", 
"dl_f_chk_keys", "space1", "dl_f_chk_asc",
        "space2", "dl_f_chk_md5", "space3", "dl_f_chk_sha256", "dl_lp_info", 
"dl_lp_chk_keys", "space4", "dl_lp_chk_asc",
        "space5", "dl_lp_chk_md5", "space6", "dl_lp_chk_sha256", "dl_hlp_img", 
"dl_hlp", "dl_chk_img", "dl_chk",
        "dl_rpt_img", "dl_rpt" ];
 
+       // All elements with ID in the green and sub-green box that have a link.
        element_ids_links = [ "dl_f_link", "dl_lp_link", "dl_f_chk_keys", 
"dl_f_chk_asc", "dl_f_chk_md5", "dl_f_chk_sha256",
        "dl_lp_chk_keys", "dl_lp_chk_asc", "dl_lp_chk_md5", "dl_lp_chk_sha256", 
"dl_hlp", "dl_chk", "dl_rpt" ];
 
-       // The following are used in "download.js". and "index.html".
+       // The following are used in "download.js" only.
+
+       // All global variables.
        if( init_all === 1 ) {
-               R_MODE                          = "";    // The release mode (1 
= stable release (default), 2 = beta release, etc.).
+               R_MODE                          = 1;     // The release mode (1 
= stable release (default), 2 = beta release, etc.).
                LANG_ISO                        = "";    // The language as ISO 
code.
                LANG_SEL                        = "";    // The selected 
language as ISO code from select box.
                UI_PLATFORM_NO_SUP              = "";    // The platform as 
readable string, if not supported.
-               OLD_PLATFORM                    = false; // Is the browser 
platform old (true) or not (false)?
                PLATFORM_SEL                    = "";    // The selected 
platform from select box.
                VERSION_SEL                     = "";    // The selected 
version from select box.
        }
@@ -90,7 +96,7 @@ function initVars( init_all ) {
        RELEASE_PLATFORM                        = "";    // The platform in the 
release matrix array.
        RELEASE_LANG                            = "";    // The language 
specific data depending on LANG_ISO.
        REL_TEXT                                = "";    // The release data 
(milestone, build ID, svn rev, release date).
-       REL_NOTES                               = "";    // The complete URL 
for the release notes.
+       REL_NOTES                               = "";    // The complete URL 
for the release notes (depends on version).
        FILENAME_FULL                           = "";    // The complete 
filename of the download URL (full install).
        FILENAME_LP                             = "";    // The complete 
filename of the download URL (langpack).
        FILESIZE_FULL                           = -1;    // The filesize of the 
download file (full install).
@@ -110,10 +116,8 @@ function initVars( init_all ) {
        LINK_CHK_ASC_LP                         = "";    // The ASC file as 
download URL (langpack).
        LINK_CHK_MD5_LP                         = "";    // The MD5 file as 
download URL (langpack).
        LINK_CHK_SHA256_LP                      = "";    // The SHA256 file as 
download URL (langpack).
-       SF                                      = false; // Does the download 
URL points to Soureforge?
-       OTHER                                   = false; // Does the download 
URL points to the porting webpage?
-       ARCHIVE                                 = false; // Does the download 
URL points to the ASF archive?
-       ERROR                                   = true;  // Is the download URL 
in general correct (false) or not (true)?
+       SUPPORTED                               = false; // Are the selected 
options supported in general (true) or not (false)?
+       ERROR                                   = false; // Is the download URL 
in general correct (true) or not (false)?
 
        return;
 }
@@ -479,8 +483,6 @@ function showErrorMessage( error_text ) 
        document.getElementById( "dl_lp_link"    ).innerHTML            = 
l10n_download_langpack_link_error_text;
        document.getElementById( "dl_lp_link"    ).title                = 
l10n_download_langpack_link_error_title;
 
-       document.getElementById( "sub_green_box" ).className            = 
"sub-green-sel_error";
-
        document.getElementById( "dl_err_img"    ).src                  = 
FILE_ERROR_IMG;
        document.getElementById( "dl_err_img"    ).title                = 
l10n_download_error_problem_img_title;
        document.getElementById( "dl_err_img"    ).alt                  = 
l10n_download_error_problem_img_alt;
@@ -490,9 +492,13 @@ function showErrorMessage( error_text ) 
        document.getElementById( "dl_err"        ).style.cursor         = 
"default";
        document.getElementById( "dl_err"        ).style.display        = 
"inline-block";
 
+       document.getElementById( "sub_green_box" ).className            = 
"sub-green-sel_error";
+       document.getElementById( "sub_green_box" ).style.display        = 
"block";
+
        // Delete previously set string to get the possibility back to choose a 
different platform
        // and then to assemble a new download link.
        UI_PLATFORM_NO_SUP = "";
+       SUPPORTED          = false;
        ERROR              = true;
        return ERROR;
 }
@@ -520,37 +526,42 @@ function isLangSupported() {
                        break;
                default:
                        RELEASE_LANG = "";
-                       ERROR = true;
+                       ERROR        = true;
        }
 
        if( RELEASE_LANG[ 3 ] === 'y' ) {
                ERROR = false;
                return true;
        } else {
-               NOT_AVAILABLE = RELEASE_LANG[ 1 ] + " is not available";
                ERROR = true;
                return false;
        }
 }
 
 /*
- * Get link to mirror system for download file and checksum file
- * Depends on chosen OS, language and type
+ * Check links that should be assembled in getLinkSel() for expections that do 
not lead to real download links
+ * Depends on chosen OS, language and version
  */
-function getLinkSel() {
-       // Reset all variables that could have been set until now.
-       initVars( 0 );
+function checkLinkExceptions() {
+       // If recognized platform is not Windows, Linux or Mac, show the 
none-availability to the user.
 
-       // If no mode was given, assume it is the release mode (stable release).
-       if( R_MODE === undefined )
-               R_MODE = 1;
+       var error_text = "";
 
-       // Get the selected data from the select boxes.
-       getOSSel();
-       getLangSel();
-       getVerSel();
+       // If language is not supported, show the none-availability to the user.
+       if( ! isLangSupported() ) {
+               // Show an error message that the chosen items do not lead to a 
download.
+               error_text = "<b>" + l10n_download_error_problem_text + "</b>" 
+ l10n_download_error_aoo_text + VERSION_SEL
+                            + l10n_download_error_not_available_for_text + 
"<b>" + RELEASE_LANG[ 1 ] + " ("
+                            + RELEASE_LANG[ 2 ] + ") (" + LANG_SEL + ")</b>."
+                            + "<br /><b>" + l10n_download_error_solution_text 
+ "</b>"
+                            + l10n_download_error_please_select_4_text;
+
+               showErrorMessage( error_text );
+       } else {
+               // If language is supported, assemble the filenames and text 
for download and checksums.
+               // Go on in "getLinkSel().
+       }
 
-       // If recognized platform is not Windows, Linux or Mac, show the 
none-availability to the user.
        if( UI_PLATFORM_NO_SUP !== "" ) {
                // Show an error message that the chosen items do not lead to a 
download.
                error_text = "<b>" + l10n_download_error_problem_text + "</b>" 
+ l10n_download_error_aoo_text + VERSION_SEL
@@ -559,7 +570,6 @@ function getLinkSel() {
                             + l10n_download_error_please_select_3_text;
 
                showErrorMessage( error_text );
-               return false;
        }
 
        // If version is '4.1.0' (or newer) and platform is 'Mac OS X <= 10.6', 
show the none-availability to the user.
@@ -571,7 +581,6 @@ function getLinkSel() {
                             + l10n_download_error_please_select_1_text;
 
                showErrorMessage( error_text );
-               return false;
        }
 
        // If version is '4.0.1' (or older) and platform is 'Mac OS X >= 10.7', 
show the none-availability to the user.
@@ -583,7 +592,6 @@ function getLinkSel() {
                             + l10n_download_error_please_select_2_text;
 
                showErrorMessage( error_text );
-               return false;
        }
 
        // If platform is 'other', create a download link that leads to the 
Porting webpage.
@@ -601,9 +609,8 @@ function getLinkSel() {
                document.getElementById( "dl_lp_link"    ).style.display = 
"none";
                document.getElementById( "sub_green_box" ).style.display = 
"none";
 
-               OTHER = true;
-               ERROR = false;
-               return LINK_FULL;
+               SUPPORTED = true;
+               ERROR     = false;
        }
 
        // If version is 'older', create a download link that leads to the 
archive webpage.
@@ -621,38 +628,39 @@ function getLinkSel() {
                document.getElementById( "dl_lp_link"    ).style.display = 
"none";
                document.getElementById( "sub_green_box" ).style.display = 
"none";
 
-               ARCHIVE = true;
-               ERROR   = false;
-               return LINK_FULL;
+               SUPPORTED = true;
+               ERROR     = false;
        }
 
-       // If language is not supported, show the none-availability to the user.
-       if( ! isLangSupported() ) {
-               if( R_MODE === 1 ) {
-                       // Release mode.
-                       // Provide the link from the Native Language (NL) group.
-                       LINK_FULL     = "http://www.openoffice.org/"; + 
RELEASE_LANG[ 4 ];
-                       LINK_LP       = LINK_LP;
-                       FILESIZE_FULL = 0;
-                       FILESIZE_LP   = 0;
-               } else {
-                       // Beta release mode.
-                       // Provide the "all_beta.html" as download link.
-                       LINK_FULL     = 
"http://www.openoffice.org/download/all_beta.html";;
-                       LINK_LP       = LINK_LP;
-               }
-               // Show an error message that the chosen items do not lead to a 
download.
-               error_text = "<b>" + l10n_download_error_problem_text + "</b>" 
+ l10n_download_error_aoo_text + VERSION_SEL
-                            + l10n_download_error_not_available_for_text + 
"<b>" + RELEASE_LANG[ 1 ] + " ("
-                            + RELEASE_LANG[ 2 ] + ") (" + LANG_SEL + ")</b>."
-                            + "<br /><b>" + l10n_download_error_solution_text 
+ "</b>"
-                            + l10n_download_error_please_select_4_text;
+       // If until now an error occurred then assume that the selected options 
are not supported.
+       if( ERROR )
+               SUPPORTED = false;
+       else
+               SUPPORTED = true;
 
-               showErrorMessage( error_text );
-               return false;
-       } else {
-               // If language is supported, assemble the filenames and text 
for download and checksums. 
+       return ERROR;
+}
 
+/*
+ * Get link to mirror system for download file and checksum file
+ * Depends on chosen OS, language and version
+ */
+function getLinkSel() {
+       // Reset all variables that could have been set until now.
+       initVars( 0 );
+
+       // Get the selected data from the select boxes.
+       getOSSel();
+       getLangSel();
+       getVerSel();
+
+       // First check for expections that do not lead to real download links.
+       checkLinkExceptions();
+
+       // If selected options lead to an exception (VERSION_SEL = "older" OR 
SUPPORTED = FALSE)
+       // then do not overwrite current download links.
+       if( VERSION_SEL !== "older" && SUPPORTED && ! ERROR ) {
+               // Assemble the filenames and text for download and checksums.
                getReleaseMatrixPos();
                getFileData( VERSION_SEL );
 
@@ -672,7 +680,7 @@ function getLinkSel() {
                LINK_CHK_MD5_LP      = ASF_ARC_BASE_URL  + "/binaries/"   + 
LANG_SEL + "/" + FILENAME_LP   + ".md5";
                LINK_CHK_SHA256_LP   = ASF_ARC_BASE_URL  + "/binaries/"   + 
LANG_SEL + "/" + FILENAME_LP   + ".sha256";
 
-               SF                   = true;
+               SUPPORTED            = true;
                ERROR                = false;
 
                // Set the values for both download text buttons and set the 
focus to the "full install".
@@ -875,15 +883,9 @@ function getPlatform() {
 
                // Legacy, no longer supported platforms.
                if( ua.indexOf( "power_pc"              ) !== -1 ||
-                   ua.indexOf( "ppc"                   ) !== -1 ) {    
UI_PLATFORM_NO_SUP      = "Mac OS PPC (DMG)";
-                                                                       
OLD_PLATFORM            = true;
-               }
-               if( ua.indexOf( "sun4u"                 ) !== -1 ) {    
UI_PLATFORM_NO_SUP      = "Solaris SPARC (PKG)";
-                                                                       
OLD_PLATFORM            = true;
-               }
-               if( os.indexOf( "sunos"                 ) !== -1 ) {    
UI_PLATFORM_NO_SUP      = "Solaris x86 (PKG)";
-                                                                       
OLD_PLATFORM            = true;
-               }
+                   ua.indexOf( "ppc"                   ) !== -1 )      
UI_PLATFORM_NO_SUP      = "Mac OS PPC (DMG)";
+               if( ua.indexOf( "sun4u"                 ) !== -1 )      
UI_PLATFORM_NO_SUP      = "Solaris SPARC (PKG)";
+               if( os.indexOf( "sunos"                 ) !== -1 )      
UI_PLATFORM_NO_SUP      = "Solaris x86 (PKG)";
 
                // If $UI_PLATFORM_NO_SUP is already filled, something was 
recognized and no more work is needed.
                if( UI_PLATFORM_NO_SUP !== "" ) {
@@ -957,7 +959,6 @@ function getPlatform() {
                            ua.indexOf( "10.3"          ) !== -1 ||
                            ua.indexOf( "10_3"          ) !== -1 ) {    
UI_PLATFORM     = "Mac OS X (<= 10.6)";
                                                                        
PLATFORM        = "mac32";
-                                                                       
OLD_PLATFORM    = true;
                        }
                } 
        } 
@@ -1142,13 +1143,12 @@ function alertDbg( location ) {
        + "PLATFORM_FULL: "                     + "\t\t\t\t\t"          + 
PLATFORM_FULL                         + "\n"
        + "PLATFORM_LP: "                       + "\t\t\t\t\t\t"        + 
PLATFORM_LP                           + "\n"
        + "PLATFORM_SEL: "                      + "\t\t\t\t\t\t"        + 
PLATFORM_SEL                          + "\n"
-       + "OLD_PLATFORM: "                      + "\t\t\t\t\t"          + 
OLD_PLATFORM                          + "\n"
        + "RELEASE_PLATFORM_POS_FULL: "         + "\t\t\t"              + 
RELEASE_PLATFORM_POS_FULL             + "\n"
        + "RELEASE_PLATFORM_POS_LP: "           + "\t\t\t"              + 
RELEASE_PLATFORM_POS_LP               + "\n"
        + "RELEASE_PLATFORM: "                  + "\t\t\t\t\t"          + 
RELEASE_PLATFORM                      + "\n"
        + "RELEASE_LANG: "                      + "\t\t\t\t\t\t"        + 
RELEASE_LANG                          + "\n"
        + "REL_TEXT: "                          + "\t\t\t\t\t\t\t"      + 
REL_TEXT                              + "\n"
-       + "REL_NOTES: "                         + "\t\t\t\t\t\t\t"      + 
REL_NOTES                             + "\n"
+       + "REL_NOTES: "                         + "\t\t\t\t\t\t"        + 
REL_NOTES                             + "\n"
        + "VERSION_SEL: "                       + "\t\t\t\t\t\t"        + 
VERSION_SEL                           + "\n"
        + "FILENAME_FULL: "                     + "\t\t\t\t\t"          + 
FILENAME_FULL                         + "\n"
        + "FILENAME_LP: "                       + "\t\t\t\t\t\t"        + 
FILENAME_LP                           + "\n"
@@ -1163,9 +1163,7 @@ function alertDbg( location ) {
        + "LINK_CHK_ASC_LP: "                   + "\t\t\t\t\t"          + 
LINK_CHK_ASC_LP                       + "\n"
        + "LINK_CHK_MD5_LP: "                   + "\t\t\t\t\t"          + 
LINK_CHK_MD5_LP                       + "\n"
        + "LINK_CHK_SHA256_LP: "                + "\t\t\t\t"            + 
LINK_CHK_SHA256_LP                    + "\n"
-       + "SF: "                                + "\t\t\t\t\t\t\t\t"    + SF    
                                + "\n"
-       + "OTHER: "                             + "\t\t\t\t\t\t\t"      + OTHER 
                                + "\n"
-       + "ARCHIVE: "                           + "\t\t\t\t\t\t\t"      + 
ARCHIVE                               + "\n"
+       + "SUPPORTED: "                         + "\t\t\t\t\t\t"        + 
SUPPORTED                             + "\n"
        + "ERROR: "                             + "\t\t\t\t\t\t\t"      + ERROR 
                                + "\n"
        + "" );
 


Reply via email to