Author: jmorliaguet Date: Sun Feb 5 12:25:37 2006 New Revision: 2297 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log:
- initial "local storage" implementation - not very robust but good enough for testing. Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Sun Feb 5 12:25:37 2006 @@ -787,14 +787,28 @@ CPSSkins.LocalStorage.prototype = Object.extend( new CPSSkins.StorageAdapter(), { + setup: function() { + this.id = this.model.def.storage.id; + this.cookie_name = 'cpsskins_local_storage_' + this.id; + }, + requestData: function() { - /* nothing to do since the data is already there */ - CPSSkins.notify('stored', this); + var results = document.cookie.match(this.cookie_name + '=(.*?)(;|$)'); + if (results) { + var value = unescape(results[1]); + data = JSON.parse(value); + this.write(data); + CPSSkins.notify('stored', this); + } else { + return; + } }, storeData: function(data) { - /* Store the data directly */ this.write(data); + value = escape(JSON.stringify(data)); + document.cookie = this.cookie_name + '=' + value + '; path=/'; + CPSSkins.notify('stored', this); } -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins