Mercurial > eldonilo > lightstring
comparison plugins/disco.js @ 37:6773e5bc2ca0
several fixes
author | Sonny Piers <sonny.piers@gmail.com> |
---|---|
date | Mon, 30 Jan 2012 23:46:55 +0100 |
parents | bdfbd58b4835 |
children | 063e31247e71 |
comparison
equal
deleted
inserted
replaced
36:b43ca01b9f6f | 37:6773e5bc2ca0 |
---|---|
67 }; | 67 }; |
68 Lightstring.discoInfo = function(aConnection, aTo, aNode, aCallback) { | 68 Lightstring.discoInfo = function(aConnection, aTo, aNode, aCallback) { |
69 aConnection.send(Lightstring.stanza.disco.info(aTo, aNode), function(stanza){ | 69 aConnection.send(Lightstring.stanza.disco.info(aTo, aNode), function(stanza){ |
70 var identities = []; | 70 var identities = []; |
71 var features = []; | 71 var features = []; |
72 var fields = {}; | |
72 | 73 |
73 var children = stanza.DOM.firstChild.children; | 74 var children = stanza.DOM.firstChild.childNodes; |
74 var length = children.length; | 75 var length = children.length; |
75 | 76 |
76 for (var i = 0; i < length; i++) { | 77 for (var i = 0; i < length; i++) { |
77 var child = children[i]; | |
78 | 78 |
79 if (child.localName === 'feature') | 79 if (children[i].localName === 'feature') |
80 features.push(child.getAttributeNS(null, 'var')); | 80 features.push(children[i].getAttributeNS(null, 'var')); |
81 | 81 |
82 else if (child.localName === 'identity') { | 82 else if (children[i].localName === 'identity') { |
83 var identity = { | 83 var identity = { |
84 category: child.getAttributeNS(null, 'category'), | 84 category: children[i].getAttributeNS(null, 'category'), |
85 type: child.getAttributeNS(null, 'type') | 85 type: children[i].getAttributeNS(null, 'type') |
86 }; | 86 }; |
87 var name = child.getAttributeNS(null, 'name'); | 87 var name = children[i].getAttributeNS(null, 'name'); |
88 if (name) | 88 if (name) |
89 identity.name = name; | 89 identity.name = name; |
90 identities.push(identity); | 90 identities.push(identity); |
91 } | 91 } |
92 | |
93 else if (children[i].localName === 'x') { | |
94 for (var j = 0; j < children[i].childNodes.length; j++) { | |
95 var child = children[i].childNodes[j]; | |
96 var field = { | |
97 type: child.getAttribute('type') | |
98 }; | |
99 | |
100 var _var = child.getAttribute('var'); | |
101 | |
102 var label = child.getAttribute('label'); | |
103 if(label) field.label = label; | |
104 | |
105 | |
106 for (var y = 0; y < child.childNodes.length; y++) { | |
107 if(child.childNodes[y].localName === 'desc') | |
108 field.desc = child.childNodes[y].textContent; | |
109 else if(child.childNodes[y].localName === 'required') | |
110 field.required = true; | |
111 else if(child.childNodes[y].localName === 'value') | |
112 field.value = child.childNodes[y].textContent; | |
113 } | |
114 | |
115 | |
116 fields[_var] = field; | |
117 } | |
118 } | |
92 } | 119 } |
93 | 120 |
94 aCallback({identities: identities, features: features}); | 121 aCallback({'identities': identities, 'features': features, 'fields': fields}, stanza); |
95 }); | 122 }); |
96 }; | 123 }; |