]> git.babelmonkeys.de Git - xmppchat.git/blobdiff - js/main.js
Add a disconnect button
[xmppchat.git] / js / main.js
index e6e88fb8e7a304f490d93690b51cb81624d2958f..9588826df689e99d1a9086f20d5b8d7963bea319 100644 (file)
@@ -242,6 +242,16 @@ function doLogin(aForm) {
        }
 }
 
+function doDisconnect(aForm) {
+       if (connection) {
+               connection.send($pres({to: room, type: 'unavailable'}).tree());
+               connection.flush();
+               connection.disconnect();
+               connection = null;
+       }
+       return false;
+}
+
 var dragElement = null;
 var mouseX = 0;
 var mouseY = 0;
@@ -268,13 +278,7 @@ function stopDrag(eve) {
        dragElement = null;
 }
 
-window.onunload = window.onbeforeunload = function() {
-       if (connection) {
-               connection.send($pres({to: room, type: 'unavailable'}).tree());
-               connection.disconnect();
-               connection = null;
-       }
-};
+window.onunload = window.onbeforeunload = doDisconnect;
 
 window.onmousemove = doDrag;