Mercurial > eldonilo > lightstring
annotate plugins/dataforms.js @ 68:e1ccfb580228
Replaces that by Conn.
author | Sonny Piers <sonny.piers@gmail.com> |
---|---|
date | Thu, 02 Feb 2012 00:00:34 +0100 |
parents | bcb5b7c2c3d3 |
children | 5dbf93cef55d |
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 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
48 var desc = child.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'desc'); |
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 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
54 var required = child.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'required'); |
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 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
59 var values = child.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'value'); |
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 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
66 var options = child.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'option'); |
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 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
74 var val = opt.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'value'); |
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 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
94 Lightstring.plugins['disco'] = { |
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) { |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
100 if (x.namespaceURI !== Lightstring.namespaces['dataforms'] || x.localName !== 'x') |
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 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
110 var title = x.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'title'); |
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 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
116 var fields = parseFields(x.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'fields')); |
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 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
120 var reported = x.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'reported'); |
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) { |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
124 var fields = parseFields(reported[0].getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'fields')); |
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 |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
129 var itemsList = x.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'item'); |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
130 if (itemsList) { |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
131 var fields = parseFields(itemsList[0].getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'fields')); |
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 }; |
bcb5b7c2c3d3
Add a dataforms plugin and make disco#info use this one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
140 })(); |