Mercurial > psgxs
diff forms.js @ 23:5fc4ee90c1bc
A lot of refactorization. First attempt to modularize the server.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 31 Oct 2010 23:58:07 +0100 |
parents | efe8dbd34780 |
children | 023f767662d3 |
line wrap: on
line diff
--- a/forms.js +++ b/forms.js @@ -33,14 +33,14 @@ exports.build = function(type, desc, con desc = service_configuration[desc]; if (desc._TITLE) - x.s('title').t(desc._TITLE); + x.c('title').t(desc._TITLE).up(); else if (title) - x.s('title').t(title); + x.c('title').t(title).up(); if (desc._INSTRUCTIONS) - x.s('instructions').t(desc._INSTRUCTIONS); + x.c('instructions').t(desc._INSTRUCTIONS).up(); else if (instructions) - x.s('instructions').t(instructions); + x.c('instructions').t(instructions).up(); if (content == 'default') { content = {}; @@ -60,7 +60,7 @@ exports.build = function(type, desc, con if (desc[i].label) fieldAttr.label = desc[i].label; } - var field = xmpp.stanza('field', fieldAttr); + x.c('field', fieldAttr); if (labels && (desc[i].type == 'list-multi' || @@ -69,29 +69,27 @@ exports.build = function(type, desc, con var optAttr = {}; if (desc[i].options[j].label) optAttr.label = desc[i].options[j].label; - field.s('option', optAttr).c('value').t(j); + x.c('option', optAttr).c('value').t(j).up().up(); } } if (i == 'FORM_TYPE') - field.s('value').t(desc[i].value); + x.c('value').t(desc[i].value).up(); else if (typeof content[i] != 'undefined') { var md = content[i]; if (desc[i].type == 'jid-multi' || desc[i].type == 'list-multi' || desc[i].type == 'text-multi') { for (var j=0; j<md.length; j++) - field.s('value') - .t(md[j].toString()); + x.c('value') + .t(md[j].toString()).up(); } else - field.s('value').t(md.toString()); + x.c('value').t(md.toString()).up(); } - x.cnode(field); + x.up(); } - if (field) - return x; - return -1; //FIXME + return x; } exports.parse = function(x, params) {