aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsuVene2008-12-21 17:06:19 +0000
committersuVene2008-12-21 17:06:19 +0000
commitf8caa390332bd7554c49b071e2d7706b39dd62e1 (patch)
treeeec68724316230073e165ffce67d0bc5b14d29b6
parent37c53b0030815c1977aa9bbde13ca03c4a2a29b1 (diff)
downloadvimperator-plugins-f8caa390332bd7554c49b071e2d7706b39dd62e1.tar.bz2
* 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
-rw-r--r--notifier.js12
-rw-r--r--notifier/observer_growl.js20
2 files changed, 26 insertions, 6 deletions
diff --git a/notifier.js b/notifier.js
index ea9bbf2..779d91d 100644
--- a/notifier.js
+++ b/notifier.js
@@ -5,7 +5,7 @@ var PLUGIN_INFO =
<description>change notice framework.</description>
<description lang="ja">変更通知フレームワーク。</description>
<author mail="suvene@zeromemory.info" homepage="http://zeromemory.sblo.jp/">suVene</author>
- <version>0.1.3</version>
+ <version>0.1.4</version>
<minVersion>2.0pre</minVersion>
<maxVersion>2.0pre</maxVersion>
<updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/notifier.js</updateURL>
@@ -193,7 +193,8 @@ function bootstrap() {
__initialize__: function(args) {
$U.extend(this, args);
if (typeof this.initialize == 'function') this.initialize();
- }
+ },
+ shutdown: function() {}
};//}}}
var Subject = function() {//{{{
@@ -222,7 +223,8 @@ function bootstrap() {
}
});
},
- check: function() { throw 'needs override.' }
+ check: function() { throw 'needs override.' },
+ shutdown: function() {}
};//}}}
var SubjectHttp = Subject;//{{{
@@ -323,6 +325,8 @@ function bootstrap() {
this.subjects.getPlugins().forEach(function(s) s.attach(o));
}));
+ liberator.registerObserver("shutdown", $U.bind(this, function() this.stop()));
+
this.isBusy = false;
},//}}}
start: function() {//{{{
@@ -373,6 +377,8 @@ function bootstrap() {
if (typeof finallycallback == 'function') finallycallback();
return;
}
+ this.subjects.getPlugins().forEach(function(s) s.shutdown());
+ this.observers.getPlugins().forEach(function(o) o.shutdown());
this.finallycallback = finallycallback;
this.timer = false;
}//}}}
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 =
<description>notification from the subjects is notified to you by the Growl style.</description>
<description lang="ja">Growl風通知。</description>
<author mail="suvene@zeromemory.info" homepage="http://zeromemory.sblo.jp/">suVene</author>
- <version>0.1.4</version>
+ <version>0.1.5</version>
<minVersion>2.0pre</minVersion>
<maxVersion>2.0pre</maxVersion>
- <updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/notifier\observer_growl.js</updateURL>
+ <updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/notifier/observer_growl.js</updateURL>
<detail><![CDATA[
== Settings ==
>||
@@ -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(<div id="observer_growl" class="observer_growl top-right"/>, 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;
+ };
}
-
});
})();