# HG changeset patch # User Emmanuel Gil Peyrot # Date 1545597692 -3600 # Node ID 084202870d76d3d2d9f2719951f64fbc95424bc3 # Parent 45bd945c57227b804bab19aa33177bc2d64ca9bc Add nickname access model configuration. diff --git a/index.xhtml b/index.xhtml --- a/index.xhtml +++ b/index.xhtml @@ -68,6 +68,13 @@

Enter your nickname, so people you know can recognize you.

+

+ +

diff --git a/nickname.js b/nickname.js --- 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); + } }