Changeset 21042 for lang/javascript/Grease
- Timestamp:
- 10/09/08 17:14:31 (3 months ago)
- Files:
-
- 1 modified
-
lang/javascript/Grease/trunk/grease.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/Grease/trunk/grease.js
r20990 r21042 17 17 var ManagedStore = this.ManagedStore = { 18 18 /** 19 * @var GearsLocalServer20 */21 ls: factory.create('beta.localserver'),22 /**23 19 * Creates (or opens) managed resource store. 24 20 * @param string name … … 27 23 */ 28 24 create: function() { 29 var store = this.ls.createManagedStore.apply(this.ls, arguments);30 return this.extend( store);25 var ls = factory.create('beta.localserver'); 26 return this.extend(ls.createManagedStore.apply(ls, arguments)); 31 27 }, 32 28 /** … … 36 32 */ 37 33 remove: function() { 38 this.ls.removeManagedStore.apply(this.ls, arguments); 34 var ls = factory.create('beta.localserver'); 35 ls.removeManagedStore.apply(ls, arguments); 39 36 }, 40 37 /** … … 52 49 /** 53 50 * A handy method to get/set manifestUrl. 51 * @param string url (optional) 52 * @return string|GearsManagedResourceStore 54 53 */ 55 54 manifest: function(url) { … … 60 59 return this; 61 60 } 61 }, 62 /** 63 * Checks for update and calls back on complete/error. 64 * @param string url (optional) The URL of manifest file. 65 * @param object options (optional) { oncomplete: callback, onerror: callback } 66 * @return GearsManagedResourceStore Fluent interface. 67 */ 68 update: function(url, options) { 69 var store = this, oldVersion = store.currentVersion; 70 store.manifest(url); 71 store.checkForUpdate(); 72 73 // emulate events 74 if (options) { 75 var timer = window.setInterval(function() { 76 if (store.updateStatus == 0) { 77 window.clearInterval(timer); 78 if (options.oncomplete) { 79 var newVersion = store.currentVersion; 80 options.oncomplete({ newVersion: (oldVersion != newVersion) ? newVersion : '' }); 81 } 82 } else if (store.updateStatus == 3) { 83 window.clearInterval(timer); 84 if (options.onerror) { 85 options.onerror({ message: store.lastErrorMessage }); 86 } 87 } 88 }, 500); 89 } 90 91 return this; 62 92 } 63 93 } … … 71 101 var Db = this.Db = { 72 102 /** 73 * Opens database.103 * Creates database object. 74 104 * @param string name Database name. 75 105 * @return GearsDatabase Extended GearsDatabase object. 76 106 */ 77 open: function(name) {107 create: function(name) { 78 108 var db = factory.create('beta.database'); 79 109 db.open(name); … … 231 261 */ 232 262 Db.Table = function(db, table, primary) { 233 this.db = Db[(typeof db == 'string') ? ' open' : 'extend'](db);263 this.db = Db[(typeof db == 'string') ? 'create' : 'extend'](db); 234 264 this.table = '"' + table + '"'; 235 265 this.primary = '"' + primary + '"';
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)