Mercurial > eldonilo > blog
comparison forms.js @ 11:f4422eafb0f8
Make forms building actually working.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 02 Nov 2011 10:02:31 -0700 |
parents | f62b5c395a48 |
children |
comparison
equal
deleted
inserted
replaced
10:360186772aa3 | 11:f4422eafb0f8 |
---|---|
17 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>. | 17 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>. |
18 */ | 18 */ |
19 | 19 |
20 'use strict'; | 20 'use strict'; |
21 | 21 |
22 var xmpp = require('xmpp') | 22 var Element = require('ltx').Element; |
23 | 23 |
24 var parseBoolean = function(b) { | 24 var parseBoolean = function(b) { |
25 if (b == 'true' || b == 'True' || b == 'TRUE' || b == '1') | 25 if (b == 'true' || b == 'True' || b == 'TRUE' || b == '1') |
26 return true; | 26 return true; |
27 return false; | 27 return false; |
28 } | 28 } |
29 | 29 |
30 exports.build = function(type, desc, content, labels, title, instructions) { | 30 var forms = exports || {}; |
31 var x = xmpp.stanza('x', {xmlns: 'jabber:x:data', type: type}); | 31 |
32 forms.build = function(type, desc, content, labels, title, instructions) { | |
33 var x = Element('x', {xmlns: 'jabber:x:data', type: type}); | |
32 | 34 |
33 if (desc._TITLE) | 35 if (desc._TITLE) |
34 x.c('title').t(desc._TITLE).up(); | 36 x.c('title').t(desc._TITLE).up(); |
35 else if (title) | 37 else if (title) |
36 x.c('title').t(title).up(); | 38 x.c('title').t(title).up(); |
88 x.up(); | 90 x.up(); |
89 } | 91 } |
90 return x; | 92 return x; |
91 } | 93 } |
92 | 94 |
93 exports.parse = function(x, params) { | 95 forms.parse = function(x, params) { |
94 var form = {}; | 96 var form = {}; |
95 | 97 |
96 x.constructor.prototype.getAttribute = function(a) { | 98 x.constructor.prototype.getAttribute = function(a) { |
97 return this.attrs[a]; | 99 return this.attrs[a]; |
98 } | 100 } |