aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsuVene2009-01-02 18:22:47 +0000
committersuVene2009-01-02 18:22:47 +0000
commitfd596c870dbacce1f31bcf5cd58281931744c4a8 (patch)
tree86776653315a97367f41eea98cb8fd1375f5a9ea
parentbb9f9df702dde21b8ec258121226c1abdfbf8589 (diff)
downloadvimperator-plugins-fd596c870dbacce1f31bcf5cd58281931744c4a8.tar.bz2
add "subject_liberator_echomsg.js".
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@27801 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r--notifier.js9
-rwxr-xr-xnotifier/subject_liberator_echomsg.js71
2 files changed, 78 insertions, 2 deletions
diff --git a/notifier.js b/notifier.js
index 7028d7a..d231b3f 100644
--- a/notifier.js
+++ b/notifier.js
@@ -11,7 +11,7 @@ var PLUGIN_INFO =
<description>change notice framework.</description>
<description lang="ja">変更通知フレームワーク。</description>
<author mail="suvene@zeromemory.info" homepage="http://zeromemory.sblo.jp/">suVene</author>
- <version>0.1.5</version>
+ <version>0.1.6</version>
<license>MIT</license>
<minVersion>2.0pre</minVersion>
<maxVersion>2.0pre</maxVersion>
@@ -92,10 +92,15 @@ check():
指定したインターバルごとにフレームワークによって呼び出されます。
変更を検知した場合、liberator.plugins.notifier.Message のインスタンスを引数に
this.notify(message) を呼び出してください。
+shutdown():
+ 必要の無い場合、実装しなくても OK です。
+ 変更通知フレームワークの終了時に呼ばれます。
==== librator.plugins.notifier.SubjectHttp ====
Httpを利用した変更検知の基底クラスです。
リクエスト内容をキャッシュします。
+interval:
+ 秒で変更チェックするインターバルを指定します。デフォルトは 60 です。
options{}:
url:
URL を指定します。
@@ -270,7 +275,7 @@ function bootstrap() {
var req = new libly.Request(
this.options.url,
this.options.headers,
- $U.extend({ asynchronous: false }, this.options.extra)
+ $U.extend({ asynchronous: true }, this.options.extra)
);
req.addEventListener('onSuccess', $U.bind(this, function(res) {
var parsed, diff;
diff --git a/notifier/subject_liberator_echomsg.js b/notifier/subject_liberator_echomsg.js
new file mode 100755
index 0000000..c435474
--- /dev/null
+++ b/notifier/subject_liberator_echomsg.js
@@ -0,0 +1,71 @@
+/*** BEGIN LICENSE BLOCK {{{
+ Copyright (c) 2009 suVene<suvene@zeromemory.info>
+
+ distributable under the terms of an MIT-style license.
+ http://www.opensource.jp/licenses/mit-license.html
+}}} END LICENSE BLOCK ***/
+// PLUGIN_INFO//{{
+var PLUGIN_INFO =
+<VimperatorPlugin>
+ <name>{NAME}</name>
+ <description>liberator.echomsg notice.</description>
+ <description lang="ja">liberator.echomsg 通知。</description>
+ <author mail="suvene@zeromemory.info" homepage="http://zeromemory.sblo.jp/">suVene</author>
+ <version>0.1.0</version>
+ <license>MIT</license>
+ <minVersion>2.0pre</minVersion>
+ <maxVersion>2.0pre</maxVersion>
+ <updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/notifier/subject_liberator_echomsg.js</updateURL>
+</VimperatorPlugin>;
+//}}}
+(function() {
+
+var notifier = liberator.plugins.notifier;
+if (!notifier) return;
+
+var libly = notifier.libly;
+var $U = libly.$U;
+var logger = $U.getLogger('subject_liberator_echomsg');
+
+notifier.subject.register(notifier.Subject, {
+ interval: 5,
+ initialize: function() {
+ this.original = liberator.echomsg;
+ this.__updating__ = false;
+ this.messages = [];
+
+ var self = this;
+
+ liberator.echomsg = function(message) {
+ while (self.waiting)
+ liberator.sleep(100);
+
+ logger.log('message: ' + message);
+ self.messages.push(message);
+ return self.original.apply(null, arguments);
+ };
+ },
+ check: function() {
+ try {
+ this.__updating__ = true;
+ if (!this.messages.length) return;
+
+ var msg = '<ul><li>' + this.messages.join('</li><li>') + '</li></ul>';
+ this.messages = [];
+
+ this.notify(new notifier.Message('liberator.echomsg', msg));
+
+ } finally {
+ this.__updating__ = false;
+ }
+ },
+ shutdown: function() {
+ liberator.echomsg = this.original;
+ this.__updating__ = false;
+ }
+
+});
+
+})();
+// vim: set fdm=marker sw=4 ts=4 sts=0 et:
+