[gimp-web] Implement a platform switcher for the downloads page



commit 78b1e6acd8643cbbc6d822f6646845237d8f595b
Author: Michael Schumacher <schumaml gmx de>
Date:   Tue Aug 4 02:16:15 2015 +0200

    Implement a platform switcher for the downloads page
    
    This allows to circumvent the automatic platform detection and get
    access to downloads for other platforms. The detected platform is
    shown as well.

 downloads/index.htrw |    1 +
 includes/wgo.js      |   53 +++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 47 insertions(+), 7 deletions(-)
---
diff --git a/downloads/index.htrw b/downloads/index.htrw
index 07c58a0..e1b1392 100644
--- a/downloads/index.htrw
+++ b/downloads/index.htrw
@@ -15,6 +15,7 @@ $(document).ready(function() {
 
 <div id="downloads">
        <noscript>
+               Go to the downloads for <a href=#linux">GNU/Linux</a> <a href="#mac">OS X</a> <a 
href="#windows">Microsoft Windows</a></br>
                <!--#include virtual="/downloads/Linux.html"   -->
                <!--#include virtual="/downloads/Mac.html"     -->
                <!--#include virtual="/downloads/Windows.html" -->
diff --git a/includes/wgo.js b/includes/wgo.js
index b979e4c..7aea75c 100644
--- a/includes/wgo.js
+++ b/includes/wgo.js
@@ -26,25 +26,64 @@ function mangleforOpera() {
 //provide download page depending on OS
 function renderDownload(platform) {
 
-    $("#downloads").html("<div id=\"os\">&nbsp;</div>\n<div id=\"moreos\"></div>\n<hr />\n<div 
id=\"source\">&nbsp;</div>\n");
+    platforms = {
+       "oslinux"   : "GNU/Linux",
+       "osmac"     : "OS X",
+       "oswindows" : "Microsoft Windows",
+       "osall"     : "All",
+    };
 
+    // decide which platform to show
     if (platform == undefined) {
-       $("#os").load($.browser.OS + ".html"); // OS specific (autodetected)
-       $("#moreos").html("<a href=\"javascript:renderDownload('all');\">Show other downloads</a>");
+       platform    = "os" + $.browser.OS.toLowerCase();
     }
-    else if (platform == "all") {
+
+    if ( ! $("#os").length ) {
+       $("#downloads").html("<div id=\"moreos\"></div>\n<div id=\"os\"></div>\n<hr />\n<div 
id=\"source\"></div>\n");
+       $("#moreos").html("Our site thinks that you are using: " + platforms[platform] + "</br>" +
+                         "Show downloads for <a href=\"javascript:renderDownload('oslinux');\">"   + 
platforms['oslinux']   + "</a>" +
+                                          " | <a href=\"javascript:renderDownload('osmac');\">"     + 
platforms['osmac']     + "</a>" +
+                                          " | <a href=\"javascript:renderDownload('oswindows');\">" + 
platforms['oswindows'] + "</a>" +
+                                          " | <a href=\"javascript:renderDownload('osall');\">"     + 
platforms['osall']     + "</a>");
+
+       // always have all the divs
        $("#os").html("<div id=\"oslinux\"></div>\n<div id=\"osmac\"></div>\n<div id=\"oswindows\"></div>\n");
+    }
+
+    // load contents if necessary
+    if ( $("#oslinux").is(':empty') ) {
        $("#oslinux").load("Linux.html");
+    }
+
+    if ( $("#osmac").is(':empty') ) {
        $("#osmac").load("Mac.html");
+    }
+
+    if ( $("#oswindows").is(':empty') ) {
        $("#oswindows").load("Windows.html");
     }
+
+    if (platform == "osall") {
+       $("#oslinux").show();
+       $("#osmac").show();
+       $("#oswindows").show();
+    }
     else
     {
-       $("#os").load(platform + ".html"); // OS specific (manual)
-       $("#moreos").html("<a href=\"javascript:renderDownload('all');\">Show other downloads</a>");
+       $('#os').children().each(function() {
+           if ($(this).attr('id') != platform) {
+               $(this).hide();
+           } else {
+               $(this).show();
+           };
+       });
+
+
     }
 
-    $("#source").load("source.html"); //sources for all
+    if ( $("#source").is(':empty') ) {
+       $("#source").load("source.html"); //sources for all
+    }
 }
 
 var usertyped = ""; //for the easteregg



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]