aboutsummaryrefslogtreecommitdiffstats
path: root/notifier/subject_hatelabo_bottle.js
diff options
context:
space:
mode:
Diffstat (limited to 'notifier/subject_hatelabo_bottle.js')
-rw-r--r--notifier/subject_hatelabo_bottle.js48
1 files changed, 14 insertions, 34 deletions
diff --git a/notifier/subject_hatelabo_bottle.js b/notifier/subject_hatelabo_bottle.js
index 7a00d13..abba6cd 100644
--- a/notifier/subject_hatelabo_bottle.js
+++ b/notifier/subject_hatelabo_bottle.js
@@ -5,11 +5,10 @@ var PLUGIN_INFO =
<description>notifies if hatena bottle was changed.</description>
<description lang="ja">はてなボトルの変更通知。</description>
<author mail="suvene@zeromemory.info" homepage="http://zeromemory.sblo.jp/">suVene</author>
- <version>0.1.0</version>
+ <version>0.1.1</version>
<minVersion>2.0pre</minVersion>
<maxVersion>2.0pre</maxVersion>
- <detail><![CDATA[
- ]]></detail>
+ <detail/>
</VimperatorPlugin>;
//}}}
(function() {
@@ -32,42 +31,23 @@ notifier.subject.register(notifier.SubjectHttp, {
extra: null
},
parse: function(res) {
+ if (!res.isSuccess() || res.responseText == '') return;
- var ret, dom;
+ var dom = res.getHTMLDocument('id("body")//div[contains(concat(" ", @class, " "), " entry ")]');
+ if (!dom) return;
- if (!res.isSuccess() || res.responseText == '') return ret;
-
- dom = res.getHTMLDocument('id("body")//div[contains(concat(" ", @class, " "), " entry ")]');
- if (!dom) return ret;
-
- ret = [];
- for (let i = 0, len = dom.childNodes.length; i < len; i++) {
- ret.push(dom.childNodes[i]);
- }
-
- return ret;
- },
- diff: function(cache, parsed) {
var ret = [];
- parsed.forEach(function(element) {
- if (!cache.some(function(c) { if (c.textContent == element.textContent) return true }))
- ret.push(element);
- });
+ for (let i = 0, len = dom.childNodes.length; i < len; ret.push(dom.childNodes[i++]));
return ret;
},
- buildMessages: function(diff) {
- var ret = [];
- diff.forEach(function(d) {
- ret.push(
- new notifier.Message('Hatelab bottle', $U.xmlSerialize(d), {
- growl: {
- life: 7000
- }
- })
- );
- });
- return ret;
- }
+ diff: function(cache, parsed)
+ parsed.filter(function(element)
+ !cache.some(function(c) c.textContent == element.textContent)),
+ buildMessages: function(diff)
+ diff.map(function(d)
+ new notifier.Message('Hatelab bottle', $U.xmlSerialize(d), {
+ growl: { life: 7000 }
+ }))
});
})();