Mercurial > xmpp-account-manager
view util.js @ 25:d9da5c3e305d
Add support for setting some vCard4 fields.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 23 Dec 2018 16:34:30 +0100 |
parents | 6c620e9f7d2c |
children | 9ba4f8cc32f1 |
line wrap: on
line source
const NS = { xrd: 'http://docs.oasis-open.org/ns/xri/xrd-1.0', roster: 'jabber:iq:roster', disco_items: 'http://jabber.org/protocol/disco#items', disco_info: 'http://jabber.org/protocol/disco#info', dataforms: 'jabber:x:data', pubsub: 'http://jabber.org/protocol/pubsub', pubsub_owner: 'http://jabber.org/protocol/pubsub#owner', avatar_metadata: 'urn:xmpp:avatar:metadata', avatar_data: 'urn:xmpp:avatar:data', nickname: 'http://jabber.org/protocol/nick', vcard4: 'urn:ietf:params:xml:ns:vcard-4.0', mam: 'urn:xmpp:mam:2', forward: 'urn:xmpp:forward:0', }; function nsResolver(prefix) { return NS[prefix] || null; } function parseXPath(elem, xpath, result) { if (result === undefined) result = XPathResult.FIRST_ORDERED_NODE_TYPE; const value = elem.getRootNode().evaluate(xpath, elem, nsResolver, result, null); if (result == XPathResult.FIRST_ORDERED_NODE_TYPE) return value.singleNodeValue; return value; } function parseXPathText(elem, xpath) { const value = parseXPath(elem, xpath); if (value === null) return null; return value.textContent; } function configurePEPField(node, key, value, cb, err_cb) { return $iq({type: 'set'}) .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub#owner'}) .c('configure', {node: node}) .c('x', {xmlns: 'jabber:x:data', type: 'submit'}) .c('field', {'var': 'FORM_TYPE', type: 'hidden'}) .c('value') .t('http://jabber.org/protocol/pubsub#node_config') .up() .up() .c('field', {'var': key}) .c('value') .t(value) .up() .up(); } function displaySpinner(spinner) { if ('timeoutid' in spinner.dataset) clearTimeout(spinner.dataset.timeoutid); spinner.src = 'spinner.svg'; spinner.hidden = false; } function spinnerOk(spinner) { if ('timeoutid' in spinner.dataset) clearTimeout(spinner.dataset.timeoutid); spinner.src = 'ok.svg'; spinner.hidden = false; spinner.dataset.timeoutid = setTimeout(function () { spinner.hidden = true; }, 1000); } function spinnerError(spinner) { if ('timeoutid' in spinner.dataset) clearTimeout(spinner.dataset.timeoutid); spinner.src = 'error.svg'; spinner.hidden = false; } function hideSpinner(spinner) { if ('timeoutid' in spinner.dataset) clearTimeout(spinner.dataset.timeoutid); spinner.hidden = true; }