+ buildHTMLField: function(fld) {
+ var field = $(fld), html = {
+ "hidden" : "<input type='hidden'/>",
+ "boolean" : "<input type='checkbox'/>",
+ "fixed" : "<input type='text' readonly='true'/>",
+ "text-single" : "<input type='text'/>",
+ "text-private": "<input type='password'/>",
+ "text-multi" : "<textarea rows='10' cols='70'/>",
+ "jid-single" : "<input type='text'/>",
+ "jid-multi" : "<textarea rows='10' cols='70'/>",
+ "list-single" : "<select/>",
+ "list-multi" : "<select multiple='multiple'/>",
+ };
+ var type = field.attr('type');
+ var input = $(html[type] || "<input/>");
+ var name = field.attr("var");
+
+ input.addClass("df-item");
+ if (name) {
+ input.attr("name", name);
+ input.attr("id", name);
+ }
+
+ if (field.find("required").length > 0)
+ input.attr("required", "required");
+
+ /* Add possible values to the lists */
+ if (type === 'list-multi' || type==='list-single') {
+ field.find("option").each(function() {
+ var option = $("<option/>");
+ option.text($(this).attr("label"));
+ option.val($(this).find("value").text());
+ input.append(option);
+ });
+ }
+
+ /* Add/select default values */
+ field.children("value").each(function() {
+ var value = $(this).text();
+ if ((type === "text-multi") || (type === "jid-multi")) {
+ input.text(input.text() + value + "\n"); /* .append() would work, but doesn't escape */
+ } else if (type === "list-multi") {
+ input.children('option[value="' + value + '"]').each(function() {
+ $(this).attr("selected", "selected");
+ });
+ } else {
+ input.val(value);
+ }
+ });
+
+ return input;
+ },
+