← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13296: if newer appcache is available, notify user, and ask to reload page

 

------------------------------------------------------------
revno: 13296
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-12-18 09:58:53 +0100
message:
  if newer appcache is available, notify user, and ask to reload page
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.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.util.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js	2013-08-23 16:11:13 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.util.js	2013-12-18 08:58:53 +0000
@@ -37,12 +37,12 @@
  *
  * @returns {object} Namespace object
  */
-dhis2.util.namespace = function ( path ) {
-    var parts = path.split( '.' );
+dhis2.util.namespace = function( path ) {
+    var parts = path.split('.');
     var parent = window;
     var currentPart = '';
 
-    for ( var i = 0, length = parts.length; i < length; i++ ) {
+    for( var i = 0, length = parts.length; i < length; i++ ) {
         currentPart = parts[i];
         parent[currentPart] = parent[currentPart] || {};
         parent = parent[currentPart];
@@ -54,49 +54,49 @@
 /**
  * Escape function for regular expressions.
  */
-dhis2.util.escape = function ( text ) {
-    return text.replace( /[-[\]{}()*+?.,\/\\^$|#\s]/g, "\\$&" );
+dhis2.util.escape = function( text ) {
+    return text.replace(/[-[\]{}()*+?.,\/\\^$|#\s]/g, "\\$&");
 };
 
 /**
  * jQuery cannot correctly filter strings with () in them, so here is a fix
  * until jQuery gets updated.
  */
-dhis2.util.jqTextFilterCaseSensitive = function ( key, not ) {
-    key = dhis2.util.escape( key );
-    not = not || false;
-
-    if ( not ) {
-        return function ( i, el ) {
-            return !!!$( el ).text().match( "" + key );
-        };
-    }
-    else {
-        return function ( i, el ) {
-            return !!$( el ).text().match( "" + key );
-        };
-    }
-};
-
-dhis2.util.jqTextFilter = function ( key, not ) {
-    key = dhis2.util.escape( key ).toLowerCase();
-    not = not || false;
-
-    if ( not ) {
-        return function ( i, el ) {
-            return !!!$( el ).text().toLowerCase().match( "" + key );
-        };
-    }
-    else {
-        return function ( i, el ) {
-            return !!$( el ).text().toLowerCase().match( "" + key );
-        };
-    }
-};
-
-dhis2.util.uuid = function () {
-    var S4 = function () {
-        return (((1 + Math.random()) * 0x10000) | 0).toString( 16 ).substring( 1 );
+dhis2.util.jqTextFilterCaseSensitive = function( key, not ) {
+    key = dhis2.util.escape(key);
+    not = not || false;
+
+    if( not ) {
+        return function( i, el ) {
+            return !!!$(el).text().match("" + key);
+        };
+    }
+    else {
+        return function( i, el ) {
+            return !!$(el).text().match("" + key);
+        };
+    }
+};
+
+dhis2.util.jqTextFilter = function( key, not ) {
+    key = dhis2.util.escape(key).toLowerCase();
+    not = not || false;
+
+    if( not ) {
+        return function( i, el ) {
+            return !!!$(el).text().toLowerCase().match("" + key);
+        };
+    }
+    else {
+        return function( i, el ) {
+            return !!$(el).text().toLowerCase().match("" + key);
+        };
+    }
+};
+
+dhis2.util.uuid = function() {
+    var S4 = function() {
+        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
     };
 
     return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
@@ -106,17 +106,17 @@
  * adds ':containsNC' to filtering.
  * $(sel).find(':containsNC(key)').doSomething();
  */
-$.expr[":"].containsNC = function ( a, i, m, r ) {
-    var search = dhis2.util.escape( m[3] );
-    return jQuery( a ).text().toUpperCase().indexOf( m[search].toUpperCase() ) >= 0;
+$.expr[":"].containsNC = function( a, i, m, r ) {
+    var search = dhis2.util.escape(m[3]);
+    return jQuery(a).text().toUpperCase().indexOf(m[search].toUpperCase()) >= 0;
 };
 
 /**
  * adds ':regex' to filtering, use to filter by regular expression
  */
-$.expr[":"].regex = function ( a, i, m, r ) {
-    var re = new RegExp( m[3], 'i' );
-    return re.test( jQuery( a ).text() );
+$.expr[":"].regex = function( a, i, m, r ) {
+    var re = new RegExp(m[3], 'i');
+    return re.test(jQuery(a).text());
 };
 
 /**
@@ -124,9 +124,9 @@
  *
  * (this is the case sensitive version)
  */
-$.expr[":"].regexCS = function ( a, i, m, r ) {
-    var re = new RegExp( m[3] );
-    return re.test( jQuery( a ).text() );
+$.expr[":"].regexCS = function( a, i, m, r ) {
+    var re = new RegExp(m[3]);
+    return re.test(jQuery(a).text());
 };
 
 /**
@@ -135,12 +135,12 @@
  *
  * @returns array of keys
  */
-if ( !Object.keys ) {
-    Object.keys = function ( obj ) {
+if( !Object.keys ) {
+    Object.keys = function( obj ) {
         var keys = new Array();
-        for ( k in obj )
-            if ( obj.hasOwnProperty( k ) )
-                keys.push( k );
+        for( k in obj )
+            if( obj.hasOwnProperty(k) )
+                keys.push(k);
         return keys;
     };
 }
@@ -149,8 +149,19 @@
  * Define a window.log object, and output to console.log if it exists. (this is
  * a fix for IE8 and FF 3.6).
  */
-window.log = function ( str ) {
-    if ( this.console ) {
-        console.log( str );
+window.log = function( str ) {
+    if( this.console ) {
+        console.log(str);
     }
 };
+
+$(function() {
+    $(window.applicationCache).on('updateready', function( e ) {
+        if( window.applicationCache.status == window.applicationCache.UPDATEREADY ) {
+            // Browser downloaded a new app cache.
+            if( confirm('A new version of this site is available. Load it?') ) {
+                window.location.reload();
+            }
+        }
+    });
+});