=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.dom.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.dom.js 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.dom.js 2013-02-14 14:38:04 +0000 @@ -0,0 +1,121 @@ +// web storage support (localStorage) +dhis2.storage.Store.adapter( 'dom', (function () { + var storage = window.localStorage; + + var indexer = function ( name ) { + return { + key: name + '.__index__', + + all: function () { + var a = storage.getItem( this.key ); + + if ( a ) { + try { + a = JSON.parse( a ); + } catch ( e ) { + a = null; + } + } + + if ( a == null ) { + storage.setItem( this.key, JSON.stringify( [] ) ); + } + + return JSON.parse( storage.getItem( this.key ) ); + }, + + add: function ( key ) { + var a = this.all(); + a.push( key ); + storage.setItem( this.key, JSON.stringify( a ) ); + }, + + remove: function ( key ) { + var a = this.all(); + + if ( a.indexOf( key ) != -1 ) { + dhis2.array.remove( a, a.indexOf( key ), a.indexOf( key ) ); + storage.setItem( this.key, JSON.stringify( a ) ); + } + }, + + find: function ( key ) { + var a = this.all(); + return a.indexOf( key ); + } + } + } + + return { + valid: function () { + return !!storage; + }, + + init: function ( options, callback ) { + this.indexer = indexer( this.name ); + if ( callback ) callback.call( this, this, options ); + }, + + save: function ( key, obj, callback ) { + var key = this.name + '.' + key; + if ( this.indexer.find( key ) == -1 ) this.indexer.add( key ); + storage.setItem( key, JSON.stringify( obj ) ); + if ( callback ) callback.call( this, this, obj ); + + return this; + }, + + remove: function ( key, callback ) { + var key = this.name + '.' + key; + this.indexer.remove( key ); + storage.removeItem( key ); + if ( callback ) callback.call( this, this ); + + return this; + }, + + exists: function ( key, callback ) { + key = this.name + '.' + key; + var success = storage.getItem( key ) != null; + if ( callback ) callback.call( this, this, success ); + + return this; + }, + + keys: function ( callback ) { + var that = this; + var keys = this.indexer.all().map( function ( r ) { + return r.replace( that.name + '.', '' ) + } ); + + if ( callback ) callback.call( this, this, keys ); + + return this; + }, + + load: function ( key, callback ) { + key = this.name + '.' + key; + var obj = storage.getItem( key ); + + if ( obj ) { + obj = JSON.parse( obj ); + if ( callback ) callback.call( this, this, obj ); + } + + return this; + }, + + all: function ( callback ) { + var idx = this.indexer.all(); + var arr = []; + + for ( var k = 0; k < idx.length; k++ ) { + arr.push( JSON.parse( storage.getItem( idx[k] ) ) ); + } + + if ( callback ) callback.call( this, this, arr ); + + return this; + } + }; +})() ); === added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.idb.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.idb.js 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.idb.js 2013-02-14 14:38:04 +0000 @@ -0,0 +1,37 @@ +// web storage support (indexedDb) +dhis2.storage.Store.adapter( 'indexed-db', (function () { + function getIDB() { + return window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.oIndexedDB || window.msIndexedDB; + } + + return { + valid: function () { + return false; + // return !!getIDB(); + }, + + init: function ( options, callback ) { + throw 'Init not implemented' + }, + + save: function ( key, obj, callback ) { + throw 'Save not implemented' + }, + + remove: function ( key, callback ) { + throw 'Remove not implemented' + }, + + exists: function ( key, callback ) { + throw 'Exists not implemented' + }, + + load: function ( key, callback ) { + throw 'Load not implemented' + }, + + all: function ( callback ) { + throw 'All not implemented' + } + }; +})() ); === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.js 2013-02-14 14:20:13 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.js 2013-02-14 14:38:04 +0000 @@ -70,163 +70,3 @@ obj['id'] = id; Store.adapters.splice( 0, 0, obj ); }; - -// web storage support (localStorage) -dhis2.storage.Store.adapter( 'dom', (function () { - var storage = window.localStorage; - - var indexer = function ( name ) { - return { - key: name + '.__index__', - - all: function () { - var a = storage.getItem( this.key ); - - if ( a ) { - try { - a = JSON.parse( a ); - } catch ( e ) { - a = null; - } - } - - if ( a == null ) { - storage.setItem( this.key, JSON.stringify( [] ) ); - } - - return JSON.parse( storage.getItem( this.key ) ); - }, - - add: function ( key ) { - var a = this.all(); - a.push( key ); - storage.setItem( this.key, JSON.stringify( a ) ); - }, - - remove: function ( key ) { - var a = this.all(); - - if ( a.indexOf( key ) != -1 ) { - dhis2.array.remove( a, a.indexOf( key ), a.indexOf( key ) ); - storage.setItem( this.key, JSON.stringify( a ) ); - } - }, - - find: function ( key ) { - var a = this.all(); - return a.indexOf( key ); - } - } - } - - return { - valid: function () { - return !!storage; - }, - - init: function ( options, callback ) { - this.indexer = indexer( this.name ); - if ( callback ) callback.call( this, this, options ); - }, - - save: function ( key, obj, callback ) { - var key = this.name + '.' + key; - if ( this.indexer.find( key ) == -1 ) this.indexer.add( key ); - storage.setItem( key, JSON.stringify( obj ) ); - if ( callback ) callback.call( this, this, obj ); - - return this; - }, - - remove: function ( key, callback ) { - var key = this.name + '.' + key; - this.indexer.remove( key ); - storage.removeItem( key ); - if ( callback ) callback.call( this, this ); - - return this; - }, - - exists: function ( key, callback ) { - key = this.name + '.' + key; - var success = storage.getItem( key ) != null; - if ( callback ) callback.call( this, this, success ); - - return this; - }, - - keys: function ( callback ) { - var that = this; - var keys = this.indexer.all().map( function ( r ) { - return r.replace( that.name + '.', '' ) - } ); - - if ( callback ) callback.call( this, this, keys ); - - return this; - }, - - load: function ( key, callback ) { - key = this.name + '.' + key; - var obj = storage.getItem( key ); - - if ( obj ) { - obj = JSON.parse( obj ); - if ( callback ) callback.call( this, this, obj ); - } - - return this; - }, - - all: function ( callback ) { - var idx = this.indexer.all(); - var arr = []; - - for ( var k = 0; k < idx.length; k++ ) { - arr.push( JSON.parse( storage.getItem( idx[k] ) ) ); - } - - if ( callback ) callback.call( this, this, arr ); - - return this; - } - }; -})() ); - -// web storage support (indexedDb) -dhis2.storage.Store.adapter( 'indexed-db', (function () { - function getIDB() { - return window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.oIndexedDB || window.msIndexedDB; - } - - return { - valid: function () { - return false; - // return !!getIDB(); - }, - - init: function ( options, callback ) { - throw 'Init not implemented' - }, - - save: function ( key, obj, callback ) { - throw 'Save not implemented' - }, - - remove: function ( key, callback ) { - throw 'Remove not implemented' - }, - - exists: function ( key, callback ) { - throw 'Exists not implemented' - }, - - load: function ( key, callback ) { - throw 'Load not implemented' - }, - - all: function ( callback ) { - throw 'All not implemented' - } - }; -})() ); === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm 2013-02-14 14:00:36 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm 2013-02-14 14:38:04 +0000 @@ -8,7 +8,7 @@ #foreach ( $style in $stylesheets ) - #end + #end @@ -18,7 +18,7 @@ - + @@ -48,20 +48,22 @@ + + - + #foreach( $javascript in $javascripts ) #end - - + + #parse( "macros.vm" ) #end @@ -95,20 +97,20 @@ #foreach( $module in $serviceModules )
  • $i18n.getString( $module.name ) 
  • #end - + #end - + - +