]> git.babelmonkeys.de Git - adhocweb.git/commitdiff
Cancel command on "Query" if appropriate
authorFlorian Zeitz <florob@babelmonkeys.de>
Thu, 16 Sep 2010 21:01:37 +0000 (23:01 +0200)
committerFlorian Zeitz <florob@babelmonkeys.de>
Thu, 16 Sep 2010 21:01:37 +0000 (23:01 +0200)
js/main.js

index 52e6296a5c54908a740595d00a36e3712faa3c6f..1011dc87e58a9f4361130410e82282db34bb12c2 100644 (file)
@@ -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 = $("<input type='button' value='Start over'/>").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();
     });
 });