Mercurial > xmpp-account-manager
comparison avatar.js @ 1:d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 21 Dec 2018 23:44:18 +0100 |
parents | 2a8d4e8600d0 |
children | db033e5eabcb |
comparison
equal
deleted
inserted
replaced
0:2a8d4e8600d0 | 1:d6df73b466f6 |
---|---|
146 avatar_change.disabled = false; | 146 avatar_change.disabled = false; |
147 } | 147 } |
148 sha1_reader.readAsArrayBuffer(file); | 148 sha1_reader.readAsArrayBuffer(file); |
149 }); | 149 }); |
150 | 150 |
151 function nsResolver(prefix) { | |
152 return { | |
153 pubsub: 'http://jabber.org/protocol/pubsub', | |
154 avatar_metadata: 'urn:xmpp:avatar:metadata', | |
155 avatar_data: 'urn:xmpp:avatar:data', | |
156 }[prefix] || null; | |
157 } | |
158 | |
159 function parseXPath(elem, xpath) | |
160 { | |
161 return elem.getRootNode().evaluate(xpath, elem, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
162 } | |
163 | |
164 function friendlyDataSize(bytes) { | 151 function friendlyDataSize(bytes) { |
165 let unit = 'B' | 152 let unit = 'B' |
166 if (bytes >= 1024) { | 153 if (bytes >= 1024) { |
167 bytes /= 1024; | 154 bytes /= 1024; |
168 unit = 'KiB'; | 155 unit = 'KiB'; |