Author: marcus
Date: Thu Feb 20 22:28:31 2014
New Revision: 1570368

URL: http://svn.apache.org/r1570368
Log:
Updated DL logic with beta mode

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=1570368&r1=1570367&r2=1570368&view=diff
==============================================================================
--- openoffice/ooo-site/trunk/content/download/test/download.js (original)
+++ openoffice/ooo-site/trunk/content/download/test/download.js Thu Feb 20 
22:28:31 2014
@@ -11,25 +11,25 @@
 /*
  * Define global variables
  */
-var LANG_ISO                           = "";           // The language as ISO 
code
-var LANG_ARRAY                         = "";           // This array contains 
all language specific data
-var RELEASE_MATRIX_PLATFORM_POS                = -1;           // The position 
of the platform in the release matrix array
-var RELEASE_MATRIX_PLATFORM            = "";           // The platform in the 
release matrix array
-var UI_PLATFORM                                = "";           // The platform 
as readable string
-var URL_PLATFORM                       = "";           // The platform as part 
of the download URL
-var OLD_PLATFORM                       = false;        // The browser platform 
is old (true) or not (false)
-var FILENAME                           = "";           // The complete 
filename of the download URL
-var FILESIZE                           = 0;            // The filesize of the 
download file
-var EXTENSION                          = "";           // The file extension 
of the download URL
-var LINK                               = "";           // The complete 
download URL
-var CHECKSUM_KEYS                      = "";           // The KEYS file as 
download URL
-var CHECKSUM_ASC                       = "";           // The ASC file as 
download URL
-var CHECKSUM_MD5                       = "";           // The MD5 file as 
download URL
-var CHECKSUM_SHA256                    = "";           // The SHA256 file as 
download URL
-var SOURCEFORGE                                = false;        // The download 
URL points to Soureforge
-var OTHER                              = false;        // The download URL 
points to 'other.html'
-var ARCHIVE                            = false;        // The download URL 
points to the ASF archive
-var ERROR                              = false;        // The download URL is 
correct (false) or not (true)?
+var LANG_ISO                   = "";    // The language as ISO code
+var LANG_ARRAY                 = "";    // This array contains all language 
specific data
+var RELEASE_MATRIX_PLATFORM_POS        = -1;    // The position of the 
platform in the release matrix array
+var RELEASE_MATRIX_PLATFORM    = "";    // The platform in the release matrix 
array
+var UI_PLATFORM                        = "";    // The platform as readable 
string
+var URL_PLATFORM               = "";    // The platform as part of the 
download URL
+var OLD_PLATFORM               = false; // The browser platform is old (true) 
or not (false)
+var FILENAME                   = "";    // The complete filename of the 
download URL
+var FILESIZE                   = 0;     // The filesize of the download file
+var EXTENSION                  = "";    // The file extension of the download 
URL
+var LINK                       = "";    // The complete download URL
+var CHECKSUM_KEYS              = "";    // The KEYS file as download URL
+var CHECKSUM_ASC               = "";    // The ASC file as download URL
+var CHECKSUM_MD5               = "";    // The MD5 file as download URL
+var CHECKSUM_SHA256            = "";    // The SHA256 file as download URL
+var SOURCEFORGE                        = false; // The download URL points to 
Soureforge
+var OTHER                      = false; // The download URL points to 
'other.html'
+var ARCHIVE                    = false; // The download URL points to the ASF 
archive
+var ERROR                      = false; // The download URL is correct (false) 
or not (true)?
 
 /*
  * Get array and ISO code for language
@@ -100,8 +100,8 @@ function getLanguage() {
                thisLanguage = thisLanguageSet[ "-" ];
        }
 
-       LANG_ISO        = language;
-       LANG_ARRAY      = thisLanguage;
+       LANG_ISO   = language;
+       LANG_ARRAY = thisLanguage;
 }
 
 /*
@@ -121,13 +121,13 @@ function hasMirrorLink() {
  * Get link to mirror system for download file and checksum file
  * Depends on array-list
  */
-function getLink() {
+function getLink(rel_mode) {
        var chk_link = "";
 
        getLanguage();
        hasMirrorLink();
        getPlatform();
-       getFilesize();
+       getFilesize(rel_mode);
 
        if ( NL_LANGUAGE == "" )
                NL_LANGUAGE = LANG_ISO;
@@ -141,26 +141,37 @@ function getLink() {
        if ( hasMirrorLink() ) {
                // If platform is too old, then provide a general download link 
to the archive.
                if ( OLD_PLATFORM ) {
-                       LINK    = "http://archive.apache.org/dist/openoffice/";;
+                       if (rel_mode == 0) {
+                               // Release mode
+                               LINK    = 
"http://archive.apache.org/dist/openoffice/";;
 
-                       CHECKSUM_KEYS   = 
"https://people.apache.org/keys/group/openoffice.asc";;
-                       CHECKSUM_ASC    = 
"http://archive.apache.org/dist/openoffice/";;
-                       CHECKSUM_MD5    = 
"http://archive.apache.org/dist/openoffice/";;
-                       CHECKSUM_SHA256 = 
"http://archive.apache.org/dist/openoffice/";;
+                               CHECKSUM_KEYS   = 
"https://people.apache.org/keys/group/openoffice.asc";;
+                               CHECKSUM_ASC    = 
"http://archive.apache.org/dist/openoffice/";;
+                               CHECKSUM_MD5    = 
"http://archive.apache.org/dist/openoffice/";;
+                               CHECKSUM_SHA256 = 
"http://archive.apache.org/dist/openoffice/";;
+                       } else {
+                               // Beta release mode
+                       }
 
                        if ( UI_PLATFORM == "Mac OS X (10.6 or older)" ) {
                                // If platform is Mac OS X <=10.6, then provide 
a download link with previous AOO version.
 
-                               FILENAME        = "Apache_OpenOffice_" + 
PRE_VERSION + "_" + URL_PLATFORM + "_";
-                               FILENAME        = FILENAME + NL_LANGUAGE + 
EXTENSION;
-                               LINK            = SOURCEFORGE_PREVIOUS_URL + 
NL_LANGUAGE + "/" + FILENAME + "/download";
-
-                               chk_link        = APACHE_DIST_PREVIOUS_URL + 
"/binaries/" + NL_LANGUAGE + "/" + FILENAME;
-
-                               CHECKSUM_KEYS   = 
"https://people.apache.org/keys/group/openoffice.asc";;
-                               CHECKSUM_ASC    = chk_link + ".asc";
-                               CHECKSUM_MD5    = chk_link + ".md5";
-                               CHECKSUM_SHA256 = chk_link + ".sha256";
+                               if (rel_mode == 0) {
+                                 // Release mode
+                                 FILENAME      = "Apache_OpenOffice_" + 
PRE_VERSION + "_" + URL_PLATFORM + "_";
+                                 FILENAME      = FILENAME + NL_LANGUAGE + 
EXTENSION;
+                                 LINK          = SOURCEFORGE_PREVIOUS_URL + 
NL_LANGUAGE + "/" + FILENAME + "/download";
+
+                                 chk_link      = APACHE_DIST_PREVIOUS_URL + 
"/binaries/" + NL_LANGUAGE + "/" + FILENAME;
+
+                                 CHECKSUM_KEYS = 
"https://people.apache.org/keys/group/openoffice.asc";;
+                                 CHECKSUM_ASC  = chk_link + ".asc";
+                                 CHECKSUM_MD5  = chk_link + ".md5";
+                                 CHECKSUM_SHA256       = chk_link + ".sha256";
+                               } else {
+                                 // Beta release mode
+                                 LINK          = 
"http://www.openoffice.org/download/all_beta.html";;
+                               }
                        }
 
                        ARCHIVE = true;
@@ -173,7 +184,13 @@ function getLink() {
                        if ( UI_PLATFORM == "" )
                                UI_PLATFORM = "unknown platform/OS";
 
-                       LINK    = 
"http://www.openoffice.org/download/other.html";;
+                       if (rel_mode == 0) {
+                               // Release mode
+                               LINK    = 
"http://www.openoffice.org/download/other.html";;
+                       } else {
+                               // Beta release mode
+                               LINK    = 
"http://www.openoffice.org/download/all_beta.html";;
+                       }
                        OTHER   = true;
                        ERROR   = true;
                        return LINK;
@@ -183,16 +200,31 @@ function getLink() {
                        // FILENAME     = "Apache_OpenOffice_" + VERSION + "_" 
+ URL_PLATFORM + "_" + NL_LANGUAGE;
                        // FILENAME     = FILENAME + EXTENSION;
 
-                       // Assign the file name (column 3) from the release 
matrix of language and platform
-                       FILENAME        = release_matrix[ LANG_ISO ][ 
RELEASE_MATRIX_PLATFORM_POS ][ 3 ];
-
-                       // LINK         = SOURCEFORGE_BASE_URL + NL_LANGUAGE + 
"/Apache_OpenOffice_" + VERSION + "_";
-                       // LINK         = LINK + URL_PLATFORM + "_" + 
NL_LANGUAGE + EXTENSION + "/download";
-                       LINK            = SOURCEFORGE_BASE_URL + NL_LANGUAGE + 
"/" + FILENAME + "/download";
-
-                       // chk_link     = APACHE_DIST_BASE_URL + "/binaries/" + 
NL_LANGUAGE + "/Apache_OpenOffice_";
-                       // chk_link     = chk_link + VERSION + "_" + 
URL_PLATFORM + "_" + NL_LANGUAGE + EXTENSION;
-                       chk_link        = APACHE_DIST_BASE_URL + "/binaries/" + 
NL_LANGUAGE + "/" + FILENAME;
+                       if (rel_mode == 0) {
+                               // Release mode
+                               // Assign the file name (column 3) from the 
release matrix of language and platform
+                               FILENAME        = release_matrix[ LANG_ISO ][ 
RELEASE_MATRIX_PLATFORM_POS ][ 3 ];
+
+                               // LINK = SOURCEFORGE_BASE_URL + NL_LANGUAGE + 
"/Apache_OpenOffice_" + VERSION + "_";
+                               // LINK = LINK + URL_PLATFORM + "_" + 
NL_LANGUAGE + EXTENSION + "/download";
+                               LINK            = SOURCEFORGE_BASE_URL + 
NL_LANGUAGE + "/" + FILENAME + "/download";
+
+                               // chk_link     = APACHE_DIST_BASE_URL + 
"/binaries/" + NL_LANGUAGE + "/Apache_OpenOffice_";
+                               // chk_link     = chk_link + VERSION + "_" + 
URL_PLATFORM + "_" + NL_LANGUAGE + EXTENSION;
+                               chk_link        = APACHE_DIST_BASE_URL + 
"/binaries/" + NL_LANGUAGE + "/" + FILENAME;
+                       } else {
+                               // Beta release mode
+                               // Assign the file name (column 3) from the 
release matrix of language and platform
+                               FILENAME        = release_matrix_beta[ LANG_ISO 
][ RELEASE_MATRIX_PLATFORM_POS ][ 3 ];
+
+                               // LINK = SOURCEFORGE_BASE_URL + NL_LANGUAGE + 
"/Apache_OpenOffice_" + VERSION + "_";
+                               // LINK = LINK + URL_PLATFORM + "_" + 
NL_LANGUAGE + EXTENSION + "/download";
+                               LINK            = SOURCEFORGE_BASE_URL_BETA + 
NL_LANGUAGE + "/" + FILENAME + "/download";
+
+                               // chk_link     = APACHE_DIST_BASE_URL + 
"/binaries/" + NL_LANGUAGE + "/Apache_OpenOffice_";
+                               // chk_link     = chk_link + VERSION + "_" + 
URL_PLATFORM + "_" + NL_LANGUAGE + EXTENSION;
+                               chk_link        = APACHE_DIST_BASE_URL_BETA + 
"/binaries/" + NL_LANGUAGE + "/" + FILENAME;
+                       }
 
                        CHECKSUM_KEYS   = 
"https://people.apache.org/keys/group/openoffice.asc";;
                        CHECKSUM_ASC    = chk_link + ".asc";
@@ -221,7 +253,7 @@ function getLink() {
 
 /*
  * Get platform of browser
- * Depending on internal browser data
+ * Depends on internal browser data
  */
 function getPlatform() {
        // For more help or data see: "http://www.useragentstring.com";
@@ -233,19 +265,19 @@ function getPlatform() {
        // Add ECMA262-5 Array methods if not supported natively
        // To workaround that MSIE 8 and older do not support this function
        if ( !( 'indexOf' in Array.prototype ) ) {
-         Array.prototype.indexOf= function( find, i /*opt*/ ) {
-           if ( i === undefined )
-             i = 0;
-           if ( i < 0 )
-             i+= this.length;
-           if ( i < 0 )
-             i = 0;
-           for ( var n = this.length; i < n; i++ ) {
-             if ( i in this && this[ i ] === find )
-               return i;
-           }
-           return -1;
-         };
+               Array.prototype.indexOf= function( find, i /*opt*/ ) {
+                       if ( i === undefined )
+                               i = 0;
+                       if ( i < 0 )
+                               i+= this.length;
+                       if ( i < 0 )
+                               i = 0;
+                       for ( var n = this.length; i < n; i++ ) {
+                               if ( i in this && this[ i ] === find )
+                                       return i;
+                       }
+                       return -1;
+               };
        }
 
        if ( os ) {
@@ -301,7 +333,7 @@ function getPlatform() {
 
          // If the $UI_PLATFORM variable is already filled, then something was 
recognized and no more work is need
          if ( UI_PLATFORM != "" )
-           return;
+               return;
 
          // Windows, x86 or mobile?
          if ( os.indexOf( "windows"            ) != -1 ||
@@ -312,61 +344,61 @@ function getPlatform() {
                 ua.indexOf( "mobile"           ) != -1 )       UI_PLATFORM     
= "Windows Mobile device";
          }
 
-         // Linux, x86 or x86_64, DEB or RPM?
+         // Linux, x86 or x86-64, DEB or RPM?
          if ( os.indexOf( "linux"              ) != -1 ) {
-           // 32-bit, DEB or RPM?
-           if ( os.indexOf( "x86"              ) != -1 ||
-                os.indexOf( "i686"             ) != -1 ||
-                os.indexOf( "i586"             ) != -1 ||
-                os.indexOf( "i486"             ) != -1 ||
-                os.indexOf( "i386"             ) != -1 ) {     UI_PLATFORM     
= "Linux 32-bit (RPM)";
+               // 32-bit, DEB or RPM?
+               if ( os.indexOf( "x86"          ) != -1 ||
+                    os.indexOf( "i686"         ) != -1 ||
+                    os.indexOf( "i586"         ) != -1 ||
+                    os.indexOf( "i486"         ) != -1 ||
+                    os.indexOf( "i386"         ) != -1 ) {     UI_PLATFORM     
= "Linux 32-bit (RPM)";
                                                                URL_PLATFORM    
= "Linux_x86_install-rpm";
                                                                EXTENSION       
= ".tar.gz";
-             if ( ua.indexOf( "debian"         ) != -1 ||
-                  ua.indexOf( "ubuntu"         ) != -1 ||
-                  ua.indexOf( "iceweasel"      ) != -1 ) {     UI_PLATFORM     
= "Linux Debian 32-bit (DEB)";
+                    if ( ua.indexOf( "debian"    ) != -1 ||
+                         ua.indexOf( "ubuntu"    ) != -1 ||
+                         ua.indexOf( "iceweasel" ) != -1 ) {   UI_PLATFORM     
= "Linux Debian 32-bit (DEB)";
                                                                URL_PLATFORM    
= "Linux_x86_install-deb";
                                                                EXTENSION       
= ".tar.gz";
-             }
-           }
-           // 64-bit, DEB or RPM?
-           if ( os.indexOf( "_64"              ) != -1 ||
-                os.indexOf( "-64"              ) != -1 ||
-                os.indexOf( "x64"              ) != -1 ||
-                os.indexOf( "amd64"            ) != -1 ) {     UI_PLATFORM     
= "Linux 64-bit (RPM)";
+                    }
+               }
+               // 64-bit, DEB or RPM?
+               if ( os.indexOf( "_64"          ) != -1 ||
+                    os.indexOf( "-64"          ) != -1 ||
+                    os.indexOf( "x64"          ) != -1 ||
+                    os.indexOf( "amd64"        ) != -1 ) {     UI_PLATFORM     
= "Linux 64-bit (RPM)";
                                                                URL_PLATFORM    
= "Linux_x86-64_install-rpm";
                                                                EXTENSION       
= ".tar.gz";
-             if ( ua.indexOf( "debian"         ) != -1 ||
-                  ua.indexOf( "ubuntu"         ) != -1 ||
-                  ua.indexOf( "iceweasel"      ) != -1 ) {     UI_PLATFORM     
= "Linux Debian 64-bit (DEB)";
+                    if ( ua.indexOf( "debian"    ) != -1 ||
+                         ua.indexOf( "ubuntu"    ) != -1 ||
+                         ua.indexOf( "iceweasel" ) != -1 ) {   UI_PLATFORM     
= "Linux Debian 64-bit (DEB)";
                                                                URL_PLATFORM    
= "Linux_x86-64_install-deb";
                                                                EXTENSION       
= ".tar.gz";
-             }
-           }
+                    }
+               }
          }
 
-         // OS X x86?
+         // OS X 64-bit
          if ( os.indexOf( "mac"                ) != -1 ) {     UI_PLATFORM     
= "OS X 64-bit Intel (DMG)";
                                                                URL_PLATFORM    
= "MacOS_x86_install";
                                                                EXTENSION       
= ".dmg";
-           // OS X is 10.6 or older?
-           if ( ua.indexOf( "10.6"             ) != -1 ||
-                ua.indexOf( "10_6"             ) != -1 ||
-                ua.indexOf( "10.5"             ) != -1 ||
-                ua.indexOf( "10_5"             ) != -1 ||
-                ua.indexOf( "10.4"             ) != -1 ||
-                ua.indexOf( "10_4"             ) != -1 ||
-                ua.indexOf( "10.3"             ) != -1 ||
-                ua.indexOf( "10_3"             ) != -1 ) {     UI_PLATFORM     
= "Mac OS X (10.6 or older)";
+               // OS X is 10.6 or older?
+               if ( ua.indexOf( "10.6"         ) != -1 ||
+                    ua.indexOf( "10_6"         ) != -1 ||
+                    ua.indexOf( "10.5"         ) != -1 ||
+                    ua.indexOf( "10_5"         ) != -1 ||
+                    ua.indexOf( "10.4"         ) != -1 ||
+                    ua.indexOf( "10_4"         ) != -1 ||
+                    ua.indexOf( "10.3"         ) != -1 ||
+                    ua.indexOf( "10_3"         ) != -1 ) {     UI_PLATFORM     
= "Mac OS X (10.6 or older)";
                                                                OLD_PLATFORM    
= true;
-           }
+               }
          } 
        } 
 
        // If nothing was recognized until now, set $UI_PLATFORM to show it to 
the user
        if ( UI_PLATFORM == "" ) {
-               UI_PLATFORM     = "unknown platform/OS";
-               ERROR           = true;
+               UI_PLATFORM = "unknown platform/OS";
+               ERROR       = true;
        }
        return;
 }
@@ -375,7 +407,7 @@ function getPlatform() {
  * Get file size for download file
  * Depends on array-list
  */
-function getFilesize() {
+function getFilesize(rel_mode) {
        // Depending on $URL_PLATFORM assign the platform position of the 
release matrix
        switch ( URL_PLATFORM ) {
                case "Linux_x86-64_install-deb":
@@ -390,7 +422,7 @@ function getFilesize() {
                case "Linux_x86_install-rpm":
                        RELEASE_MATRIX_PLATFORM_POS = 5;
                        break;
-               case "MacOS_x86_install":
+               case "MacOS_x86-64_install":
                        RELEASE_MATRIX_PLATFORM_POS = 8;
                        break;
                case "Win_x86_install":
@@ -402,14 +434,22 @@ function getFilesize() {
 
        // If a platform was found and no error occurred, assign the array data 
and filesize from the release matrix
        if ( RELEASE_MATRIX_PLATFORM_POS > -1 && !ERROR ) {
-               // Assign all values from the release matrix of language and 
platform
-               RELEASE_MATRIX_PLATFORM = release_matrix[ LANG_ISO ][ 
RELEASE_MATRIX_PLATFORM_POS ];
-
-               // Assign the file size (column 2) from the release matrix of 
language and platform
-               FILESIZE                = release_matrix[ LANG_ISO ][ 
RELEASE_MATRIX_PLATFORM_POS ][ 2 ];
+               if (rel_mode == 0) {
+                       // Release mode
+                       // Assign all values from the release matrix of 
language and platform
+                       RELEASE_MATRIX_PLATFORM = release_matrix[ LANG_ISO ][ 
RELEASE_MATRIX_PLATFORM_POS ];
+                       // Assign the file size (column 2) from the release 
matrix of language and platform
+                       FILESIZE                = release_matrix[ LANG_ISO ][ 
RELEASE_MATRIX_PLATFORM_POS ][ 2 ];
+               } else {
+                       // Beta release mode
+                       // Assign all values from the release matrix of 
language and platform
+                       RELEASE_MATRIX_PLATFORM = release_matrix_beta[ LANG_ISO 
][ RELEASE_MATRIX_PLATFORM_POS ];
+                       // Assign the file size (column 2) from the release 
matrix of language and platform
+                       FILESIZE                = release_matrix_beta[ LANG_ISO 
][ RELEASE_MATRIX_PLATFORM_POS ][ 2 ];
+               }
        } else {
-               ERROR                   = true;
-               FILESIZE                = 0;
+               ERROR    = true;
+               FILESIZE = 0;
        }
 
        return FILESIZE;


Reply via email to