Mercurial > xmpp-account-manager
diff avatar.js @ 15:3eed9fe0bd7c
End spinners with either a green ✔ or a red ✘.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 22 Dec 2018 18:38:27 +0100 |
parents | 8724e28ccbd7 |
children | cd35420457ac |
line wrap: on
line diff
--- a/avatar.js +++ b/avatar.js @@ -18,7 +18,7 @@ function initAvatar(connection) { .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub'}) .c('items', {node: 'urn:xmpp:avatar:metadata'}); connection.sendIQ(iq, onAvatarMetadata, onAvatarRetrievalError.bind(null, 'PubSub metadata query failed.')); - spinner_img.hidden = false; + displaySpinner(spinner_img); function onAvatarMetadata(result_iq) { @@ -67,14 +67,14 @@ function initAvatar(connection) { }; */ avatar_img.src = url; - spinner_img.hidden = true; + hideSpinner(spinner_img); } function onAvatarRetrievalError(string) { console.log('Failed to retrieve avatar, an empty one is displayed instead: ' + string); avatar_img.src = DEFAULT_AVATAR; - spinner_img.hidden = true; + hideSpinner(spinner_img); } avatar_upload.addEventListener('click', function (evt) { @@ -95,7 +95,7 @@ function initAvatar(connection) { height: avatar_img.naturalHeight, }); connection.sendIQ(metadata_iq, onAvatarMetadataUpload, onAvatarUploadError); - spinner_img.hidden = false; + displaySpinner(spinner_img); }); function onAvatarMetadataUpload(iq) @@ -114,13 +114,13 @@ function initAvatar(connection) { console.log('Avatar successfully uploaded!', iq); avatar_change.hidden = true; avatar_size.innerHTML = ''; - spinner_img.hidden = true; + spinnerOk(spinner_img); } function onAvatarUploadError(iq) { console.log("onAvatarUploadError", iq); - spinner_img.hidden = true; + spinnerError(spinner_img); } avatar_file.addEventListener('change', function (evt) { @@ -180,18 +180,18 @@ function initAvatar(connection) { avatar_access.addEventListener('change', function (evt) { const iq = configurePEPField('urn:xmpp:avatar:metadata', 'pubsub#access_model', evt.target.value); connection.sendIQ(iq, onAvatarConfigured, onAvatarConfigureError.bind(null, 'PubSub configuration failed.')); - access_model_spinner_img.hidden = false; + displaySpinner(access_model_spinner_img); }); function onAvatarConfigured(result_iq) { console.log('Successfully set avatar access model.') - access_model_spinner_img.hidden = true; + spinnerOk(access_model_spinner_img); } function onAvatarConfigureError(string) { console.log('Failed to configure avatar node: ' + string); - access_model_spinner_img.hidden = true; + spinnerError(access_model_spinner_img); } }