diff --git a/app/index.html b/app/index.html
index 760291a..5c0c221 100644
--- a/app/index.html
+++ b/app/index.html
@@ -223,11 +223,13 @@
View Avatar
-
+
Change Avatar
-
+
Reset Avatar
diff --git a/app/index.js b/app/index.js
index a65bc03..1b149ef 100644
--- a/app/index.js
+++ b/app/index.js
@@ -394,8 +394,7 @@ class GlobalBindings {
// return this.thisUser() === ui // TODO check for perms
}
ui.canChangeAvatar = () => {
- return false // TODO implement changing of avatar
- // return this.thisUser() === ui // TODO check for perms
+ return this.thisUser() === ui // TODO check for perms
}
ui.toggleMute = () => {
if (ui.selfMute()) {
@@ -414,6 +413,21 @@ class GlobalBindings {
ui.viewAvatar = () => {
this.avatarView(ui.texture())
}
+ ui.changeAvatar = () => {
+ let input = document.createElement('input')
+ input.type = 'file'
+ input.addEventListener('change', () => {
+ let reader = new window.FileReader()
+ reader.onload = () => {
+ this.client.setSelfTexture(reader.result)
+ }
+ reader.readAsArrayBuffer(input.files[0])
+ })
+ input.click()
+ }
+ ui.removeAvatar = () => {
+ user.clearTexture()
+ }
Object.entries(simpleProperties).forEach(key => {
ui[key[1]] = ko.observable(user[key[0]])
})