var PLUGIN_INFO =
{NAME}
notification using nsIAlertService
nsIAlertServiceを使用したnotifier用通知プラグイン
teramako
0.1
MPL 1.1/GPL 2.0/LGPL 2.1
2.0pre
2.0pre
http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/notifier/observer_nsIAlertService.js
||
:js Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator).getMostRecentWindow("alert:alert").close()
||<
]]>
;
//}}}
(function(){
var notifier = liberator.plugins.notifier;
if (!notifier){
return;
}
var libly = notifier.libly;
var $U = libly.$U;
var logger = $U.getLogger("observer_alert");
const alertService = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
const ICON_URL = "chrome://vimperator/skin/icon.png";
var observer = {
observe: function(aSubject, aTopic, aData){
if (aTopic == "alertclickcallback" && aData){
liberator.open(aData, liberator.NEW_TAB);
}
}
};
function getAlertWindows(){
return Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator)
.getXULWindowEnumerator("alert:alert");
}
function alertNotify(count, message){
alertService.showAlertNotification(
ICON_URL,
count + ": " + message.title,
"",
message.link ? true : false,
message.link,
observer
);
(function(){
var fixed = false;
var winEnum = getAlertWindows();
var win;
while (winEnum.hasMoreElements()){
win = winEnum.getNext()
.QueryInterface(Ci.nsIXULWindow).docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
if (win.arguments[1] == count + ": " + message.title){
let box = win.document.getElementById("alertTextBox");
let t = box.firstChild;
if (box.lastChild.hasAttribute("clickable")){
t.style.cursor = "pointer";
t.style.color = "#1455D6";
t.style.textDecoration = "underline";
}
t.setAttribute("onclick", "onAlertClick();");
box.removeChild(box.lastChild);
box.appendChild($U.xmlToDom(new XMLList(
'
' + message.message + "
"),
document
));
win.onAlertLoad();
fixed = true;
}
}
if (!fixed) setTimeout(arguments.callee, 10);
})();
}
notifier.observer.register(notifier.Observer, {
initialize: function (){
this.count = 1;
},
update: function(message){
alertNotify(this.count, message);
this.count++;
}
});
})();
// vim: set fdm=marker sw=4 ts=4 sts=0 et: