/** * notifier.js plugin observer * @name observer_growl.js * @description growl when notified. * @description-ja Growl風通知。 * @author suVene suvene@zeromemory.info * @version 0.1.0 * Last Change: 07-Dec-2008. * * use JQuery * http://jquery.com/ * use JGrowl * http://stanlemon.net/projects/jgrowl.html */ (function() { var notifier = liberator.plugins.notifier; if (!notifier) return; var lib = notifier.lib; var $U = lib.$U; var logger = $U.getLogger('observer_growl'); var Growl = function() {//{{{ this.initialize.apply(this, arguments); } Growl.prototype = { defaults: { life: 3000 }, initialize: function(dom, container) { this.dom = dom; this.container = container; this.created = new Date(); this.life = this.defaults.life; dom.childNodes[0].addEventListener("click", $U.bind(this, this.remove), false); }, remove: function() { this.container.removeChild(this.dom); }, }//}}} notifier.observer.register({ initialize: function () { logger.log('initialize'); this.count = 1; io.getRuntimeDirectories('').forEach(function(dir) { let path = io.expandPath(dir.path + '/plugin/notifier'); $U.readDirectory(path, '^jquery' , function(f) { try { io.source(f.path, true) logger.log('load success: ' + f.leafName); } catch (e) { logger.log('load failed: ' + f.leafName); } }); }); }, update: function(message) { logger.log('update:' + this.count); var doc = window.content.document; var container = doc.getElementById("observer_growl"); if (!container) { doc.body.appendChild(util.xmlToDom(
, doc)); container = doc.getElementById("observer_growl"); } this.createPopup(doc, message, container); container.appendChild(this.createPopup(doc, message, container)); if (container.childNodes.length == 1) { var interval = setInterval($U.bind(this, this.checkStatus), 1000); container.__interval__ = interval; } this.count++; }, createPopup: function(doc, message, nodes) { var dom; var html =