diff --git a/ui (gen4)/features/config.js b/ui (gen4)/features/config.js index e6ed9d50..e240e09b 100755 --- a/ui (gen4)/features/config.js +++ b/ui (gen4)/features/config.js @@ -36,6 +36,7 @@ var TimersActions = actions.Actions({ __timeouts: null, __intervals: null, + __persistent_intervals: null, // XXX should these be actions??? @@ -87,18 +88,68 @@ var TimersActions = actions.Actions({ delete intervals[id] }], - // XXX start all on .start(..) and stop on .stop(..)... + // XXX assert that func is a string... + // ...wrap func... setPersistentInterval: ['- System/', - function(id, func, ms){ - // XXX + core.doc` + + Restart interval id... + .setPersistentInterval(id) + + Save/start interval id... + .setPersistentInterval(id, action, ms) + + `, + function(id, action, ms){ + var cfg = + this.config['persistent-intervals'] = + this.config['persistent-intervals'] || {} + var intervals = + this.__persistent_intervals = + this.__persistent_intervals || {} + + // get defaults... + action = action ? action : cfg[id].action + ms = ms ? ms : cfg[id].ms + + // checks... + if(!ms || !action){ + console.error('Persistent interval: both action and ms must be set.') + return + } + if(typeof(action) != typeof('str')){ + console.error('Persistent interval: handler must be a string.') + return + } + + id in intervals + && clearInterval(intervals[id]) + + cfg[id] = { + action: action, + ms: ms, + } + + timeouts[id] = setInterval( + function(){ this.call(action) }.bind(this), + ms || 0) }], - // XXX clearPersistentInterval: ['- System/', function(id){ - var intervals = this.config['persistent-intervals'] = this.config['persistent-intervals'] || {} + var intervals = + this.__persistent_intervals = + this.__persistent_intervals || {} clearInterval(intervals[id]) delete intervals[id] + delete this.config['persistent-intervals'][id] }], + // XXX add start/restart/stop persistent actions... + // to start all: + // Object.keys(this.config['persistent-intervals'] || {}) + // .forEach(function(id){ + // this.setPersistentInterval(id) }.bind(this)) + // to stop all: + // XXX }) var Timers = @@ -111,9 +162,23 @@ module.Timers = core.ImageGridFeatures.Feature({ ], actions: Timers, + + // XXX start all on .start(..) and stop on .stop(..)... + handlers: [ + // XXX should this be start or start??? + ['start', + function(){ + // XXX + }], + ['stop', + function(){ + // XXX + }], + ], }) + /*********************************************************************/ // XXX move store to a separate module... diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 521132f2..605fcf47 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -990,6 +990,7 @@ var UIIntrospectionActions = actions.Actions({ // Show doc for action... // // XXX STUB... + // XXX handle non-action methods... // XXX this needs to: // - be a widget // - handle focus diff --git a/ui (gen4)/package-lock.json b/ui (gen4)/package-lock.json index 289cb12b..4f7348e8 100755 --- a/ui (gen4)/package-lock.json +++ b/ui (gen4)/package-lock.json @@ -931,9 +931,9 @@ "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" }, "ig-actions": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.12.0.tgz", - "integrity": "sha512-9fRwJKN2K9lP87NS5Cagdp5CEu/Z4CYF59dv++1IjNkvGmrpgHV41nSSW90vk8p1yKlu3zBV6+i7suLFljT90g==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.14.0.tgz", + "integrity": "sha512-ZKKAMGee+/yJz0Arfc9ZHP14mgEu7Z7MjlX205KzdXLLdvXgd5r6TGMZs6qo4jHqznAheIr5IeF0RcCq5MwGzA==", "requires": { "ig-object": "1.0.2" } @@ -943,7 +943,7 @@ "resolved": "https://registry.npmjs.org/ig-features/-/ig-features-3.3.2.tgz", "integrity": "sha512-NSvuVkLUI47f1mpG03/fVqJaMYLDUFVcg2FNXUtqvDqQqKhlZuXJfxsGcoFQ1eIZ1pqYcYeYHmjNbgmK6rT5cA==", "requires": { - "ig-actions": "3.12.0", + "ig-actions": "3.14.0", "ig-object": "1.0.2" } }, diff --git a/ui (gen4)/package.json b/ui (gen4)/package.json index 0f7a40bc..2d7f120a 100755 --- a/ui (gen4)/package.json +++ b/ui (gen4)/package.json @@ -26,7 +26,7 @@ "fs-walk": "^0.0.1", "glob": "^4.0.6", "guarantee-events": "^1.0.0", - "ig-actions": "^3.12.0", + "ig-actions": "^3.14.0", "ig-features": "^3.3.2", "ig-object": "^1.0.2", "moment": "^2.20.1",