From fd596c870dbacce1f31bcf5cd58281931744c4a8 Mon Sep 17 00:00:00 2001 From: suVene Date: Fri, 2 Jan 2009 18:22:47 +0000 Subject: add "subject_liberator_echomsg.js". git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@27801 d0d07461-0603-4401-acd4-de1884942a52 --- notifier/subject_liberator_echomsg.js | 71 +++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100755 notifier/subject_liberator_echomsg.js (limited to 'notifier') 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 + + 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 = + + {NAME} + liberator.echomsg notice. + liberator.echomsg 通知。 + suVene + 0.1.0 + MIT + 2.0pre + 2.0pre + http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/notifier/subject_liberator_echomsg.js +; +//}}} +(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 = ''; + 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: + -- cgit v1.2.3