X-Git-Url: http://git.babelmonkeys.de/?p=xmppchat.git;a=blobdiff_plain;f=js%2Fmain.js;h=9588826df689e99d1a9086f20d5b8d7963bea319;hp=e6e88fb8e7a304f490d93690b51cb81624d2958f;hb=3cd1748e378f0cfa34f208abddd03fa1798b5364;hpb=6c19bc50128edf5f1675a022a586423533104c3a diff --git a/js/main.js b/js/main.js index e6e88fb..9588826 100644 --- a/js/main.js +++ b/js/main.js @@ -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;