X-Git-Url: http://cgit.babelmonkeys.de/?p=adhocweb.git;a=blobdiff_plain;f=js%2Fmain.js;h=6bd32412743739166210a6cc07f5d3c9e3df1a29;hp=1bb3a459cee1c76a32db2d64f4ffd08b5c47ff7f;hb=e5d4fe480e02907b80e91d9ed42854700c5866c1;hpb=b01285cb145a159729dc46cb7df7f84e728c7f9b
diff --git a/js/main.js b/js/main.js
index 1bb3a45..6bd3241 100644
--- a/js/main.js
+++ b/js/main.js
@@ -41,6 +41,7 @@ function onConnect(status) {
} else if (status == Strophe.Status.CONNECTED) {
log('Strophe is connected.');
queryJID = connection.domain;
+ $('#queryJID').val(queryJID);
$('#query').show();
checkFeatures();
}
@@ -50,6 +51,7 @@ function addNote(elem, text, type) {
if (!type) {
type = "info";
}
+ text = text.replace(/\n/g, "
");
$(elem).append("
" + text + "
"); } @@ -86,7 +88,7 @@ function addForm(elem, x) { item = $("").attr("readonly",true); break; case "jid-multi": - item = $(""); + item = $(""); break; case "jid-single": item = $(""); @@ -127,6 +129,8 @@ function addForm(elem, x) { item.val($(this).find("value").text()); } } + if ($(x).attr("type") == "result") + item.attr("readonly", true); if ($(this).attr("var")) { item.attr("name", $(this).attr("var")); item.attr("id", $(this).attr("var")); @@ -194,12 +198,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(); @@ -222,6 +238,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) { @@ -300,13 +324,13 @@ $(document).ready(function () { } else { connection.disconnect(); } - event.preventDefault(); + event.preventDefault(); }); $('#queryForm').bind('submit', function (event) { queryJID = $('#queryJID').val(); checkFeatures(); - event.preventDefault(); + event.preventDefault(); }); });