]> cgit.babelmonkeys.de Git - adhocweb.git/commitdiff
Add input to query different JIDs
authorFlorian Zeitz <florob@babelmonkeys.de>
Thu, 26 Aug 2010 20:45:55 +0000 (22:45 +0200)
committerFlorian Zeitz <florob@babelmonkeys.de>
Thu, 26 Aug 2010 20:45:55 +0000 (22:45 +0200)
index.html
js/main.js
style.css

index a4ab660ae6551f9a6ff737baff2cd9b461706545..8de6589e0e2471ce50e8cb5ffcb07dd669b421b6 100644 (file)
   </form>
 </div>
 
   </form>
 </div>
 
-<div id="output"></div>
+<div id='query'>
+  <form id='queryForm' name='queryForm'>
+    <label for='queryJID'>Query:</label>
+    <input type='text' id='queryJID' />
+    <input type='submit' value='Query' />
+  </form>
+</div>
+
+<div id='output'></div>
 
 <div id='log_container'>
   <a id='log_toggle' href='#'>Status Log :</a>
 
 <div id='log_container'>
   <a id='log_toggle' href='#'>Status Log :</a>
index 8724764fc49cb711496bb102ebd044a48c171df8..9f802b5f8e8bea4f4af7bb1334e5beee1ed04384 100644 (file)
@@ -7,6 +7,7 @@ var localJID = null;
 var connection   = null;
 var sessionid = null;
 var cmdNode = null;
 var connection   = null;
 var sessionid = null;
 var cmdNode = null;
+var queryJID = null;
 
 function log(msg) {
     var entry = $('<div></div>').append(document.createTextNode(msg));
 
 function log(msg) {
     var entry = $('<div></div>').append(document.createTextNode(msg));
@@ -39,6 +40,8 @@ function onConnect(status) {
         }
     } else if (status == Strophe.Status.CONNECTED) {
         log('Strophe is connected.');
         }
     } else if (status == Strophe.Status.CONNECTED) {
         log('Strophe is connected.');
+        queryJID = connection.domain;
+        $('#query').show();
         checkFeatures();
     }
 }
         checkFeatures();
     }
 }
@@ -182,14 +185,14 @@ function displayResult(result) {
                 $('#' + kind + 'Button').attr("disabled", "false");
         }
         $('#executeButton').bind("click", function() {
                 $('#' + 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() {
                 .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;
                 .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)
 
 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");
         .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() {
 }
 
 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("<ul id='items'></ul>");
         $(result).find("item").each(function(index, e) {
     connection.sendIQ(nodesIQ, function(result) {
         $('#output').append("<ul id='items'></ul>");
         $(result).find("item").each(function(index, e) {
@@ -228,7 +231,7 @@ function getCommandNodes() {
 }
 
 function checkFeatures() {
 }
 
 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("<p>This entitiy does support AdHoc commands</p>");
     connection.sendIQ(featureIQ, function(result) {
         if ($(result).find("feature[var='" + Strophe.NS.ADHOC + "']").length > 0) {
             $('#output').append("<p>This entitiy does support AdHoc commands</p>");
@@ -236,6 +239,7 @@ function checkFeatures() {
             $('#output').append("<p>This entitiy does NOT support AdHoc commands</p>");
         }
     });
             $('#output').append("<p>This entitiy does NOT support AdHoc commands</p>");
         }
     });
+    $('#output').empty();
     getCommandNodes();
 }
 
     getCommandNodes();
 }
 
@@ -245,6 +249,7 @@ function showConnect() {
     var button = $('#connect').get(0);        
 
     button.value = 'connect';
     var button = $('#connect').get(0);        
 
     button.value = 'connect';
+    $('#query').hide();
     pass.show();
     jid.show();
     $('label').show();
     pass.show();
     jid.show();
     $('label').show();
@@ -260,7 +265,7 @@ function showDisconnect() {
     button.value = 'disconnect';
     pass.hide();
     jid.hide();
     button.value = 'disconnect';
     pass.hide();
     jid.hide();
-    $('label').hide();
+    $('#cred label').hide();
     return false;
 }
 
     return false;
 }
 
@@ -293,6 +298,12 @@ $(document).ready(function () {
         }
         return false;
     });
         }
         return false;
     });
+
+    $('#queryForm').bind('submit', function () {
+        queryJID = $('#queryJID').val();
+        checkFeatures();
+        return false;
+    });
 });
 
 onunload = function() {
 });
 
 onunload = function() {
index 958bd57a3b1a0d2cfa73692b06640089d3c76ffe..1020e9e15cd3aeea9ef6fb121f5283c24f48a7d5 100644 (file)
--- a/style.css
+++ b/style.css
@@ -9,3 +9,7 @@ label {
 #log_container {
   display: none
 }
 #log_container {
   display: none
 }
+
+#query {
+  display: none
+}