From 51c60cd810d1f101920eb4a0767dcbc7473185fc Mon Sep 17 00:00:00 2001 From: drry Date: Tue, 9 Dec 2008 01:54:43 +0000 Subject: * もしバグったらごめんなさい。 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@26163 d0d07461-0603-4401-acd4-de1884942a52 --- notifier/observer_growl.js | 6 ++--- notifier/subject_hatelabo_bottle.js | 48 +++++++++++-------------------------- 2 files changed, 17 insertions(+), 37 deletions(-) (limited to 'notifier') 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 = notifies if hatena bottle was changed. はてなボトルの変更通知。 suVene - 0.1.0 + 0.1.1 2.0pre 2.0pre - + ; //}}} (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 } + })) }); })(); -- cgit v1.2.3