X-Git-Url: http://cgit.babelmonkeys.de/?p=adhocweb.git;a=blobdiff_plain;f=js%2Fmain.js;h=955ceb9f5d9a0795529b5f9a9d577e134789b73c;hp=c03a8cf74c391428363da43a2f1269f1fb40d9c3;hb=c61edf2757c92c0460b9e0581771f7a9b06ed1ba;hpb=9ba3402321b224b65cc3eed994b6cb016cfeabda diff --git a/js/main.js b/js/main.js index c03a8cf..955ceb9 100644 --- a/js/main.js +++ b/js/main.js @@ -5,9 +5,11 @@ Strophe.addNamespace("ADHOC", "http://jabber.org/protocol/commands"); var localJID = null; var connection = null; -var sessionid = null; -var cmdNode = null; -var queryJID = null; +var adhoc_status = { + sessionid: null, + cmdNode: null, + queryJID: null +}; function log(msg) { var entry = $('
').append(document.createTextNode(msg)); @@ -40,8 +42,8 @@ function onConnect(status) { } } else if (status == Strophe.Status.CONNECTED) { log('Strophe is connected.'); - queryJID = connection.domain; - $('#queryJID').val(queryJID); + adhoc_status.queryJID = connection.domain; + $('#queryJID').val(adhoc_status.queryJID); $('#query').show(); checkFeatures(); } @@ -64,7 +66,7 @@ function addForm(elem, x) { $("").text($(x).find("title").text()).appendTo(fieldset); if ($(x).find("instructions").length > 0) $("

").text($(x).find("instructions").text()).appendTo(fieldset); - $(x).find("field").each(function(){ + $(x).find("field").each(function() { var item = null; var type = $(this).attr("type"); if($(this).attr("label")) { @@ -95,15 +97,15 @@ function addForm(elem, x) { break; case "list-multi": item = $(""); - $(this).find("option").each(function(){ - $("

"); $(result).find("item").each(function(index, e) { @@ -259,7 +262,7 @@ function getCommandNodes() { } function checkFeatures() { - featureIQ = $iq({ type: "get", to: queryJID, id: "features1" }).c("query", {xmlns: Strophe.NS.DISCO_INFO}); + featureIQ = $iq({ type: "get", to: adhoc_status.queryJID, id: "features1" }).c("query", {xmlns: Strophe.NS.DISCO_INFO}); $('#output').empty(); connection.sendIQ(featureIQ, function(result) { /* Callback */ @@ -333,15 +336,14 @@ $(document).ready(function () { }); $('#queryForm').bind('submit', function (event) { - queryJID = $('#queryJID').val(); + adhoc_status.queryJID = $('#queryJID').val(); checkFeatures(); event.preventDefault(); }); }); -onunload = function() { +window.onunload = window.onbeforeunload = function() { if (connection) { connection.disconnect(); } } -