Mercurial > xmpp-account-manager
comparison 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 |
comparison
equal
deleted
inserted
replaced
34:45bd945c5722 | 35:084202870d76 |
---|---|
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 function initNickname(connection) { | 3 function initNickname(connection) { |
4 const nick_input = document.getElementById('nick'); | 4 const nick_input = document.getElementById('nick'); |
5 const nick_access = document.getElementById('nick-access'); | |
5 const spinner_img = document.getElementById('nick-spinner'); | 6 const spinner_img = document.getElementById('nick-spinner'); |
7 const access_spinner_img = document.getElementById('nick-access-spinner'); | |
6 | 8 |
7 const iq = $iq({type: 'get'}) | 9 const iq = $iq({type: 'get'}) |
8 .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub'}) | 10 .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub'}) |
9 .c('items', {node: 'http://jabber.org/protocol/nick'}); | 11 .c('items', {node: 'http://jabber.org/protocol/nick'}); |
10 connection.sendIQ(iq, onNickname, onNicknameRetrievalError.bind(null, 'PubSub query failed.')); | 12 connection.sendIQ(iq, onNickname, onNicknameRetrievalError.bind(null, 'PubSub query failed.')); |
47 function onNicknameChangeError(iq) | 49 function onNicknameChangeError(iq) |
48 { | 50 { |
49 console.log("onNicknameChangeError", iq); | 51 console.log("onNicknameChangeError", iq); |
50 spinnerError(spinner_img); | 52 spinnerError(spinner_img); |
51 } | 53 } |
54 | |
55 nick_access.addEventListener('change', function (evt) { | |
56 const iq = configurePEPField('http://jabber.org/protocol/nick', 'pubsub#access_model', evt.target.value); | |
57 connection.sendIQ(iq, onNicknameConfigured, onNicknameConfigureError); | |
58 displaySpinner(access_spinner_img); | |
59 }); | |
60 | |
61 function onNicknameConfigured(iq) | |
62 { | |
63 console.log('Successfully set nickname access model.') | |
64 spinnerOk(access_spinner_img); | |
65 } | |
66 | |
67 function onNicknameConfigureError(iq) | |
68 { | |
69 const string = 'Failed to configure nick node: ' + parseErrorIq(iq); | |
70 console.log(string); | |
71 spinnerError(access_spinner_img, string); | |
72 } | |
52 } | 73 } |