aboutsummaryrefslogtreecommitdiffstats
path: root/notifier
diff options
context:
space:
mode:
authorsuVene2008-12-18 17:27:37 +0000
committersuVene2008-12-18 17:27:37 +0000
commit7e2df6a0694f18c9569744d5707045fbc934f0c1 (patch)
treea9a68631640739558845577bf9b60f5150501e60 /notifier
parentc3edf91140e9f8bef88bc2375f0cea4f2a753541 (diff)
downloadvimperator-plugins-7e2df6a0694f18c9569744d5707045fbc934f0c1.tar.bz2
* observer_growl. EventListener の登録失敗回避.[close all]追加.
* subject_weather_yahoo.js url の設定読込み. * growl.css className modify. git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@27040 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'notifier')
-rw-r--r--notifier/growl.css4
-rw-r--r--notifier/observer_growl.js60
-rw-r--r--notifier/subject_hatelabo_bottle.js3
-rwxr-xr-xnotifier/subject_weather_yahoo.js13
4 files changed, 52 insertions, 28 deletions
diff --git a/notifier/growl.css b/notifier/growl.css
index d67b681..ab172e0 100644
--- a/notifier/growl.css
+++ b/notifier/growl.css
@@ -36,12 +36,12 @@ body > div.observer_growl.center {
}
/** Cross Browser Styling **/
-div.center div.observer_growl_notification, div.center div.observer_growl-closer {
+div.center div.observer_growl_notification, div.center div.observer_growl_closer {
margin-left: auto;
margin-right: auto;
}
-div.observer_growl div.observer_growl_notification, div.observer_growl div.observer_growl-closer {
+div.observer_growl div.observer_growl_notification, div.observer_growl div.observer_growl_closer {
background-color: #000;
color: #fff;
opacity: .85;
diff --git a/notifier/observer_growl.js b/notifier/observer_growl.js
index f26c850..473800a 100644
--- a/notifier/observer_growl.js
+++ b/notifier/observer_growl.js
@@ -5,7 +5,7 @@ var PLUGIN_INFO =
<description>notification from the subjects is notified to you by the Growl style.</description>
<description lang="ja">Growl風通知。</description>
<author mail="suvene@zeromemory.info" homepage="http://zeromemory.sblo.jp/">suVene</author>
- <version>0.1.1</version>
+ <version>0.1.2</version>
<minVersion>2.0pre</minVersion>
<maxVersion>2.0pre</maxVersion>
<detail><![CDATA[
@@ -28,7 +28,7 @@ e.g.)
>||
javascript <<EOM
liberator.globalVariables.observer_growl_settings = {
- 'Hatelabo bottle': { life: 20, keyword: 'はてな' },
+ 'Hatelabo bottle': { life: 20, sticky_keyword: 'はてな' },
'Weather forecast by Yahoo!': { sticky: true }
};
EOM
@@ -37,7 +37,6 @@ EOM
== Todo ==
- sticky_keyword
- hide
-- close all
]]></detail>
</VimperatorPlugin>;
//}}}
@@ -54,22 +53,22 @@ var Growl = function() {//{{{
this.initialize.apply(this, arguments);
};
Growl.prototype = {
- defaults: {
- life: 10,
- sticky: false,
- suticky_keyword: [],
- hide: false,
- },
- initialize: function(node, container, options) {
+ initialize: function(node, options) {
+ this.defaults = {
+ life: 10,
+ sticky: false,
+ suticky_keyword: [],
+ hide: false
+ };
this.node = node;
- this.container = container;
this.created = new Date();
this.options = $U.extend(this.defaults, (options || {}));
- node.childNodes[0].addEventListener("click", $U.bind(this, this.remove), false);
+ var div = node.getElementsByTagName('div');
+ div[0].addEventListener("click", $U.bind(this, this.remove), false);
},
remove: function() {
// TODO: animation!!!!
- this.container.removeChild(this.node);
+ this.node.parentNode.removeChild(this.node);
},
};//}}}
@@ -101,6 +100,7 @@ notifier.observer.register(notifier.Observer, {
doc.body.appendChild($U.xmlToDom(<div id="observer_growl" class="observer_growl top-right"/>, doc));
container = doc.getElementById("observer_growl");
}
+ var closer = doc.getElementById("observer_growl_closer");
var notification = this.createPopup(message, doc, container);
// TODO: animation!!!
@@ -110,6 +110,12 @@ notifier.observer.register(notifier.Observer, {
if (container.childNodes.length == 1) {
let interval = setInterval($U.bind(this, this.checkStatus), 1000);
container.__interval__ = interval;
+ } else if (container.childNodes.length >= 2) {
+ if (!closer) {
+ closer = $U.xmlToDom(<div id="observer_growl_closer" class="observer_growl_closer center" style="display: block;">[close all]</div>, doc);
+ container.insertBefore(closer, container.firstChild);
+ closer.addEventListener("click", $U.bind(this, this.removeAll, 'test'), false);
+ }
}
this.count++;
@@ -127,10 +133,11 @@ notifier.observer.register(notifier.Observer, {
<div class="message">{new XMLList(message.message || '')}</div>
</div>;
node = $U.xmlToDom(html, doc);
- node.__data__ = new Growl(node, container, this.settings[message.title]);
+ node.__data__ = new Growl(node, this.settings[message.title]);
return node;
},
- checkStatus: function() {
+ checkStatus: function(force) {
+ force = force == 'EVENT_REMOVE_ALL' ? true : false;
var doc = window.content.document;
var container = doc.getElementById("observer_growl");
@@ -140,18 +147,31 @@ notifier.observer.register(notifier.Observer, {
for (let i = 0, len = container.childNodes.length; i < len; i++) {
let item = container.childNodes[i];
let growl = item.__data__;
- if (growl && growl.created &&
- !growl.options.sticky &&
- growl.created.getTime() + (growl.options.life * 1000) < (new Date()).getTime()) {
- removeNodes.push(item);
+ if (force ||
+ (growl && growl.created && !growl.options.sticky &&
+ growl.created.getTime() + (growl.options.life * 1000) < (new Date()).getTime())) {
+ if (item.id != 'observer_growl_closer')
+ removeNodes.push(item);
+ }
+
+ if (len == 1) {
+ let elem = container.childNodes[0];
+ if (elem.id == 'observer_growl_closer')
+ elem.parentNode.removeChild(elem);
}
}
removeNodes.forEach(function(element) element.__data__.remove());
- if (container.childNodes.length == 0)
+ if (force || container.childNodes.length == 0)
clearInterval(container.__interval__);
+ },
+ removeAll: function(a) {
+ this.checkStatus('EVENT_REMOVE_ALL');
+ var closer = window.content.document.getElementById("observer_growl_closer");
+ closer.parentNode.removeChild(closer);
}
+
});
})();
diff --git a/notifier/subject_hatelabo_bottle.js b/notifier/subject_hatelabo_bottle.js
index a21f22f..0cf31ef 100644
--- a/notifier/subject_hatelabo_bottle.js
+++ b/notifier/subject_hatelabo_bottle.js
@@ -28,9 +28,6 @@ notifier.subject.register(notifier.SubjectHttp, {
headers: null,
extra: null
},
- preInitialize: function() {
- logger.log('preInitialize: ');
- },
parse: function(res) {
// if (this.count == 0) return []; // for debug
var doc = res.getHTMLDocument('id("body")//div[contains(concat(" ", @class, " "), " entry ")]');
diff --git a/notifier/subject_weather_yahoo.js b/notifier/subject_weather_yahoo.js
index 96f23d0..0445bed 100755
--- a/notifier/subject_weather_yahoo.js
+++ b/notifier/subject_weather_yahoo.js
@@ -5,9 +5,16 @@ var PLUGIN_INFO =
<description>yahoo weather forecast notice.</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[
+== Options ==
+>||
+liberator.globalVariables.subject_weather_yahoo_urls = [url1, url2,…]
+||<
+- @see http://weather.yahoo.co.jp/weather/
+ ]]></detail>
</VimperatorPlugin>;
//}}}
(function() {
@@ -19,8 +26,7 @@ var libly = notifier.libly;
var $U = libly.$U;
var logger = $U.getLogger('subject_weather_yahoo');
-// @see http://weather.yahoo.co.jp/weather/
-var URLs = [
+var URLs = liberator.globalVariables.subject_weather_yahoo_urls || [
'http://weather.yahoo.co.jp/weather/jp/27/6200/27127/5300001.html',
'http://weather.yahoo.co.jp/weather/jp/13/4410/13113/1500001.html'
];
@@ -55,6 +61,7 @@ URLs.forEach(function(url) {
var table = $U.getFirstNodeFromXPath('descendant::table', source);
table.style.width = '95%';
+ table.style.color = '#222';
var cloneTable = table.cloneNode(false);
this.cloneTable(cloneTable, table, start, start + 3, true);