From 8860ec5b9f362284b66a2abbefe7071bf756c768 Mon Sep 17 00:00:00 2001 From: suVene Date: Mon, 15 Dec 2008 16:51:03 +0000 Subject: * growl.css - add head link style. * observer_growl.js - add hyperlink.mod default life 10 seconds. * subject_hatelabo_bottle.js - parse permalink. * notifier.js - follow pluginManager.etc. git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@26822 d0d07461-0603-4401-acd4-de1884942a52 --- notifier.js | 135 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 70 insertions(+), 65 deletions(-) (limited to 'notifier.js') diff --git a/notifier.js b/notifier.js index 2b084ba..6bc6277 100644 --- a/notifier.js +++ b/notifier.js @@ -1,110 +1,113 @@ // PLUGIN_INFO//{{{ var PLUGIN_INFO = - {name} + {NAME} notice of change framework. 変更通知フレームワーク。 suVene - 0.1.1 + 0.1.2 2.0pre 2.0pre ; //}}} @@ -167,12 +170,13 @@ function bootstrap() { this.initialize.apply(this, arguments); }; Message.prototype = { - initialize: function(title, message, options) { + initialize: function(title, message, link, options) { try { if (typeof title == 'undefined' || title == null) throw 'title is undefined.'; if (typeof message == 'undefined' || message == null) throw 'message is undefined.'; this.title = title; this.message = message; + this.link = link; this.options = options; } catch (e) { logger.log('Message.initialize error: ' + e); @@ -232,7 +236,7 @@ function bootstrap() { var req = new libly.Request( this.options.url, this.options.headers, - this.options.extra + $U.extend({ asynchronous: true }, this.options.extra) ); req.addEventListener('onSuccess', $U.bind(this, function(res) { logger.log('initialized'); @@ -249,7 +253,7 @@ function bootstrap() { var req = new libly.Request( this.options.url, this.options.headers, - this.options.extra + $U.extend({ asynchronous: false }, this.options.extra) ); req.addEventListener('onSuccess', $U.bind(this, function(res) { var parsed, diff; @@ -258,7 +262,7 @@ function bootstrap() { if (diff && (typeof diff.length != 'undefined' && diff.length > 0)) { this.cache = parsed; if (typeof this.buildMessages == 'function') { - let messages = this.buildMessages([].concat(diff)); + let messages = this.buildMessages(diff); [].concat(messages).forEach($U.bind(this, function(m) { this.notify(m); liberator.sleep(1500); @@ -267,7 +271,8 @@ function bootstrap() { } })); req.get(); - } + }, + diff: function(cache, parsed) cache });//}}} var Notifier = function() {//{{{ @@ -337,11 +342,11 @@ function bootstrap() { liberator.dump('window:' + window.content.window); this.subjects.getPlugins().forEach(function(s) { let now = new Date(); - if (!s.__nextTime) s.nexttime = now; + if (!s.__nextTime) s.__nextTime = now; if (s.interval > 0 && !s.isActive && s.__nextTime <= now) { + s.isActive = true; setTimeout(function() { let start = (new Date()).getTime(); - s.isActive = true; if (typeof s.check == 'function') try { s.check(); } catch (e) { logger.log('subject.check error: ' + e) } let stop = (new Date()).getTime(); -- cgit v1.2.3