Mercurial > eldonilo > lightstring
annotate plugins/disco.js @ 45:063e31247e71
Fix disco plugin.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 31 Jan 2012 21:09:07 +0100 |
parents | 6773e5bc2ca0 |
children | aaad98b33f86 |
rev | line source |
---|---|
30
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 'use strict'; |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
2 |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
3 /** |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 Copyright (c) 2011, Sonny Piers <sonny at fastmail dot net> |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
6 Permission to use, copy, modify, and/or distribute this software for any |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
7 purpose with or without fee is hereby granted, provided that the above |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
8 copyright notice and this permission notice appear in all copies. |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 */ |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 ///////// |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
20 //Disco// |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 ///////// |
45
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
22 Lightstring.plugins['disco'] = { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
23 namespaces: { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
24 'disco#info': "http://jabber.org/protocol/disco#info", |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
25 'disco#items': "http://jabber.org/protocol/disco#items" |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
26 }, |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
27 stanzas: { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
28 'disco#info': function(aTo, aNode) { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
29 if(aTo) |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
30 var iq = "<iq type='get' to='"+aTo+"'>"; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
31 else |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
32 var iq = "<iq type='get'>"; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
33 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
34 if(aNode) |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
35 var query = "<query xmlns='"+Lightstring.NS['disco#items']+"' node='"+aNode+"'/>"; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
36 else |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
37 var query = "<query xmlns='"+Lightstring.NS['disco#items']+"'/>"; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
38 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
39 return iq+query+"</iq>"; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
40 }, |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
41 'disco#info': function(aTo, aNode) { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
42 if(aTo) |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
43 var iq = "<iq type='get' to='"+aTo+"'>"; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
44 else |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
45 var iq = "<iq type='get'>"; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
46 if(aNode) |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
47 var query = "<query xmlns='"+Lightstring.NS['disco#info']+"' node='"+aNode+"'/>"; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
48 else |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
49 var query = "<query xmlns='"+Lightstring.NS['disco#info']+"'/>"; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
50 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
51 return iq+query+"</iq>"; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
52 } |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
53 }, |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
54 handlers: { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
55 //TODO: fix that handler. |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
56 /*conn.on('iq/' + Lightstring.NS['disco#info'] + ':query', function(stanza) { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
57 if (stanza.DOM.getAttributeNS(null, 'type') !== 'get') |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
58 return; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
59 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
60 var query = stanza.DOM.firstChild; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
61 if (query.getAttributeNS(null, 'node')) { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
62 var response = "<iq to='" + stanza.DOM.getAttributeNS(null, 'from') + "'" + |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
63 " id='" + stanza.DOM.getAttributeNS(null, 'id') + "'" + |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
64 " type='error'/>"; //TODO: precise the error. |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
65 conn.send(response); |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
66 return; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
67 } |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
68 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
69 var features = [Lightstring.NS.sxe, Lightstring.NS.jingle.transports.sxe]; //TODO: put that elsewhere. |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
70 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
71 var response = "<iq to='" + stanza.DOM.getAttributeNS(null, 'from') + "'" + |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
72 " id='" + stanza.DOM.getAttributeNS(null, 'id') + "'" + |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
73 " type='result'>" + |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
74 "<query xmlns='" + Lightstring.NS['disco#info'] + "'>" + |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
75 "<identity category='client' type='browser'/>"; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
76 features.forEach(function(f) { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
77 response += "<feature var='" + f + "'/>"; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
78 }); |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
79 response += "</query>" + |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
80 "</iq>"; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
81 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
82 conn.send(response); |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
83 });*/ |
30
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
84 }, |
45
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
85 methods: { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
86 discoItems: function(aTo, aResult, aError) { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
87 this.send(Lightstring.stanzas.disco.items(aTo), function (stanza) { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
88 var items = []; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
89 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
90 var children = stanza.DOM.firstChild.childNodes; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
91 var length = children.length; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
92 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
93 for (var i = 0; i < length; i++) { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
94 var node = children[i]; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
95 if (node.localName !== 'item') |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
96 continue; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
97 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
98 var item = { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
99 jid: node.getAttributeNS(null, 'jid'), |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
100 name: node.getAttributeNS(null, 'name'), |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
101 node: node.getAttributeNS(null, 'node') |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
102 }; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
103 items.push(item); |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
104 } |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
105 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
106 stanza.items = items; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
107 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
108 if (aResult) |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
109 aResult(stanza); |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
110 }, aError); |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
111 }, |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
112 discoInfo: function(aTo, aNode, aResult, aError) { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
113 this.send(Lightstring.stanzas.disco.info(aTo, aNode), function(stanza){ |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
114 var identities = []; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
115 var features = []; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
116 var fields = {}; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
117 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
118 var children = stanza.DOM.firstChild.childNodes; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
119 var length = children.length; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
120 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
121 for (var i = 0; i < length; i++) { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
122 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
123 if (children[i].localName === 'feature') |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
124 features.push(children[i].getAttributeNS(null, 'var')); |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
125 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
126 else if (children[i].localName === 'identity') { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
127 var identity = { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
128 category: children[i].getAttributeNS(null, 'category'), |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
129 type: children[i].getAttributeNS(null, 'type') |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
130 }; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
131 var name = children[i].getAttributeNS(null, 'name'); |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
132 if (name) |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
133 identity.name = name; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
134 identities.push(identity); |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
135 } |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
136 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
137 else if (children[i].localName === 'x') { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
138 for (var j = 0; j < children[i].childNodes.length; j++) { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
139 var child = children[i].childNodes[j]; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
140 var field = { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
141 type: child.getAttribute('type') |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
142 }; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
143 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
144 var _var = child.getAttribute('var'); |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
145 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
146 var label = child.getAttribute('label'); |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
147 if (label) |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
148 field.label = label; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
149 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
150 for (var y = 0; y < child.childNodes.length; y++) { |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
151 if(child.childNodes[y].localName === 'desc') |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
152 field.desc = child.childNodes[y].textContent; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
153 else if(child.childNodes[y].localName === 'required') |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
154 field.required = true; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
155 else if(child.childNodes[y].localName === 'value') |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
156 field.value = child.childNodes[y].textContent; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
157 } |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
158 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
159 fields[_var] = field; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
160 } |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
161 } |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
162 } |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
163 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
164 stanza.identities = identities; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
165 stanza.features = features; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
166 stanza.fields = fields; |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
167 |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
168 if (aResult) |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
169 aResult(stanza); |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
170 }, aError); |
063e31247e71
Fix disco plugin.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
37
diff
changeset
|
171 } |
30
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
172 } |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
173 }; |