Author: marcus Date: Wed May 28 22:16:41 2014 New Revision: 1598158 URL: http://svn.apache.org/r1598158 Log: Caching conditions to speed-up 'for' loops
Modified: openoffice/ooo-site/trunk/content/download/test/download_droplist.js Modified: openoffice/ooo-site/trunk/content/download/test/download_droplist.js URL: http://svn.apache.org/viewvc/openoffice/ooo-site/trunk/content/download/test/download_droplist.js?rev=1598158&r1=1598157&r2=1598158&view=diff ============================================================================== --- openoffice/ooo-site/trunk/content/download/test/download_droplist.js (original) +++ openoffice/ooo-site/trunk/content/download/test/download_droplist.js Wed May 28 22:16:41 2014 @@ -270,7 +270,8 @@ function fillOSSel() { var option = ""; // Fill the <select> element until all OS's are used. - for( var i = 0; i < SEL_OS.length; i = i + 3 ) { +// for( var i = 0; i < SEL_OS.length; i = i + 3 ) { + for( var i = 0, j = SEL_OS.length; i < j; i = i + 3 ) { option = document.createElement( "option" ); // Assign the platform abbreviation as index value. option.value = SEL_OS[ i ]; @@ -297,7 +298,8 @@ function fillLangSel() { var option = ""; // Fill the <select> element until all languages are used. - for( var i = 0; i < SEL_LANG.length; i = i + 2 ) { +// for( var i = 0; i < SEL_LANG.length; i = i + 2 ) { + for( var i = 0, j = SEL_LANG.length; i < j; i = i + 2 ) { option = document.createElement( "option" ); // Assign the language ISO code as index value. option.value = SEL_LANG[ i ]; @@ -336,7 +338,8 @@ function fillVerSel() { var option = ""; // Fill the <select> element until all versions are used. - for( var i = 0; i < SEL_VER.length; i = i + 2 ) { +// for( var i = 0; i < SEL_VER.length; i = i + 2 ) { + for( var i = 0, j = SEL_VER.length; i < j; i = i + 2 ) { option = document.createElement( "option" ); // Assign the version as index value. option.value = SEL_VER[ i ]; @@ -379,7 +382,8 @@ function setOSSel() { // alert( "SEL_OS.length: " + SEL_OS.length / 3 ); // alert( "URL_PLATFORM: " + URL_PLATFORM ); // alert( "sel_os.selectedIndex: " + sel_os.selectedIndex ); - for( var i = 0; i < SEL_OS.length; i = i + 3 ) { +// for( var i = 0; i < SEL_OS.length; i = i + 3 ) { + for( var i = 0, j = SEL_OS.length; i < j; i = i + 3 ) { // If the platform was found, assign the found index to the drop-down-box. // alert( "i: " + i / 2 + "\n" + "SEL_OS[ i ]: " + SEL_OS[ i ] ); if( SEL_OS[ i ] == URL_PLATFORM ) { @@ -395,7 +399,8 @@ function setOSSel() { if( sel_os.selectedIndex == 0 ) { // Default: Assign "Windows". // alert( "SEL_OS.length: " + SEL_OS.length / 3 ); - for( var i = 0; i < SEL_OS.length; i = i + 3 ) { +// for( var i = 0; i < SEL_OS.length; i = i + 3 ) { + for( var i = 0, j = SEL_OS.length; i < j; i = i + 3 ) { // If the platform was found, assign the found index to the drop-down-box. // alert( "i: " + i / 2 + "\n" + "SEL_OS[ i ]: " + SEL_OS[ i ] ); if( SEL_OS[ i ] == "Win_x86_install" ) { @@ -484,7 +489,8 @@ function setLangSel() { // alert( "SEL_LANG.length: " + SEL_LANG.length / 2 ); // alert( "LANG_ISO: " + LANG_ISO ); // alert( "sel_lang.selectedIndex: " + sel_lang.selectedIndex ); - for( var i = 0; i < SEL_LANG.length; i = i + 2 ) { +// for( var i = 0; i < SEL_LANG.length; i = i + 2 ) { + for( var i = 0, j = SEL_LANG.length; i < j; i = i + 2 ) { // If the language was found, assign the found index to the drop-down-box. // alert( "i: " + i / 2 + "\n" + "SEL_LANG[ i ]: " + SEL_LANG[ i ] ); if( SEL_LANG[ i ] == LANG_ISO ) { @@ -500,7 +506,8 @@ function setLangSel() { if( sel_lang.selectedIndex == 0 ) { // Default: Assign "en-US". // alert( "SEL_LANG.length: " + SEL_LANG.length / 2 ); - for( var i = 0; i < SEL_LANG.length; i = i + 2 ) { +// for( var i = 0; i < SEL_LANG.length; i = i + 2 ) { + for( var i = 0, j = SEL_LANG.length; i < j; i = i + 2 ) { // If the language was found, assign the found index to the drop-down-box. // alert( "i: " + i / 2 + "\n" + "SEL_LANG[ i ]: " + SEL_LANG[ i ] ); if( SEL_LANG[ i ] == "en-US" ) { @@ -563,7 +570,8 @@ function setVerSel() { // alert( "SEL_VER.length: " + SEL_VER.length / 2 ); // alert( "VERSION: " + VERSION ); // alert( "sel_ver.selectedIndex: " + sel_ver.selectedIndex ); - for( var i = 0; i < SEL_VER.length; i = i + 2 ) { +// for( var i = 0; i < SEL_VER.length; i = i + 2 ) { + for( var i = 0, j = SEL_VER.length; i < j; i = i + 2 ) { // If the version was found, assign the found index to the drop-down-box. // alert( "i: " + i / 2 ); if( SEL_VER[ i ] == VERSION ) { @@ -651,7 +659,8 @@ function getOSSel() { } */ // Search through the <select> element until the chosen OS is found. - for( var i = 0; i < SEL_OS.length; i = i + 3 ) { +// for( var i = 0; i < SEL_OS.length; i = i + 3 ) { + for( var i = 0, j = SEL_OS.length; i < j; i = i + 3 ) { if( SEL_OS[ i ] == os_value ) { PLATFORM_SEL = SEL_OS[ i ]; UI_PLATFORM = SEL_OS[ i + 1 ]; @@ -715,7 +724,8 @@ function getLangSel() { } */ // Search through the <select> element until the chosen language is found. - for( var i = 0; i < SEL_LANG.length; i = i + 2 ) { +// for( var i = 0; i < SEL_LANG.length; i = i + 2 ) { + for( var i = 0, j = SEL_LANG.length; i < j; i = i + 2 ) { if( SEL_LANG[ i ] == lang_value ) { LANG_SEL = lang_value; /* @@ -765,7 +775,8 @@ function getVerSel() { } */ // Search through the <select> element until the chosen version is found. - for( var i = 0; i < SEL_VER.length; i = i + 2 ) { +// for( var i = 0; i < SEL_VER.length; i = i + 2 ) { + for( var i = 0, j = SEL_VER.length; i < j; i = i + 2 ) { if( SEL_VER[ i ] == ver_value ) { VERSION_SEL = ver_value; break; @@ -813,7 +824,8 @@ function resetSel() { */ // 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; i < element_ids.length; i++ ) { +// for( var i = 0; i < element_ids.length; i++ ) { + for( var i = 0, j = element_ids.length; i < j; i++ ) { if( element_ids[ i ].indexOf( "img" ) < 0 ) { // Emtpy the values for all text elements. // document.getElementById( element_ids[ i ] ).href = "javascript:void( 0 )"; @@ -967,7 +979,7 @@ function showErrorMessage( error_text ) document.getElementById( "dl_f_size_hl" ).innerHTML = error_text[ 4 ]; SF = false; - OTHER = true; + OTHER = false; ARCHIVE = false; ERROR = true; @@ -998,16 +1010,16 @@ function isLangSupported() { // RELEASE_MATRIX_LANG = release_matrix_400[ LANG_ISO ][ 0 ]; break; default: - RELEASE_MATRIX_LANG = ""; - ERROR = true; + RELEASE_MATRIX_LANG = ""; + ERROR = true; } // if( LANG_ARRAY[ 3 ] == 'y' ) { if( RELEASE_MATRIX_LANG[ 3 ] == 'y' ) { return true; } else { - NOT_AVAILABLE = RELEASE_MATRIX_LANG[ 1 ] + " is not available"; - ERROR = true; + NOT_AVAILABLE = RELEASE_MATRIX_LANG[ 1 ] + " is not available"; + ERROR = true; return false; } } @@ -1261,14 +1273,10 @@ function getLinkSel( rel_mode ) { } else { // If language is supported, assemble the filenames and text for download and checksums. -// alertDbg( "getLinkSel(): Before" ); - getReleaseMatrixPos(); getFilesize( VERSION_SEL ); getFilename( VERSION_SEL ); -// alertDbg( "getLinkSel(): After" ); - SOURCEFORGE_BASE_URL = SOURCEFORGE + VERSION_SEL + "/binaries/"; APACHE_DIST_BASE_URL = APACHE_DIST + VERSION_SEL; @@ -1370,17 +1378,19 @@ function getLinkSel( rel_mode ) { // 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; i < element_ids.length; i++ ) { +// for( var i = 0; i < element_ids.length; i++ ) { + for( var i = 0, j = element_ids.length; i < j; i++ ) { document.getElementById( element_ids[ i ] ).style.display = "inline"; document.getElementById( element_ids[ i ] ).style.cursor = "default"; } // Set the values for all elements that should not be empty. - for( var i = 0; i < element_ids_lnk.length; i++ ) { +// for( var i = 0; i < element_ids_lnk.length; i++ ) { + for( var i = 0, j = element_ids_lnk.length; i < j; i++ ) { document.getElementById( element_ids_lnk[ i ] ).style.cursor = "pointer"; } - // Specific exeptions: + // Further specific exceptions. document.getElementById( "dl_hlp" ).style.cursor = "help"; document.getElementById( "dl_hlp_img" ).style.cursor = "help"; document.getElementById( "dl_rpt" ).style.cursor = "help";