From: Florian Zeitz Date: Sat, 25 Dec 2010 22:53:37 +0000 (+0100) Subject: Move adhoc functions into a separate file X-Git-Url: https://git.babelmonkeys.de/?a=commitdiff_plain;h=b2d5c1947805fa3282ffc4762fe08620fba46c44;p=adhocweb.git Move adhoc functions into a separate file --- diff --git a/index.html b/index.html index 195bd94..5390947 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,7 @@ + diff --git a/js/adhoc.js b/js/adhoc.js new file mode 100644 index 0000000..574c5a6 --- /dev/null +++ b/js/adhoc.js @@ -0,0 +1,239 @@ +var Adhoc = { + status: { + sessionid: null, + cmdNode: null, + queryJID: null + }, + + addNote: function (elem, text, type) { + if (!type) { + type = "info"; + } + text = text.replace(/\n/g, "
"); + $(elem).append("

" + text + "

"); + }, + + addForm: function (elem, x) { + var form = $("
"); + form.submit(function(event) { + Adhoc.executeCommand("execute", Adhoc.serializeToDataform('form'), + function(e) { Adhoc.displayResult(elem, e) }); + event.preventDefault(); + }); + var fieldset = $("
"); + form.append(fieldset); + if ($(x).find("title").length > 0) + $("").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() { + var item = null; + var type = $(this).attr("type"); + if($(this).attr("label")) { + $("