diff options
author | drry | 2008-12-09 01:54:43 +0000 |
---|---|---|
committer | drry | 2008-12-09 01:54:43 +0000 |
commit | 51c60cd810d1f101920eb4a0767dcbc7473185fc (patch) | |
tree | 7e87d14d6fd4d7072e0b6b513e6162e76e47cec9 /notifier | |
parent | 83b3646a8ef65118c8010b72aec460c90ed79ac7 (diff) | |
download | vimperator-plugins-51c60cd810d1f101920eb4a0767dcbc7473185fc.tar.bz2 |
* もしバグったらごめんなさい。
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@26163 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'notifier')
-rw-r--r-- | notifier/observer_growl.js | 6 | ||||
-rw-r--r-- | notifier/subject_hatelabo_bottle.js | 48 |
2 files changed, 17 insertions, 37 deletions
diff --git a/notifier/observer_growl.js b/notifier/observer_growl.js index 0a3d1d3..e585bdc 100644 --- a/notifier/observer_growl.js +++ b/notifier/observer_growl.js @@ -23,7 +23,7 @@ var logger = $U.getLogger('observer_growl'); var Growl = function() {//{{{ this.initialize.apply(this, arguments); -} +}; Growl.prototype = { defaults: { life: 5000 @@ -41,7 +41,7 @@ Growl.prototype = { this.container.removeChild(this.dom); }, -}//}}} +};//}}} notifier.observer.register(notifier.Observer, { initialize: function () { @@ -51,7 +51,7 @@ notifier.observer.register(notifier.Observer, { var path = io.expandPath(dir.path + '/plugin/notifier'); $U.readDirectory(path, '^growl', function(f) { try { - io.source(f.path, true) + io.source(f.path, true); logger.log('load success: ' + f.leafName); } catch (e) { logger.log('load failed: ' + f.leafName); 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 } + })) }); })(); |