diff options
author | snaka | 2009-06-07 22:47:59 +0000 |
---|---|---|
committer | snaka | 2009-06-07 22:47:59 +0000 |
commit | cefb6b3d912e1307bed7f411077c5720e276343f (patch) | |
tree | fc3c86433d73f04a96b6f846cc61ea0dea31db1d | |
parent | 545903ba5a64780d10f79aafbf2e6a1e0b9f2625 (diff) | |
download | vimperator-plugins-cefb6b3d912e1307bed7f411077c5720e276343f.tar.bz2 |
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
-rw-r--r-- | hatebuWatchDog.js | 60 |
1 files changed, 52 insertions, 8 deletions
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 = <updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/hatebuWatchDog.js</updateURL> <author mail="snaka.gml@gmail.com" homepage="http://vimperator.g.hatena.ne.jp/snaka72/">snaka</author> <license>MIT style license</license> - <version>1.1.0</version> + <version>1.2.0</version> <detail><![CDATA[ == Subject == Make notify hatebu-count when specified site's hatebu-count changed. @@ -144,23 +144,57 @@ let publics = plugins.hatebuWatchDog = (function() { let message = "'" + targetSite + "' \u306E\u88AB\u306F\u3066\u30D6\u6570\u306F '" + currentValue + "' " + suffix + " (" + getSignedNum(delta) + ")"; - showAlertNotification(null, title, message); + //showAlertNotification(null, title, message); + //publics.notify(title, message); + (getNotifier())(title, message); } - function showAlertNotification(icon, title, message) { + function getSignedNum(num) { + if (num > 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 + ); } }; // }}} |