Mercurial > xmpp-account-manager
comparison nickname.js @ 7:13e8e4ea53c0
Change nickname on blur, remove the button.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 22 Dec 2018 16:07:26 +0100 |
parents | d6df73b466f6 |
children | e47b9bd55192 |
comparison
equal
deleted
inserted
replaced
6:129f5c565f1b | 7:13e8e4ea53c0 |
---|---|
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_change = document.getElementById('nick-change'); | |
6 | 5 |
7 const iq = $iq({type: 'get'}) | 6 const iq = $iq({type: 'get'}) |
8 .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub'}) | 7 .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub'}) |
9 .c('items', {node: 'http://jabber.org/protocol/nick'}); | 8 .c('items', {node: 'http://jabber.org/protocol/nick'}); |
10 connection.sendIQ(iq, onNickname, onNicknameRetrievalError.bind(null, 'PubSub query failed.')); | 9 connection.sendIQ(iq, onNickname, onNicknameRetrievalError.bind(null, 'PubSub query failed.')); |
22 function onNicknameRetrievalError(string) | 21 function onNicknameRetrievalError(string) |
23 { | 22 { |
24 console.log('Failed to retrieve nickname: ' + string); | 23 console.log('Failed to retrieve nickname: ' + string); |
25 } | 24 } |
26 | 25 |
27 nick_change.addEventListener('click', function (evt) { | 26 nick_input.addEventListener('blur', function (evt) { |
28 const iq = $iq({type: 'set'}) | 27 const iq = $iq({type: 'set'}) |
29 .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub'}) | 28 .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub'}) |
30 .c('publish', {node: 'http://jabber.org/protocol/nick'}) | 29 .c('publish', {node: 'http://jabber.org/protocol/nick'}) |
31 .c('item', {id: 'current'}) | 30 .c('item', {id: 'current'}) |
32 .c('nick', {xmlns: 'http://jabber.org/protocol/nick'}) | 31 .c('nick', {xmlns: 'http://jabber.org/protocol/nick'}) |