Mercurial > eldonilo > lightstring
changeset 80:50d36b093e3a
Lightstring.namespaces/NS has been renamed by Lightstring.ns.
author | Sonny Piers <sonny.piers@gmail.com> |
---|---|
date | Tue, 07 Feb 2012 18:42:09 +0100 |
parents | 2290321f5c8b |
children | 7500bc048dbc |
files | plugins/dataforms.js plugins/disco.js plugins/pubsub.js |
diffstat | 3 files changed, 27 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/dataforms.js +++ b/plugins/dataforms.js @@ -45,25 +45,25 @@ if (_var) field.var = _var; - var desc = child.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'desc'); + var desc = child.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'desc'); if (desc.length > 1) ; //TODO: emit a warning if there is more than one. if (0 in desc) field.desc = desc[0]; - var required = child.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'required'); + var required = child.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'required'); if (required.length > 1) ; //TODO: emit a warning if there is more than one. field.required = (0 in required) - var values = child.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'value'); + var values = child.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'value'); if (values.length) { field.values = []; for (var j = 0; j < values.length; j++) field.values.push(values[j].textContent); } - var options = child.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'option'); + var options = child.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'option'); if (options.length) { field.options = []; for (var j = 0; j < options.length; j++) { @@ -71,7 +71,7 @@ var opt = options[j]; - var val = opt.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'value'); + var val = opt.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'value'); if (val.length > 1) ; //TODO: emit a warning if there is more than one. if (0 in val) @@ -97,7 +97,7 @@ }, methods: { parse: function(x) { - if (x.namespaceURI !== Lightstring.namespaces['dataforms'] || x.localName !== 'x') + if (x.namespaceURI !== Lightstring.ns['dataforms'] || x.localName !== 'x') return null; var form = {}; @@ -107,28 +107,28 @@ return; //TODO: emit a warning too? form.type = type; - var title = x.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'title'); + var title = x.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'title'); if (title.length > 1) ; //TODO: emit a warning if there is more than one. else if (0 in title) form.title = title[0]; - var fields = parseFields(x.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'fields')); + var fields = parseFields(x.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'field')); if (fields) form.fields = fields - var reported = x.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'reported'); + var reported = x.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'reported'); if (reported.length > 1) ; //TODO: emit a warning if there is more than one. else if (0 in reported) { - var fields = parseFields(reported[0].getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'fields')); + var fields = parseFields(reported[0].getElementsByTagNameNS(Lightstring.ns['dataforms'], 'field')); if (fields) form.reported = fields } - var itemsList = x.getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'item'); - if (itemsList) { - var fields = parseFields(itemsList[0].getElementsByTagNameNS(Lightstring.namespaces['dataforms'], 'fields')); + var itemsList = x.getElementsByTagNameNS(Lightstring.ns['dataforms'], 'item'); + if (itemsList.length) { + var fields = parseFields(itemsList[0].getElementsByTagNameNS(Lightstring.ns['dataforms'], 'fields')); if (fields) form.items = fields; }
--- a/plugins/disco.js +++ b/plugins/disco.js @@ -96,10 +96,10 @@ var ns = child.namespaceURI; var name = child.localName; - if (ns === Lightstring.namespaces['disco#info'] && name === 'feature') + if (ns === Lightstring.ns['disco#info'] && name === 'feature') features.push(child.getAttributeNS(null, 'var')); - else if (ns === Lightstring.namespaces['disco#info'] && name === 'identity') { + else if (ns === Lightstring.ns['disco#info'] && name === 'identity') { var identity = { category: child.getAttributeNS(null, 'category'), type: child.getAttributeNS(null, 'type') @@ -109,10 +109,9 @@ identity.name = name; identities.push(identity); } - - else if (ns === Lightstring.namespaces['dataforms'] && name === 'x') - this.disco.parse(child); //TODO: check if that plugin is enabled. - + else if (ns === Lightstring.ns['dataforms'] && name === 'x') { + var fields = this.dataforms.parse(child); //TODO: check if that plugin is enabled. + } else ; //TODO: emit a warning. }
--- a/plugins/pubsub.js +++ b/plugins/pubsub.js @@ -32,27 +32,27 @@ }, stanzas: { getConfig: function(aTo, aNode) { - return "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.NS.pubsub_owner + "'><configure node='" + aNode + "'/></pubsub></iq>"; + return "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub_owner + "'><configure node='" + aNode + "'/></pubsub></iq>"; }, items: function(aTo, aNode) { - return "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.NS.pubsub + "'><items node='" + aNode + "'/></pubsub></iq>"; + return "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub + "'><items node='" + aNode + "'/></pubsub></iq>"; }, affiliations: function(aTo, aNode) { - return "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.NS.pubsub_owner + "'><affiliations node='" + aNode + "'/></pubsub></iq>"; + return "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub_owner + "'><affiliations node='" + aNode + "'/></pubsub></iq>"; }, publish: function(aTo, aNode, aItem, aId) { - return "<iq type='set' to='" + aTo + "'><pubsub xmlns='" + Lightstring.NS.pubsub + "'><publish node='" + aNode + "'><item id='" + aId + "'>" + aItem + "</item></publish></pubsub></iq>"; + return "<iq type='set' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub + "'><publish node='" + aNode + "'><item id='" + aId + "'>" + aItem + "</item></publish></pubsub></iq>"; }, retract: function(aTo, aNode, aItem) { - return "<iq type='set' to='" + aTo + "'><pubsub xmlns='" + Lightstring.NS.pubsub + "'><retract node='" + aNode + "'><item id='" + aItem + "'/></retract></pubsub></iq>"; + return "<iq type='set' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub + "'><retract node='" + aNode + "'><item id='" + aItem + "'/></retract></pubsub></iq>"; }, 'delete': function(aTo, aNode, aURI) { - return "<iq type='set' to='" + aTo + "'><pubsub xmlns='" + Lightstring.NS.pubsub_owner + "'><delete node='" + aNode + "'/></pubsub></iq>"; + return "<iq type='set' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub_owner + "'><delete node='" + aNode + "'/></pubsub></iq>"; }, create: function(aTo, aNode, aFields) { - var iq = "<iq type='set' to='" + aTo + "'><pubsub xmlns='" + Lightstring.NS.pubsub + "'><create node='" + aNode + "'/>"; + var iq = "<iq type='set' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub + "'><create node='" + aNode + "'/>"; if (aFields) { - iq += "<configure><x xmlns='" + Lightstring.NS.x + "' type='submit'>" + iq += "<configure><x xmlns='" + Lightstring.ns.x + "' type='submit'>" aFields.forEach(function(field) { iq += field; }); @@ -62,7 +62,7 @@ return iq; }, setAffiliations: function(aTo, aNode, aAffiliations) { - var iq = "<iq type='set' to='" + aTo + "'><pubsub xmlns='" + Lightstring.NS.pubsub_owner + "'><affiliations node='" + aNode + "'>"; + var iq = "<iq type='set' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub_owner + "'><affiliations node='" + aNode + "'>"; for (var i = 0; i < aAffiliations.length; i++) iq += "<affiliation jid='" + aAffiliations[i][0] + "' affiliation='" + aAffiliations[i][1] + "'/>"; iq += "</affiliations></pubsub></iq>";