Skip to content
Browse files

read required version from query string, and fix version comparator

  • Loading branch information...
1 parent a0fd088 commit ce1a27940226b08856d5d67d6451f11f3a5d8881 @bluesmoon committed Jan 25, 2013
Showing with 13 additions and 16 deletions.
  1. +5 −8 boomerang-reload.html
  2. +8 −8 doc/api/cache_reload.html
View
13 boomerang-reload.html
@@ -6,17 +6,14 @@
<body>
<script>
var boom_ver = BOOMR.version.split('.'),
- reqd_ver = [0, 9, 123456789]; // change this to required version
-if ( boom_ver[0] < reqd_ver[0] // javascript will do type coercion
- || boom_ver[1] < reqd_ver[1]
- || boom_ver[2] < reqd_ver[2])
+ reqd_ver = location.search.replace(/.*v=([0-9\.]+).*/, '$1').split('.');
+if ( (boom_ver[0] < reqd_ver[0]) // javascript will do type coercion
+ || (boom_ver[0] == reqd_ver[0] && boom_ver[1] < reqd_ver[1])
+ || (boom_ver[0] == reqd_ver[0] && boom_ver[1] == reqd_ver[1] && boom_ver[2] < reqd_ver[2])
+)
{
location.reload(true);
}
-else
-{
- location.replace("about:blank");
-}
</script>
</body>
</html>
View
16 doc/api/cache_reload.html
@@ -81,18 +81,18 @@ <h2 id="example">Example HTML document</h2>
&lt;/head&gt;
&lt;body&gt;
&lt;script&gt;
+// required version needs to be passed in as a query string parameter
+// like v=0.9.123456789
+
var boom_ver = BOOMR.version.split('.'),
- reqd_ver = [0, 9, 123456789]; // change this to required version
-if ( boom_ver[0] &lt; reqd_ver[0] // javascript will do type coercion
- || boom_ver[1] &lt; reqd_ver[1]
- || boom_ver[2] &lt; reqd_ver[2])
+ reqd_ver = location.search.replace(/.*v=([0-9\.]+).*/, '$1').split('.');
+if ( (boom_ver[0] &lt; reqd_ver[0]) // javascript will do type coercion
+ || (boom_ver[0] == reqd_ver[0] &amp;&amp; boom_ver[1] &lt; reqd_ver[1])
+ || (boom_ver[0] == reqd_ver[0] &amp;&amp; boom_ver[1] == reqd_ver[1] &amp;&amp; boom_ver[2] &lt; reqd_ver[2])
+)
{
location.reload(true);
}
-else
-{
- location.replace("about:blank");
-}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

0 comments on commit ce1a279

Please sign in to comment.
Something went wrong with that request. Please try again.