X-Git-Url: http://cgit.babelmonkeys.de/?p=adhocweb.git;a=blobdiff_plain;f=js%2Fadhoc.js;h=51932499f7a099ac94a96f8daa20d78f4509d1c9;hp=3f2ae2b4e96843896f95fdc1a4dc8c540be2e529;hb=3a1e752b5d9120ffd6def0a5e17e2cf536209854;hpb=9f26ed9cdd3330b0fb922e1475d3175caa46d528 diff --git a/js/adhoc.js b/js/adhoc.js index 3f2ae2b..5193249 100644 --- a/js/adhoc.js +++ b/js/adhoc.js @@ -1,3 +1,9 @@ +// adhocweb +// Copyright (c) 2010-2013 Florian Zeitz +// +// This project is MIT licensed. +// Please see the COPYING file for more information. + /* * Implementation of ECMA Script 5 like bind from: * https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind @@ -23,27 +29,33 @@ if (!Function.prototype.bind) { Strophe.addNamespace("ADHOC", "http://jabber.org/protocol/commands"); -var Adhoc = { - status: { +function Adhoc(view, readycb) { + this.status = { sessionid: null, cmdNode: null, - queryJID: null - }, + queryJID: null, + readycb: readycb, + view: view + }; +} + +Adhoc.prototype = { + constructor: Adhoc, - addNote: function (elem, text, type) { + addNote: function (text, type) { if (!type) { type = "info"; } text = text.replace(/\n/g, "
"); - $(elem).append("

" + text + "

"); + $(this.status.view).append("

" + text + "

"); }, - addForm: function (elem, x) { + addForm: function (x) { var self = this; - var form = $("
"); + var form = $(""); form.submit(function(event) { self.executeCommand("execute", self.serializeToDataform('form'), - function(e) { self.displayResult(elem, e) }); + function(e) { self.displayResult(e) }); event.preventDefault(); }); var fieldset = $("
"); @@ -51,19 +63,18 @@ var Adhoc = { $(x).find("title").each(function() { $("").text($(this).text()).appendTo(fieldset); }); $(x).find("instructions").each(function() { $("

").text($(this).text()).appendTo(fieldset); }); $(x).find("field").each(function() { + var clearfix = $("

"); var item = self.buildHTMLField(this); var label = $(this).attr("label"); if(label) { - $("