From 7e2df6a0694f18c9569744d5707045fbc934f0c1 Mon Sep 17 00:00:00 2001
From: suVene
Date: Thu, 18 Dec 2008 17:27:37 +0000
Subject: * 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
---
notifier/growl.css | 4 +--
notifier/observer_growl.js | 60 ++++++++++++++++++++++++-------------
notifier/subject_hatelabo_bottle.js | 3 --
notifier/subject_weather_yahoo.js | 13 ++++++--
4 files changed, 52 insertions(+), 28 deletions(-)
(limited to 'notifier')
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 =
notification from the subjects is notified to you by the Growl style.
Growl風通知。
suVene
- 0.1.1
+ 0.1.2
2.0pre
2.0pre
||
javascript <
;
//}}}
@@ -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(
, 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([close all]
, 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, {
{new XMLList(message.message || '')}
;
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 =
yahoo weather forecast notice.
ヤフー天気予報通知。
suVene
- 0.1.0
+ 0.1.1
2.0pre
2.0pre
+ ||
+liberator.globalVariables.subject_weather_yahoo_urls = [url1, url2,…]
+||<
+- @see http://weather.yahoo.co.jp/weather/
+ ]]>
;
//}}}
(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);
--
cgit v1.2.3