X-Git-Url: http://cgit.babelmonkeys.de/?p=adhocweb.git;a=blobdiff_plain;f=js%2Fadhoc.js;h=51932499f7a099ac94a96f8daa20d78f4509d1c9;hp=7e2ba521bc30e910dcc9a258bc973493d2e6855b;hb=3a1e752b5d9120ffd6def0a5e17e2cf536209854;hpb=e55b23864a9911c15d930b43ed9afe1df5943bf7 diff --git a/js/adhoc.js b/js/adhoc.js index 7e2ba52..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 + }; +} - addNote: function (elem, text, type) { +Adhoc.prototype = { + constructor: Adhoc, + + 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) { - $("