Mercurial > xmpp-account-manager
diff nickname.js @ 35:084202870d76
Add nickname access model configuration.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 23 Dec 2018 21:41:32 +0100 |
parents | 45bd945c5722 |
children | b76146a09e07 |
line wrap: on
line diff
--- a/nickname.js +++ b/nickname.js @@ -2,7 +2,9 @@ function initNickname(connection) { const nick_input = document.getElementById('nick'); + const nick_access = document.getElementById('nick-access'); const spinner_img = document.getElementById('nick-spinner'); + const access_spinner_img = document.getElementById('nick-access-spinner'); const iq = $iq({type: 'get'}) .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub'}) @@ -49,4 +51,23 @@ function initNickname(connection) { console.log("onNicknameChangeError", iq); spinnerError(spinner_img); } + + nick_access.addEventListener('change', function (evt) { + const iq = configurePEPField('http://jabber.org/protocol/nick', 'pubsub#access_model', evt.target.value); + connection.sendIQ(iq, onNicknameConfigured, onNicknameConfigureError); + displaySpinner(access_spinner_img); + }); + + function onNicknameConfigured(iq) + { + console.log('Successfully set nickname access model.') + spinnerOk(access_spinner_img); + } + + function onNicknameConfigureError(iq) + { + const string = 'Failed to configure nick node: ' + parseErrorIq(iq); + console.log(string); + spinnerError(access_spinner_img, string); + } }