← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15018: minor fix, don't check appcache for updates if status=0 (appcache not in use)

 

------------------------------------------------------------
revno: 15018
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-04-27 17:08:42 +0545
message:
  minor fix, don't check appcache for updates if status=0 (appcache not in use)
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.appcache.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.appcache.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.appcache.js	2013-12-20 14:54:16 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.appcache.js	2014-04-27 11:23:42 +0000
@@ -30,29 +30,31 @@
 dhis2['appcache'] = dhis2['appcache'] || {};
 
 function applicationCacheSupported() {
-    return typeof window.applicationCache !== 'undefined';
+  return typeof window.applicationCache !== 'undefined';
 }
 
 $(function() {
-    if(!applicationCacheSupported()) {
-        return;
+  if( !applicationCacheSupported() ) {
+    return;
+  }
+
+  $(window.applicationCache).on('updateready', function( e ) {
+    if( window.applicationCache.status == window.applicationCache.UPDATEREADY ) {
+      // Browser downloaded a new app cache.
+      if( confirm('An update is available. Refresh to update?') ) {
+        window.location.reload();
+      }
     }
-
-    $(window.applicationCache).on('updateready', function( e ) {
-        if( window.applicationCache.status == window.applicationCache.UPDATEREADY ) {
-            // Browser downloaded a new app cache.
-            if( confirm('An update is available. Refresh to update?') ) {
-                window.location.reload();
-            }
-        }
-    });
-
+  });
+
+  if( window.applicationCache.status > 0 ) {
     $(document).on('dhis2.online', function() {
-        dhis2.appcache.updateAppCache();
+      dhis2.appcache.updateAppCache();
     });
+  }
 });
 
 dhis2.appcache.updateAppCache = function() {
-    // check and download updated appcache, will fire of updateready
-    window.applicationCache.update();
+  // check and download updated appcache, will fire of updateready
+  window.applicationCache.update();
 };