Bug 724311 - Start page JS (upgrade nagging) fails to identify 2.10a1 nightly correctly
authorjh@junetz.de
Sat, 04 Feb 2012 22:38:39 +0000
changeset 872 f7f6c9398a851a01ecb75845cf6c858e8be41db3
parent 871 b1db8b67be9a38cb5675445d7f5df4268f98b8da
child 873 963a2ec8ecf648773490dd782ebaf393039bda52
push id1
push userhg
push dateTue, 07 Apr 2015 21:00:21 +0000
bugs724311
Bug 724311 - Start page JS (upgrade nagging) fails to identify 2.10a1 nightly correctly
src/start/index-test.en.html
src/start/index.de.html
src/start/index.en.html
--- a/src/start/index-test.en.html
+++ b/src/start/index-test.en.html
@@ -12,33 +12,38 @@
 
 <script type="text/javascript" src="/download.js"></script>
 
 <title>Welcome to SeaMonkey</title>
 </head>
 <body>
 <h1>Welcome to SeaMonkey</h1>
 
-<script type="text/javascript"> <!--
+<script type="text/javascript"><!--
+  function displayElement(el, show) {
+    document.getElementById(el).style.display = show ? "block" : "none";
+  }
+
   function buildTest() {
     var ua = navigator.userAgent;
     // Uncomment one of those user agents to test this script
-    // var ua="Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.8b2) Gecko/20050324 SeaMonkey/1.0a"
-    // var ua="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4"
-    // var ua="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a8pre) Gecko/2007082021 SeaMonkey/2.0a1pre"
-    // var ua="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0rc3) Gecko/20020523"
-    // var ua="Mozilla/5.0 (Windows NT 6.1; rv:2.0) Gecko/20110101 Firefox/4.0 SeaMonkey/2.1"
+    // ua="Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.8b2) Gecko/20050324 SeaMonkey/1.0a"
+    // ua="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4"
+    // ua="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a8pre) Gecko/2007082021 SeaMonkey/2.0a1pre"
+    // ua="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0rc3) Gecko/20020523"
+    // ua="Mozilla/5.0 (Windows NT 6.1; rv:2.0) Gecko/20110101 Firefox/4.0 SeaMonkey/2.1"
+    // ua="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0a1) Gecko/20120201 Firefox/13.0a1 SeaMonkey/2.10a1"
 
     // Search for the Gecko build date in the User Agent string
     const buildID = ua.match(/Gecko\/(\d{8,10})/);
     if (!buildID || !ua.match(/ SeaMonkey\//)) {
       // not SeaMonkey, display a "get SeaMonkey" box
       highlightDownload("download", false);
-      document.getElementById("stable").style.display = "none";
-      document.getElementById("getseamonkey").style.display = "block";
+      displayElement("stable", false);
+      displayElement("getseamonkey", true);
       return;
     }
 
     const smver = ua.match(/SeaMonkey\/([^ ]+)/);
     // stable builds only have digits and dots in their version number!
     const smver_parts = smver[1].split(".");
     if (smver[1].match(/^[\d\.]+$/)) {
       // stable build, leave "friendy" intro box turned on
@@ -54,62 +59,63 @@
         else if (parseInt(curver_parts[i]) < parseInt(smver_parts[i])) {
           break;
         }
       }
       if (oldversion) {
         highlightDownload("dlnew", false);
         var vertext = document.createTextNode(" (" + smver[1] + ")");
         document.getElementById("oldvernumber").appendChild(vertext);
-        document.getElementById("stable").style.display = "none";
-        document.getElementById("oldstable").style.display = "block";
+        displayElement("stable", false);
+        displayElement("oldstable", true);
       }
     }
     else {
       // unstable build or prerelease, test if nagging box should be displayed
-      document.getElementById("stable").style.display = "none";
-      document.getElementById("unstable").style.display = "block";
-      document.getElementById("stablenote").style.display = "none";
-      document.getElementById("unstablenote").style.display = "block";
+      displayElement("stable", false);
+      displayElement("unstable", true);
+      displayElement("stablenote", false);
+      displayElement("unstablenote", true);
 
       // prereleases have a version number with a/b in it, possibly digits afterwards
-      if (smver[1].match(/^[\d\.]+[ab]\d*$/)) {
+      // however, rapid release train nightlies end with a1
+      const prerel_parts = smver[1].match(/^[\d\.]+([ab]\d*)$/);
+      if (prerel_parts && prerel_parts[1] != "a1") {
         // check for version number and display a warning and download box if we have a newer version
         const curbeta = "[% betaversion %]";
         const curbeta_parts = curbeta.split(".");
         var oldbeta = false;
         for (var i = 0; i < curbeta_parts.length; i++) {
-          // don't use parseInt() for beta - this mean that parts with numbers
+          // don't use parseInt() for beta - this means that parts with numbers
           // larger than 9 are incorrect but alphas and betas are correct
           if (curbeta_parts[i] > smver_parts[i]) {
             oldbeta = true;
           }
           else if (curbeta_parts[i] < smver_parts[i]) {
             break;
           }
         }
         if (oldbeta) {
-          document.getElementById("nagBox-beta").style.display = "block";
+          displayElement("nagBox-beta", true);
         }
       }
       else {
         // milliseconds per day
         const msecsPerDay = 86400000;
         const nagLimit = 28 * msecsPerDay;
 
         // construct build date from ID
         const buildDate = new Date(buildID[1].substr(0,4),
                                    buildID[1].substr(4,2)-1,
                                    buildID[1].substr(6,2));
 
         const today = new Date();
-
         if (today - buildDate > nagLimit) {
           // build is old. Show the nag box
-          document.getElementById("nagBox").style.display = "block";
+          displayElement("nagBox", true);
         }
       }
     }
   }
 
   addEventListener("load", buildTest, true);
   // -->
 </script>
--- a/src/start/index.de.html
+++ b/src/start/index.de.html
@@ -12,33 +12,38 @@
 
 <script type="text/javascript" src="/download.js"></script>
 
 <title>Willkommen bei SeaMonkey</title>
 </head>
 <body>
 <h1>Willkommen bei SeaMonkey</h1>
 
-<script type="text/javascript"> <!--
+<script type="text/javascript"><!--
+  function displayElement(el, show) {
+    document.getElementById(el).style.display = show ? "block" : "none";
+  }
+
   function buildTest() {
     var ua = navigator.userAgent;
     // Uncomment one of those user agents to test this script
-    // var ua="Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.8b2) Gecko/20050324 SeaMonkey/1.0a"
-    // var ua="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4"
-    // var ua="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a8pre) Gecko/2007082021 SeaMonkey/2.0a1pre"
-    // var ua="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0rc3) Gecko/20020523"
-    // var ua="Mozilla/5.0 (Windows NT 6.1; rv:2.0) Gecko/20110101 Firefox/4.0 SeaMonkey/2.1"
+    // ua="Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.8b2) Gecko/20050324 SeaMonkey/1.0a"
+    // ua="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4"
+    // ua="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a8pre) Gecko/2007082021 SeaMonkey/2.0a1pre"
+    // ua="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0rc3) Gecko/20020523"
+    // ua="Mozilla/5.0 (Windows NT 6.1; rv:2.0) Gecko/20110101 Firefox/4.0 SeaMonkey/2.1"
+    // ua="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0a1) Gecko/20120201 Firefox/13.0a1 SeaMonkey/2.10a1"
 
     // Search for the Gecko build date in the User Agent string
     const buildID = ua.match(/Gecko\/(\d{8,10})/);
     if (!buildID || !ua.match(/ SeaMonkey\//)) {
       // not SeaMonkey, display a "get SeaMonkey" box
       highlightDownload("download", false);
-      document.getElementById("stable").style.display = "none";
-      document.getElementById("getseamonkey").style.display = "block";
+      displayElement("stable", false);
+      displayElement("getseamonkey", true);
       return;
     }
 
     const smver = ua.match(/SeaMonkey\/([^ ]+)/);
     // stable builds only have digits and dots in their version number!
     const smver_parts = smver[1].split(".");
     if (smver[1].match(/^[\d\.]+$/)) {
       // stable build, leave "friendy" intro box turned on
@@ -54,62 +59,63 @@
         else if (parseInt(curver_parts[i]) < parseInt(smver_parts[i])) {
           break;
         }
       }
       if (oldversion) {
         highlightDownload("dlnew", false);
         var vertext = document.createTextNode(" (" + smver[1] + ")");
         document.getElementById("oldvernumber").appendChild(vertext);
-        document.getElementById("stable").style.display = "none";
-        document.getElementById("oldstable").style.display = "block";
+        displayElement("stable", false);
+        displayElement("oldstable", true);
       }
     }
     else {
       // unstable build or prerelease, test if nagging box should be displayed
-      document.getElementById("stable").style.display = "none";
-      document.getElementById("unstable").style.display = "block";
-      document.getElementById("stablenote").style.display = "none";
-      document.getElementById("unstablenote").style.display = "block";
+      displayElement("stable", false);
+      displayElement("unstable", true);
+      displayElement("stablenote", false);
+      displayElement("unstablenote", true);
 
       // prereleases have a version number with a/b in it, possibly digits afterwards
-      if (smver[1].match(/^[\d\.]+[ab]\d*$/)) {
+      // however, rapid release train nightlies end with a1
+      const prerel_parts = smver[1].match(/^[\d\.]+([ab]\d*)$/);
+      if (prerel_parts && prerel_parts[1] != "a1") {
         // check for version number and display a warning and download box if we have a newer version
         const curbeta = "[% betaversion %]";
         const curbeta_parts = curbeta.split(".");
         var oldbeta = false;
         for (var i = 0; i < curbeta_parts.length; i++) {
-          // don't use parseInt() for beta - this mean that parts with numbers
+          // don't use parseInt() for beta - this means that parts with numbers
           // larger than 9 are incorrect but alphas and betas are correct
           if (curbeta_parts[i] > smver_parts[i]) {
             oldbeta = true;
           }
           else if (curbeta_parts[i] < smver_parts[i]) {
             break;
           }
         }
         if (oldbeta) {
-          document.getElementById("nagBox-beta").style.display = "block";
+          displayElement("nagBox-beta", true);
         }
       }
       else {
         // milliseconds per day
         const msecsPerDay = 86400000;
         const nagLimit = 28 * msecsPerDay;
 
         // construct build date from ID
         const buildDate = new Date(buildID[1].substr(0,4),
                                    buildID[1].substr(4,2)-1,
                                    buildID[1].substr(6,2));
 
         const today = new Date();
-
         if (today - buildDate > nagLimit) {
           // build is old. Show the nag box
-          document.getElementById("nagBox").style.display = "block";
+          displayElement("nagBox", true);
         }
       }
     }
   }
 
   addEventListener("load", buildTest, true);
   // -->
 </script>
--- a/src/start/index.en.html
+++ b/src/start/index.en.html
@@ -12,33 +12,38 @@
 
 <script type="text/javascript" src="/download.js"></script>
 
 <title>Welcome to SeaMonkey</title>
 </head>
 <body>
 <h1>Welcome to SeaMonkey</h1>
 
-<script type="text/javascript"> <!--
+<script type="text/javascript"><!--
+  function displayElement(el, show) {
+    document.getElementById(el).style.display = show ? "block" : "none";
+  }
+
   function buildTest() {
     var ua = navigator.userAgent;
     // Uncomment one of those user agents to test this script
-    // var ua="Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.8b2) Gecko/20050324 SeaMonkey/1.0a"
-    // var ua="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4"
-    // var ua="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a8pre) Gecko/2007082021 SeaMonkey/2.0a1pre"
-    // var ua="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0rc3) Gecko/20020523"
-    // var ua="Mozilla/5.0 (Windows NT 6.1; rv:2.0) Gecko/20110101 Firefox/4.0 SeaMonkey/2.1"
+    // ua="Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.8b2) Gecko/20050324 SeaMonkey/1.0a"
+    // ua="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4"
+    // ua="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a8pre) Gecko/2007082021 SeaMonkey/2.0a1pre"
+    // ua="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0rc3) Gecko/20020523"
+    // ua="Mozilla/5.0 (Windows NT 6.1; rv:2.0) Gecko/20110101 Firefox/4.0 SeaMonkey/2.1"
+    // ua="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0a1) Gecko/20120201 Firefox/13.0a1 SeaMonkey/2.10a1"
 
     // Search for the Gecko build date in the User Agent string
     const buildID = ua.match(/Gecko\/(\d{8,10})/);
     if (!buildID || !ua.match(/ SeaMonkey\//)) {
       // not SeaMonkey, display a "get SeaMonkey" box
       highlightDownload("download", false);
-      document.getElementById("stable").style.display = "none";
-      document.getElementById("getseamonkey").style.display = "block";
+      displayElement("stable", false);
+      displayElement("getseamonkey", true);
       return;
     }
 
     const smver = ua.match(/SeaMonkey\/([^ ]+)/);
     // stable builds only have digits and dots in their version number!
     const smver_parts = smver[1].split(".");
     if (smver[1].match(/^[\d\.]+$/)) {
       // stable build, leave "friendy" intro box turned on
@@ -54,62 +59,63 @@
         else if (parseInt(curver_parts[i]) < parseInt(smver_parts[i])) {
           break;
         }
       }
       if (oldversion) {
         highlightDownload("dlnew", false);
         var vertext = document.createTextNode(" (" + smver[1] + ")");
         document.getElementById("oldvernumber").appendChild(vertext);
-        document.getElementById("stable").style.display = "none";
-        document.getElementById("oldstable").style.display = "block";
+        displayElement("stable", false);
+        displayElement("oldstable", true);
       }
     }
     else {
       // unstable build or prerelease, test if nagging box should be displayed
-      document.getElementById("stable").style.display = "none";
-      document.getElementById("unstable").style.display = "block";
-      document.getElementById("stablenote").style.display = "none";
-      document.getElementById("unstablenote").style.display = "block";
+      displayElement("stable", false);
+      displayElement("unstable", true);
+      displayElement("stablenote", false);
+      displayElement("unstablenote", true);
 
       // prereleases have a version number with a/b in it, possibly digits afterwards
-      if (smver[1].match(/^[\d\.]+[ab]\d*$/)) {
+      // however, rapid release train nightlies end with a1
+      const prerel_parts = smver[1].match(/^[\d\.]+([ab]\d*)$/);
+      if (prerel_parts && prerel_parts[1] != "a1") {
         // check for version number and display a warning and download box if we have a newer version
         const curbeta = "[% betaversion %]";
         const curbeta_parts = curbeta.split(".");
         var oldbeta = false;
         for (var i = 0; i < curbeta_parts.length; i++) {
-          // don't use parseInt() for beta - this mean that parts with numbers
+          // don't use parseInt() for beta - this means that parts with numbers
           // larger than 9 are incorrect but alphas and betas are correct
           if (curbeta_parts[i] > smver_parts[i]) {
             oldbeta = true;
           }
           else if (curbeta_parts[i] < smver_parts[i]) {
             break;
           }
         }
         if (oldbeta) {
-          document.getElementById("nagBox-beta").style.display = "block";
+          displayElement("nagBox-beta", true);
         }
       }
       else {
         // milliseconds per day
         const msecsPerDay = 86400000;
         const nagLimit = 28 * msecsPerDay;
 
         // construct build date from ID
         const buildDate = new Date(buildID[1].substr(0,4),
                                    buildID[1].substr(4,2)-1,
                                    buildID[1].substr(6,2));
 
         const today = new Date();
-
         if (today - buildDate > nagLimit) {
           // build is old. Show the nag box
-          document.getElementById("nagBox").style.display = "block";
+          displayElement("nagBox", true);
         }
       }
     }
   }
 
   addEventListener("load", buildTest, true);
   // -->
 </script>