From 38cd189c63c36d684943f0c21e32d4933e26863c Mon Sep 17 00:00:00 2001 From: Florian Zeitz Date: Thu, 26 Aug 2010 22:45:55 +0200 Subject: [PATCH 1/1] Add input to query different JIDs --- index.html | 10 +++++++++- js/main.js | 23 +++++++++++++++++------ style.css | 4 ++++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index a4ab660..8de6589 100644 --- a/index.html +++ b/index.html @@ -22,7 +22,15 @@ -
+
+
+ + + +
+
+ +
Status Log : diff --git a/js/main.js b/js/main.js index 8724764..9f802b5 100644 --- a/js/main.js +++ b/js/main.js @@ -7,6 +7,7 @@ var localJID = null; var connection = null; var sessionid = null; var cmdNode = null; +var queryJID = null; function log(msg) { var entry = $('
').append(document.createTextNode(msg)); @@ -39,6 +40,8 @@ function onConnect(status) { } } else if (status == Strophe.Status.CONNECTED) { log('Strophe is connected.'); + queryJID = connection.domain; + $('#query').show(); checkFeatures(); } } @@ -182,14 +185,14 @@ function displayResult(result) { $('#' + kind + 'Button').attr("disabled", "false"); } $('#executeButton').bind("click", function() { - var execIQ = $iq({ type: "set", to: connection.domain, id: connection.getUniqueId() }) + var execIQ = $iq({ type: "set", to: queryJID, id: connection.getUniqueId() }) .c("command", { xmlns: Strophe.NS.ADHOC, node: cmdNode, sessionid: sessionid, action: "execute" }); serializeToDataform($('form'), execIQ); connection.sendIQ(execIQ, displayResult); }); $('#cancelButton').bind("click", function() { - var cancelIQ = $iq({ type: "set", to: connection.domain, id: connection.getUniqueId() }) + 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; @@ -208,7 +211,7 @@ function displayResult(result) { function runCommand() { cmdNode = $(this).attr("id"); // Save node of executed command (in global var) - var execIQ = $iq({ type: "set", to: connection.domain, id: connection.getUniqueId() }) + var execIQ = $iq({ type: "set", to: queryJID, id: connection.getUniqueId() }) .c("command", { xmlns: Strophe.NS.ADHOC, node: cmdNode, action: "execute" }); connection.sendIQ(execIQ, function(result) { sessionid = $(result).find("command").attr("sessionid"); @@ -217,7 +220,7 @@ function runCommand() { } function getCommandNodes() { - var nodesIQ = $iq({ type: "get", to: connection.domain, id: "nodes1" }).c("query", {xmlns: Strophe.NS.DISCO_ITEMS, node: Strophe.NS.ADHOC}); + 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) { $('#output').append(""); $(result).find("item").each(function(index, e) { @@ -228,7 +231,7 @@ function getCommandNodes() { } function checkFeatures() { - featureIQ = $iq({ type: "get", to: connection.domain, id: "features1" }).c("query", {xmlns: Strophe.NS.DISCO_INFO}); + featureIQ = $iq({ type: "get", to: queryJID, id: "features1" }).c("query", {xmlns: Strophe.NS.DISCO_INFO}); connection.sendIQ(featureIQ, function(result) { if ($(result).find("feature[var='" + Strophe.NS.ADHOC + "']").length > 0) { $('#output').append("

This entitiy does support AdHoc commands

"); @@ -236,6 +239,7 @@ function checkFeatures() { $('#output').append("

This entitiy does NOT support AdHoc commands

"); } }); + $('#output').empty(); getCommandNodes(); } @@ -245,6 +249,7 @@ function showConnect() { var button = $('#connect').get(0); button.value = 'connect'; + $('#query').hide(); pass.show(); jid.show(); $('label').show(); @@ -260,7 +265,7 @@ function showDisconnect() { button.value = 'disconnect'; pass.hide(); jid.hide(); - $('label').hide(); + $('#cred label').hide(); return false; } @@ -293,6 +298,12 @@ $(document).ready(function () { } return false; }); + + $('#queryForm').bind('submit', function () { + queryJID = $('#queryJID').val(); + checkFeatures(); + return false; + }); }); onunload = function() { diff --git a/style.css b/style.css index 958bd57..1020e9e 100644 --- a/style.css +++ b/style.css @@ -9,3 +9,7 @@ label { #log_container { display: none } + +#query { + display: none +} -- 2.39.5