blob: c4354742a08284e31d0356f8ca561dae69c71c94 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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:
|