From b2d5c1947805fa3282ffc4762fe08620fba46c44 Mon Sep 17 00:00:00 2001 From: Florian Zeitz Date: Sat, 25 Dec 2010 23:53:37 +0100 Subject: [PATCH] Move adhoc functions into a separate file --- index.html | 1 + js/adhoc.js | 239 +++++++++++++++++++++++++++++++++++++++++++++++++++ js/main.js | 242 +--------------------------------------------------- 3 files changed, 243 insertions(+), 239 deletions(-) create mode 100644 js/adhoc.js 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")) { + $("