From: Florian Zeitz Date: Thu, 16 Sep 2010 21:01:37 +0000 (+0200) Subject: Cancel command on "Query" if appropriate X-Git-Url: https://cgit.babelmonkeys.de/?a=commitdiff_plain;h=7b4f5c83f5892fe3ca742f0c61e311cc385bd641;p=adhocweb.git Cancel command on "Query" if appropriate --- diff --git a/js/main.js b/js/main.js index 52e6296..1011dc8 100644 --- a/js/main.js +++ b/js/main.js @@ -197,12 +197,24 @@ function displayResult(result) { }); $('#cancelButton').bind("click", function() { - var cancelIQ = $iq({ type: "set", to: queryJID, id: connection.getUniqueId() }) - .c("command", { xmlns: Strophe.NS.ADHOC, node: cmdNode, sessionid: sessionid, action: "cancel" }); - cmdNode = null - sessionid = null; - connection.sendIQ(cancelIQ, displayResult); + cancelCommand(displayResult); + }); + + $('#queryForm').unbind('submit'); + $('#queryForm').bind('submit', function (event) { + cancelCommand(function(result) { + $('#queryForm').unbind('submit'); + $('#queryForm').bind('submit', function (event) { + queryJID = $('#queryJID').val(); + checkFeatures(); + event.preventDefault(); + }); + }); + queryJID = $('#queryJID').val(); + checkFeatures(); + event.preventDefault(); }); + } else { input = $("").bind("click", function() { $('#output').empty(); @@ -225,6 +237,14 @@ function runCommand(event) { event.preventDefault(); } +function cancelCommand(callback) { + var cancelIQ = $iq({ type: "set", to: queryJID, id: connection.getUniqueId() }) + .c("command", { xmlns: Strophe.NS.ADHOC, node: cmdNode, sessionid: sessionid, action: "cancel" }); + cmdNode = null + sessionid = null; + connection.sendIQ(cancelIQ, callback); +} + function getCommandNodes() { var nodesIQ = $iq({ type: "get", to: queryJID, id: "nodes1" }).c("query", {xmlns: Strophe.NS.DISCO_ITEMS, node: Strophe.NS.ADHOC}); connection.sendIQ(nodesIQ, function(result) { @@ -303,13 +323,13 @@ $(document).ready(function () { } else { connection.disconnect(); } - event.preventDefault(); + event.preventDefault(); }); $('#queryForm').bind('submit', function (event) { queryJID = $('#queryJID').val(); checkFeatures(); - event.preventDefault(); + event.preventDefault(); }); });