From f8caa390332bd7554c49b071e2d7706b39dd62e1 Mon Sep 17 00:00:00 2001 From: suVene Date: Sun, 21 Dec 2008 17:06:19 +0000 Subject: * shutdown 時の timer cleanup. * document.unload 時の interval cleanup. git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@27175 d0d07461-0603-4401-acd4-de1884942a52 --- notifier/observer_growl.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'notifier') diff --git a/notifier/observer_growl.js b/notifier/observer_growl.js index 2f948b7..f257230 100644 --- a/notifier/observer_growl.js +++ b/notifier/observer_growl.js @@ -5,10 +5,10 @@ var PLUGIN_INFO = notification from the subjects is notified to you by the Growl style. Growl風通知。 suVene - 0.1.4 + 0.1.5 2.0pre 2.0pre - http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/notifier\observer_growl.js + http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/notifier/observer_growl.js || @@ -78,6 +78,7 @@ notifier.observer.register(notifier.Observer, { initialize: function () { this.count = 1; this.settings; + this.intervalIDs = {}; io.getRuntimeDirectories('').forEach(function(dir) { var path = io.expandPath(dir.path + '/plugin/notifier'); @@ -100,6 +101,12 @@ notifier.observer.register(notifier.Observer, { if (!container) { doc.body.appendChild($U.xmlToDom(
, doc)); container = doc.getElementById("observer_growl"); + window.content.addEventListener('unload', $U.bind(this, function() { + if (container.__interval__) { + clearInterval(container.__interval__); + this.intervalIDs[container.__interval__] = false; + } + }), false); } var closer = doc.getElementById("observer_growl_closer"); @@ -110,6 +117,7 @@ notifier.observer.register(notifier.Observer, { if (container.childNodes.length == 1 && !container.__interval__) { let interval = setInterval($U.bind(this, this.checkStatus), 1000); + this.intervalIDs[interval] = true; container.__interval__ = interval; } else if (container.childNodes.length >= 2) { if (!closer) { @@ -173,8 +181,14 @@ notifier.observer.register(notifier.Observer, { this.checkStatus('EVENT_REMOVE_ALL'); var closer = window.content.document.getElementById("observer_growl_closer"); closer.parentNode.removeChild(closer); + }, + shutdown: function() { + for (let [id, flg] in Iterator(this.intervalIDs)) { + if (!flg) return; + clearInterval(id); + this.intervalIDs[id] = false; + }; } - }); })(); -- cgit v1.2.3