Author: marcus Date: Thu Jul 3 22:20:20 2014 New Revision: 1607757 URL: http://svn.apache.org/r1607757 Log: Fixed JS errors
Modified: openoffice/ooo-site/trunk/content/download/test/download.js Modified: openoffice/ooo-site/trunk/content/download/test/download.js URL: http://svn.apache.org/viewvc/openoffice/ooo-site/trunk/content/download/test/download.js?rev=1607757&r1=1607756&r2=1607757&view=diff ============================================================================== --- openoffice/ooo-site/trunk/content/download/test/download.js (original) +++ openoffice/ooo-site/trunk/content/download/test/download.js Thu Jul 3 22:20:20 2014 @@ -34,7 +34,7 @@ function init( release_mode ) { initVariables( 1 ); // Fill the OS, language and version select boxes. - fillOSSelection() + fillOSSelection(); fillLanguageSelection(); fillVersionSelection(); @@ -49,8 +49,9 @@ function init( release_mode ) { // When release mode = 2, it is a beta release. Otherwise assume "stable release" as default. - if( release_mode === 2 ) + if( release_mode === 2 ) { RELEASE_MODE = mode; + } getLinkSelection(); @@ -130,34 +131,38 @@ function getLanguage() { var language = ""; // If available, use the manual set ISO code (see "index.html") that overrides $LANG_ISO. - if( NL_LANG !== "" ) + if( NL_LANG !== "" ) { language = NL_LANG; // Else if available, use the selected language from select box. - else if( LANG_SEL !== "" ) + } else if( LANG_SEL !== "" ) { language = LANG_SEL; // Else try to recognize the language from browser data. - else if( navigator.language ) + } else if( navigator.language ) { language = navigator.language; - else if( navigator.userLanguage ) + } else if( navigator.userLanguage ) { language = navigator.userLanguage; - else if( navigator.browserLanguage ) + } else if( navigator.browserLanguage ) { language = navigator.browserLanguage; - else if( navigator.systemLanguage ) + } else if( navigator.systemLanguage ) { language = navigator.systemLanguage; + } // Assign "en-US" as fall-back language if only "en" is set or nothing at all. - if( !language || language === "" || language == null || language === "en" ) + if( !language || language === "" || language == null || language === "en" ) { language = "en-US"; + } // Assign "pt-PT" if only "pt" is set. - if( language === "pt" ) + if( language === "pt" ) { language = "pt-PT"; + } // Konqueror uses '_' where other browsers use '-'. - if( language.indexOf( "_" ) !== -1 ) + if( language.indexOf( "_" ) !== -1 ) { // Change a contained '_' into a '-'. language = language.split( "_" ).join( "-" ); + } language = language.toLowerCase(); // Change the language into lower case. var languageCode = language.split( "-" )[ 0 ]; // Part before "-" is the language code. @@ -174,8 +179,9 @@ function getLanguage() { if( regionCode != null ) { // Fix for Portuguese (European) downloads as they are named only "pt" without region code! - if( languageCode === "pt" && regionCode === "pt" ) + if( languageCode === "pt" && regionCode === "pt" ) { language = languageCode; + } // If an additional region code was found. if( thisLanguageSet[ regionCode ] != null ) { @@ -436,11 +442,13 @@ function getVersionSelection() { function hideElements() { // Change CSS styles for all elements with ID in the green and sub-green colored boxes. // Emtpy the values for all elements, make them invisible. - for( var i = 0, j = element_ids_sub_box.length; i < j; i++ ) + for( var i = 0, j = element_ids_sub_box.length; i < j; i++ ) { document.getElementById( element_ids_sub_box[ i ] ).style.display = "none"; + } - for( var i = 0, j = element_ids_links.length; i < j; i++ ) + for( var i = 0, j = element_ids_links.length; i < j; i++ ) { document.getElementById( element_ids_links[ i ] ).style.display = "none"; + } return; } @@ -451,6 +459,8 @@ function hideElements() { */ function showWindow( target_link ) { // Open a popup window with specific parameters to show the file from "target_link". + var window; + window = window.open( target_link, "_blank", "location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=no, left=100, top=250, width=800, height=550"); window.focus(); @@ -507,8 +517,9 @@ function showErrorMessage( error_text ) function isLanguageSupported() { // Check the flag in "release_matrix.js", 'y' -> provide download link, 'n' -> redirect to alternative webpage. - if( VERSION_SEL === undefined || VERSION_SEL === "" ) + if( VERSION_SEL === undefined || VERSION_SEL === "" ) { VERSION_SEL = VERSION; + } switch( VERSION_SEL ) { case "4.1.0": @@ -559,9 +570,10 @@ function checkForLinkExceptions() { + "<br />" + "<b>" + l10n_download_error_solution_text + "</b>" + l10n_download_error_please_select_4_text; - } else + } else { // Show the customized error text. var error_text = l10n_download_error_custom_4_text; + } showErrorMessage( error_text ); } @@ -580,9 +592,10 @@ function checkForLinkExceptions() { + "<br />" + "<b>" + l10n_download_error_solution_text + "</b>" + l10n_download_error_please_select_3_text; - } else + } else { // Show the customized error text. var error_text = l10n_download_error_custom_3_text; + } showErrorMessage( error_text ); } @@ -601,9 +614,10 @@ function checkForLinkExceptions() { + "<br />" + "<b>" + l10n_download_error_solution_text + "</b>" + l10n_download_error_please_select_1_text; - } else + } else { // Show the customized error text. var error_text = l10n_download_error_custom_1_text; + } showErrorMessage( error_text ); } @@ -622,9 +636,10 @@ function checkForLinkExceptions() { + "<br />" + "<b>" + l10n_download_error_solution_text + "</b>" + l10n_download_error_please_select_2_text; - } else + } else { // Show the customized error text. var error_text = l10n_download_error_custom_2_text; + } showErrorMessage( error_text ); } @@ -839,14 +854,18 @@ function getLinkSelection() { function getPlatform() { // For more help or data see: "http://www.useragentstring.com". - if( navigator.appVersion ) + if( navigator.appVersion ) { var av = navigator.appVersion.toLowerCase(); // Get the application version in lower case. - if( navigator.platform ) + } + if( navigator.platform ) { var os = navigator.platform.toLowerCase(); // Get the platform string in lower case. - if( navigator.userAgent ) + } + if( navigator.userAgent ) { var ua = navigator.userAgent.toLowerCase(); // Get the user agent string in lower case. - if( navigator.vendor ) + } + if( navigator.vendor ) { var ve = navigator.vendor.toLowerCase(); // Get the vendor string in lower case. + } UI_PLATFORM = ""; // Delete previously set string. UI_PLATFORM_NO_SUP = ""; // Delete previously set string. @@ -857,15 +876,19 @@ function getPlatform() { // To workaround that MSIE 8 and older do not support this function. if( !( 'indexOf' in Array.prototype ) ) { Array.prototype.indexOf= function( find, i ) { // 'i' is an optional parameter. - if( i === undefined ) + if( i === undefined ) { i = 0; - if( i < 0 ) + } + if( i < 0 ) { i+= this.length; - if( i < 0 ) + } + if( i < 0 ) { i = 0; + } for( var n = this.length; i < n; i++ ) { - if( i in this && this[ i ] === find ) + if( i in this && this[ i ] === find ) { return i; + } } return -1; }; @@ -876,13 +899,15 @@ function getPlatform() { // Recognized but *not supported* platforms/OS, set $UI_PLATFORM_NO_SUP to show it to the user. // Mobile devices. - if( ve ) + if( ve ) { if( ua.indexOf( "android" ) !== -1 ) if( ua.indexOf( "nexus" ) !== -1 && ve.indexOf( "google" ) !== -1 ) UI_PLATFORM_NO_SUP = "Google Nexus"; + } - if( ua.indexOf( "android" ) !== -1 ) + if( ua.indexOf( "android" ) !== -1 ) { if( ua.indexOf( "mobile" ) !== -1 ) UI_PLATFORM_NO_SUP = "Mobile Devices (Android)"; + } if( os.indexOf( "arm" ) !== -1 ) UI_PLATFORM_NO_SUP = "Mobile Devices (ARM processor)"; if( ua.indexOf( "blackberry" ) !== -1 ) UI_PLATFORM_NO_SUP = "Blackberry Smartphones"; @@ -906,9 +931,10 @@ function getPlatform() { if( ua.indexOf( "webos" ) !== -1 ) UI_PLATFORM_NO_SUP = "Mobile Phones (Palm webOS)"; if( ua.indexOf( "widerweb" ) !== -1 ) UI_PLATFORM_NO_SUP = "Mobile Phones (WiderWeb)"; if( os.indexOf( "win" ) !== -1 || - os.indexOf( "windows" ) !== -1 ) + os.indexOf( "windows" ) !== -1 ) { if( ua.indexOf( "mobile" ) !== -1 || ua.indexOf( "phone" ) !== -1 ) UI_PLATFORM_NO_SUP = "Smartphones (Windows Phone)"; + } // Other platforms. if( os.indexOf( "aix" ) !== -1 ) UI_PLATFORM_NO_SUP = "IBM AIX"; @@ -1169,8 +1195,8 @@ function getFileData( version ) { * Set document.location to start the download */ function openItem( itemid, uri ) { - var thisDocument = document.getElementById( "downloadextendedtext" ); - var thisDocument = document.getElementById( itemid ); +// var thisDocument = document.getElementById( "downloadextendedtext" ); +// var thisDocument = document.getElementById( itemid ); document.location = uri; } @@ -1178,11 +1204,11 @@ function openItem( itemid, uri ) { * Output values of variables for debugging */ function debug( location ) { - if( location === "" ) + if( location === "" ) { location = "No location named!"; + } - alert( "" - + location + "\n" + alert( location + "\n" + "NL_LANG: " + "\t\t\t\t\t\t\t" + NL_LANG + "\n" + "LANG_ISO: " + "\t\t\t\t\t\t" + LANG_ISO + "\n" + "LANG_SEL: " + "\t\t\t\t\t\t" + LANG_SEL + "\n" @@ -1213,8 +1239,7 @@ function debug( location ) { + "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" + "SHOW_SUB_BOX: " + "\t\t\t\t\t" + SHOW_SUB_BOX + "\n" - + "ERROR: " + "\t\t\t\t\t\t\t" + ERROR + "\n" - + "" ); + + "ERROR: " + "\t\t\t\t\t\t\t" + ERROR + "\n" ); return; }