Author: marcus Date: Mon Jun 2 22:11:57 2014 New Revision: 1599378 URL: http://svn.apache.org/r1599378 Log: Updated code to recognize the used browser and platform/OS
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=1599378&r1=1599377&r2=1599378&view=diff ============================================================================== --- openoffice/ooo-site/trunk/content/download/test/download_droplist.js (original) +++ openoffice/ooo-site/trunk/content/download/test/download_droplist.js Mon Jun 2 22:11:57 2014 @@ -1450,9 +1450,10 @@ function getLinkSel() { function getPlatform() { // For more help or data see: "http://www.useragentstring.com". - var os = navigator.platform.toLowerCase(); // Get the platform string in lower cases. - var ua = navigator.userAgent.toLowerCase(); // Get the User Agent string in lower cases. - var av = navigator.appVersion.toLowerCase(); // Get the application version in lower cases. + var av = navigator.appVersion.toLowerCase(); // Get the application version in lower case. + var os = navigator.platform.toLowerCase(); // Get the platform string in lower case. + var ua = navigator.userAgent.toLowerCase(); // Get the user agent string in lower case. + 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. PLATFORM = ""; // Delete previously set string. @@ -1477,64 +1478,78 @@ function getPlatform() { } if( os ) { - // Recognized but not supported platforms/OS, set $UI_PLATFORM_NO_SUP to show it to the user. - if( os.indexOf( "aix" ) !== -1 ) UI_PLATFORM_NO_SUP = "IBM AIX"; - if( os.indexOf( "alphaserver" ) !== -1 ) UI_PLATFORM_NO_SUP = "AlphaServer"; - if( os.indexOf( "amiga" ) !== -1 ) UI_PLATFORM_NO_SUP = "AmigaOS"; - if( ua.indexOf( "android" ) !== -1 || - av.indexOf( "android" ) !== -1 ) UI_PLATFORM_NO_SUP = "Android mobile devices"; - if( os.indexOf( "arm" ) !== -1 ) UI_PLATFORM_NO_SUP = "ARM mobile devices"; + // Recognized but *not supported* platforms/OS, set $UI_PLATFORM_NO_SUP to show it to the user. + + // Mobile devices. + if( ua.indexOf( "android" ) !== -1 ) + if( ua.indexOf( "nexus" ) !== -1 && + ve.indexOf( "google" ) !== -1 ) UI_PLATFORM_NO_SUP = "Google Nexus"; + else if( ua.indexOf( "moble" ) !== -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"; if( ua.indexOf( "brew" ) !== -1 ) UI_PLATFORM_NO_SUP = "smartphones (BREW)"; + if( ua.indexOf( "ce.net" ) !== -1 ) UI_PLATFORM_NO_SUP = "mobile phones (Windows CE)"; + if( ua.indexOf( "galaxy" ) !== -1 ) UI_PLATFORM_NO_SUP = "Samsung Galaxy"; + if( ua.indexOf( "hiptop" ) !== -1 ) UI_PLATFORM_NO_SUP = "smartphones (Hiptop)"; + if( ua.indexOf( "htc" ) !== -1 ) UI_PLATFORM_NO_SUP = "HTC mobile devices"; + if( ua.indexOf( "ipad" ) !== -1 || + ua.indexOf( "iphone" ) !== -1 || + ua.indexOf( "ipod" ) !== -1 ) UI_PLATFORM_NO_SUP = "Apple iPhone/iPad/iPod"; + if( ua.indexOf( "kindle" ) !== -1 ) UI_PLATFORM_NO_SUP = "Amazon Kindle"; + if( ua.indexOf( "lg" ) !== -1 ) UI_PLATFORM_NO_SUP = "LG mobile devices"; + if( ua.indexOf( "nokia" ) !== -1 ) UI_PLATFORM_NO_SUP = "mobile phones (Nokia)"; + if( ua.indexOf( "palm" ) !== -1 ) UI_PLATFORM_NO_SUP = "mobile phones (Palm OS)"; + if( ua.indexOf( "pike" ) !== -1 ) UI_PLATFORM_NO_SUP = "mobile phones (Pike)"; + if( ua.indexOf( "s60" ) !== -1 ) UI_PLATFORM_NO_SUP = "mobile phones (S60)"; + if( ua.indexOf( "sonyericsson" ) !== -1 ) UI_PLATFORM_NO_SUP = "Sony/Ericsson mobile devices"; + if( ua.indexOf( "symbian" ) !== -1 ) UI_PLATFORM_NO_SUP = "mobile phones (Symbian OS)"; + if( ua.indexOf( "symbos" ) !== -1 ) UI_PLATFORM_NO_SUP = "mobile phones (Symbian OS)"; + 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 ) if( ua.indexOf( "mobile" ) !== -1 || ua.indexOf( "phone" ) !== -1 ) UI_PLATFORM_NO_SUP = "smartphones (Windows Phone)"; - if( ua.indexOf( "ce.net" ) !== -1 ) UI_PLATFORM_NO_SUP = "mobile phones (Windows CE)"; + + // Other platforms. + if( os.indexOf( "aix" ) !== -1 ) UI_PLATFORM_NO_SUP = "IBM AIX"; + if( os.indexOf( "alphaserver" ) !== -1 ) UI_PLATFORM_NO_SUP = "AlphaServer"; + if( os.indexOf( "amiga" ) !== -1 ) UI_PLATFORM_NO_SUP = "AmigaOS"; if( os.indexOf( "darwin" ) !== -1 ) UI_PLATFORM_NO_SUP = "Darwin"; if( os.indexOf( "dragonfly" ) !== -1 ) UI_PLATFORM_NO_SUP = "DragonFly BSD"; if( os.indexOf( "freebsd" ) !== -1 ) UI_PLATFORM_NO_SUP = "FreeBSD (PKG)"; - if( ua.indexOf( "hiptop" ) !== -1 ) UI_PLATFORM_NO_SUP = "smartphones (Hiptop)"; - if( ua.indexOf( "ipad" ) !== -1 || - ua.indexOf( "iphone" ) !== -1 || - ua.indexOf( "ipod" ) !== -1 ) UI_PLATFORM_NO_SUP = "Apple iPhone/iPad/iPod"; if( os.indexOf( "irix" ) !== -1 ) UI_PLATFORM_NO_SUP = "IRIX"; - if( ua.indexOf( "kindle" ) !== -1 ) UI_PLATFORM_NO_SUP = "Amazon Kindle"; if( os.indexOf( "netbsd" ) !== -1 ) UI_PLATFORM_NO_SUP = "NetBSD"; if( ua.indexOf( "nintendo" ) !== -1 ) UI_PLATFORM_NO_SUP = "Nintendo game console"; - if( ua.indexOf( "nokia" ) !== -1 ) UI_PLATFORM_NO_SUP = "Nokia mobile devices"; if( os.indexOf( "openbsd" ) !== -1 ) UI_PLATFORM_NO_SUP = "OpenBSD"; if( os.indexOf( "os/2" ) !== -1 ) UI_PLATFORM_NO_SUP = "OS/2"; - if( ua.indexOf( "palm" ) !== -1 ) UI_PLATFORM_NO_SUP = "mobile phones (Palm OS)"; if( os.indexOf( "pcbsd" ) !== -1 ) UI_PLATFORM_NO_SUP = "PC-BSD"; - if( ua.indexOf( "pike" ) !== -1 ) UI_PLATFORM_NO_SUP = "mobile phones (Pike)"; if( ua.indexOf( "playstation" ) !== -1 ) UI_PLATFORM_NO_SUP = "Sony Playstation"; + if( ua.indexOf( "psp" ) !== -1 ) UI_PLATFORM_NO_SUP = "Sony Playstation Portable"; + if( os.indexOf( "qnx" ) !== -1 ) UI_PLATFORM_NO_SUP = "QNX"; + if( os.indexOf( "vms" ) !== -1 ) UI_PLATFORM_NO_SUP = "OpenVMS"; + if( ua.indexOf( "wii" ) !== -1 ) UI_PLATFORM_NO_SUP = "Nintendo Wii game console"; + if( os.indexOf( "x11" ) !== -1 ) UI_PLATFORM_NO_SUP = "unknown OS (X11 support)"; + + // 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( "psp" ) !== -1 ) UI_PLATFORM_NO_SUP = "Sony Playstation Portable"; - if( os.indexOf( "qnx" ) !== -1 ) UI_PLATFORM_NO_SUP = "QNX"; - if( ua.indexOf( "s60" ) !== -1 ) UI_PLATFORM_NO_SUP = "mobile phones (S60)"; 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; } - if( ua.indexOf( "symbian" ) !== -1 ) UI_PLATFORM_NO_SUP = "mobile phones (Symbian OS)"; - if( ua.indexOf( "symbos" ) !== -1 ) UI_PLATFORM_NO_SUP = "mobile phones (Symbian OS)"; - if( os.indexOf( "vms" ) !== -1 ) UI_PLATFORM_NO_SUP = "OpenVMS"; - 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( ua.indexOf( "wii" ) !== -1 ) UI_PLATFORM_NO_SUP = "Nintendo Wii game console"; - if( os.indexOf( "x11" ) !== -1 ) UI_PLATFORM_NO_SUP = "unknown OS (X11 support)"; // If $UI_PLATFORM_NO_SUP is already filled, something was recognized and no more work is needed. - if( UI_PLATFORM_NO_SUP !== "" ) return PLATFORM; + // Recognized and *supported* platforms/OS, set $UI_PLATFORM to show it to the user. + // Windows? if( os.indexOf( "win" ) !== -1 || os.indexOf( "windows" ) !== -1 ) { UI_PLATFORM = "Windows (EXE)"; @@ -1542,9 +1557,9 @@ function getPlatform() { EXTENSION = ".exe"; } - // 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? + // 32-bit: DEB or RPM? if( os.indexOf( "x86" ) !== -1 || os.indexOf( "i686" ) !== -1 || os.indexOf( "i586" ) !== -1 || @@ -1565,7 +1580,7 @@ function getPlatform() { } } - // 64-bit, DEB or RPM? + // 64-bit: DEB or RPM? if( os.indexOf( "_64" ) !== -1 || os.indexOf( "-64" ) !== -1 || os.indexOf( "x64" ) !== -1 || @@ -1589,7 +1604,7 @@ function getPlatform() { if( os.indexOf( "mac" ) !== -1 ) { UI_PLATFORM = "OS X 64-bit (x86-64) (DMG)"; PLATFORM = "mac64"; EXTENSION = ".dmg"; - // OS X is 10.6 or older? + // OS X: 10.6 or older? if( ua.indexOf( "10.6" ) !== -1 || ua.indexOf( "10_6" ) !== -1 || ua.indexOf( "10.5" ) !== -1 ||