Mercurial > eldonilo > lightstring
annotate plugins/dataforms.js @ 108:5cb4733c5189
many api changes
author | Sonny Piers <sonny@fastmail.net> |
---|---|
date | Fri, 13 Jul 2012 15:26:18 +0200 |
parents | 7f4e43d6cb15 |
children |
rev | line source |
---|---|
58
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 'use strict'; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
2 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
3 /** |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 Copyright (c) 2012, Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
6 Permission to use, copy, modify, and/or distribute this software for any |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
7 purpose with or without fee is hereby granted, provided that the above |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
8 copyright notice and this permission notice appear in all copies. |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 */ |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 ///////// |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
20 //Disco// |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 ///////// |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
22 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
23 (function() { |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 var form_types = ['cancel', 'form', 'result', 'submit']; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
25 var field_types = ['boolean', 'fixed', 'hidden', 'jid-multi', 'jid-single', 'list-multi', 'list-single', 'text-multi', 'text-private', 'text-single']; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
27 var parseFields = function(fieldsList) { |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
28 var fields = []; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
29 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
30 for (var i = 0; i < fieldsList.length; i++) { |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
31 var field = {}; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
32 var child = fieldsList[i]; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
33 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
34 var type = child.getAttributeNS(null, 'type'); |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
35 if (field_types.indexOf(type) === -1) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
36 field.type = type; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
37 else |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
38 field.type = 'text-single'; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
39 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
40 var label = child.getAttributeNS(null, 'label'); |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
41 if (label) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
42 field.label = label; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
43 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
44 var _var = child.getAttributeNS(null, 'var'); |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
45 if (_var) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
46 field.var = _var; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
47 |
80
50d36b093e3a
Lightstring.namespaces/NS has been renamed by Lightstring.ns.
Sonny Piers <sonny.piers@gmail.com>
parents:
72
diff
changeset
|
48 var desc = child.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'desc'); |
58
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
49 if (desc.length > 1) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
50 ; //TODO: emit a warning if there is more than one. |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
51 if (0 in desc) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
52 field.desc = desc[0]; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
53 |
80
50d36b093e3a
Lightstring.namespaces/NS has been renamed by Lightstring.ns.
Sonny Piers <sonny.piers@gmail.com>
parents:
72
diff
changeset
|
54 var required = child.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'required'); |
58
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
55 if (required.length > 1) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
56 ; //TODO: emit a warning if there is more than one. |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
57 field.required = (0 in required) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
58 |
80
50d36b093e3a
Lightstring.namespaces/NS has been renamed by Lightstring.ns.
Sonny Piers <sonny.piers@gmail.com>
parents:
72
diff
changeset
|
59 var values = child.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'value'); |
58
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
60 if (values.length) { |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
61 field.values = []; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
62 for (var j = 0; j < values.length; j++) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
63 field.values.push(values[j].textContent); |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
64 } |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
65 |
80
50d36b093e3a
Lightstring.namespaces/NS has been renamed by Lightstring.ns.
Sonny Piers <sonny.piers@gmail.com>
parents:
72
diff
changeset
|
66 var options = child.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'option'); |
58
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
67 if (options.length) { |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
68 field.options = []; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
69 for (var j = 0; j < options.length; j++) { |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
70 var option = {}; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
71 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
72 var opt = options[j]; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
73 |
80
50d36b093e3a
Lightstring.namespaces/NS has been renamed by Lightstring.ns.
Sonny Piers <sonny.piers@gmail.com>
parents:
72
diff
changeset
|
74 var val = opt.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'value'); |
58
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
75 if (val.length > 1) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
76 ; //TODO: emit a warning if there is more than one. |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
77 if (0 in val) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
78 option.value = val[0]; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
79 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
80 var optionLabel = opt.getAttributeNS(null, 'label'); |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
81 if (optionLabel) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
82 option.label = optionLabel; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
83 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
84 field.options.push(option); |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
85 } |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
86 } |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
87 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
88 fields.push(field); |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
89 } |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
90 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
91 return fields; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
92 }; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
93 |
72 | 94 Lightstring.plugins['dataforms'] = { |
58
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
95 namespaces: { |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
96 dataforms: 'jabber:x:data' |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
97 }, |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
98 methods: { |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
99 parse: function(x) { |
80
50d36b093e3a
Lightstring.namespaces/NS has been renamed by Lightstring.ns.
Sonny Piers <sonny.piers@gmail.com>
parents:
72
diff
changeset
|
100 if (x.namespaceURI !== Lightstring.ns['dataforms'] || x.localName !== 'x') |
58
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
101 return null; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
102 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
103 var form = {}; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
104 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
105 var type = x.getAttributeNS(null, 'type'); |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
106 if (form_types.indexOf(type) === -1) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
107 return; //TODO: emit a warning too? |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
108 form.type = type; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
109 |
80
50d36b093e3a
Lightstring.namespaces/NS has been renamed by Lightstring.ns.
Sonny Piers <sonny.piers@gmail.com>
parents:
72
diff
changeset
|
110 var title = x.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'title'); |
58
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
111 if (title.length > 1) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
112 ; //TODO: emit a warning if there is more than one. |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
113 else if (0 in title) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
114 form.title = title[0]; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
115 |
80
50d36b093e3a
Lightstring.namespaces/NS has been renamed by Lightstring.ns.
Sonny Piers <sonny.piers@gmail.com>
parents:
72
diff
changeset
|
116 var fields = parseFields(x.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'field')); |
58
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
117 if (fields) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
118 form.fields = fields |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
119 |
80
50d36b093e3a
Lightstring.namespaces/NS has been renamed by Lightstring.ns.
Sonny Piers <sonny.piers@gmail.com>
parents:
72
diff
changeset
|
120 var reported = x.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'reported'); |
58
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
121 if (reported.length > 1) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
122 ; //TODO: emit a warning if there is more than one. |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
123 else if (0 in reported) { |
80
50d36b093e3a
Lightstring.namespaces/NS has been renamed by Lightstring.ns.
Sonny Piers <sonny.piers@gmail.com>
parents:
72
diff
changeset
|
124 var fields = parseFields(reported[0].getElementsByTagNameNS(Lightstring.ns['dataforms'], 'field')); |
58
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
125 if (fields) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
126 form.reported = fields |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
127 } |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
128 |
80
50d36b093e3a
Lightstring.namespaces/NS has been renamed by Lightstring.ns.
Sonny Piers <sonny.piers@gmail.com>
parents:
72
diff
changeset
|
129 var itemsList = x.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'item'); |
82
06495f77a74c
Fix a problem with dataforms.
Sonny Piers <sonny.piers@gmail.com>
parents:
81
diff
changeset
|
130 if (itemsList.length) { |
80
50d36b093e3a
Lightstring.namespaces/NS has been renamed by Lightstring.ns.
Sonny Piers <sonny.piers@gmail.com>
parents:
72
diff
changeset
|
131 var fields = parseFields(itemsList[0].getElementsByTagNameNS(Lightstring.ns['dataforms'], 'fields')); |
58
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
132 if (fields) |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
133 form.items = fields; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
134 } |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
135 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
136 return form; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
137 } |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
138 } |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
139 }; |
84 | 140 })(); |