changeset 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 129f5c565f1b
children 56d017ac52df
files index.xhtml nickname.js
diffstat 2 files changed, 2 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/index.xhtml
+++ b/index.xhtml
@@ -52,8 +52,7 @@
 <h1>Account</h1>
 <h2>Nickname</h2>
 <p>
-<label>Nickname: <input id="nick"/></label><br/>
-<button id="nick-change">Change my nickname</button>
+<label>Nickname: <input id="nick"/></label>
 </p>
 <h2>Avatar</h2>
 <p>
--- a/nickname.js
+++ b/nickname.js
@@ -2,7 +2,6 @@
 
 function initNickname(connection) {
     const nick_input = document.getElementById('nick');
-    const nick_change = document.getElementById('nick-change');
 
     const iq = $iq({type: 'get'})
         .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub'})
@@ -24,7 +23,7 @@ function initNickname(connection) {
         console.log('Failed to retrieve nickname: ' + string);
     }
 
-    nick_change.addEventListener('click', function (evt) {
+    nick_input.addEventListener('blur', function (evt) {
         const iq = $iq({type: 'set'})
             .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub'})
                 .c('publish', {node: 'http://jabber.org/protocol/nick'})