From cefb6b3d912e1307bed7f411077c5720e276343f Mon Sep 17 00:00:00 2001
From: snaka
Date: Sun, 7 Jun 2009 22:47:59 +0000
Subject: Add Growl for Windows (Firefox extension Growl/GNTP) support.
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@33834 d0d07461-0603-4401-acd4-de1884942a52
---
hatebuWatchDog.js | 60 +++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 52 insertions(+), 8 deletions(-)
(limited to 'hatebuWatchDog.js')
diff --git a/hatebuWatchDog.js b/hatebuWatchDog.js
index 2de0a7b..de1e15e 100644
--- a/hatebuWatchDog.js
+++ b/hatebuWatchDog.js
@@ -40,7 +40,7 @@ let PLUGIN_INFO =
http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/hatebuWatchDog.js
snaka
MIT style license
- 1.1.0
+ 1.2.0
0) return "+" + num;
+ if (num < 0) return "-" + Math.abs(num);
+ return "0";
+ }
+
+ let _notifier = null;
+ const GROWL_EXTENSION_ID = "growlgntp@brian.dunnington";
+
+ function getNotifier() {
+ if (_notifier) return _notifier;
+
+ if (Application.extensions.has(GROWL_EXTENSION_ID) &&
+ Application.extensions.get(GROWL_EXTENSION_ID).enabled) {
+ _notifier = publics.notify;
+ }
+ else {
+ _notifier = showAlertNotification;
+ }
+ return _notifier;
+ }
+
+ function showAlertNotification(title, message) {
Cc['@mozilla.org/alerts-service;1']
.getService(Ci.nsIAlertsService)
.showAlertNotification(
- icon, //'chrome://mozapps/skin/downloads/downloadIcon.png',
+ null, //'chrome://mozapps/skin/downloads/downloadIcon.png',
title,
message
);
}
- function getSignedNum(num) {
- if (num > 0) return "+" + num;
- if (num < 0) return "-" + Math.abs(num);
- return "0";
+ function growl() Components.classes['@growlforwindows.com/growlgntp;1']
+ .getService().wrappedJSObject;
+ const growlIcon = "http://img.f.hatena.ne.jp/images/fotolife/s/snaka72/20090608/20090608045633.gif"; // temporary
+
+ function growlRegister() {
+ growl().register(
+ PLUGIN_INFO.name,
+ growlIcon,
+ [
+ {name: 'announce', displayName: 'Announce from hatebuWatchDog'},
+ {name: 'sadlynews',displayName: 'Sadly announce from hatebuWatchdog'},
+ {name: 'failed', displayName: 'Erroer report from hatebuWatchdog'}
+ ]
+ );
}
function getInterval()
@@ -243,6 +277,16 @@ let publics = plugins.hatebuWatchDog = (function() {
liberator.echoerr("Cannot get current value.");
}
);
+ },
+
+ notify: function(title, message) {
+ growlRegister();
+ growl().notify(
+ PLUGIN_INFO.name,
+ 'announce',
+ title,
+ message
+ );
}
};
// }}}
--
cgit v1.2.3