From d497a2e82253922c79f9778be857f7512ae475dc Mon Sep 17 00:00:00 2001 From: Mia <49593536+mia-pi-git@users.noreply.github.com> Date: Wed, 31 Jul 2024 18:12:56 -0500 Subject: [PATCH] Add a button to change your status to the Options menu --- play.pokemonshowdown.com/js/client-topbar.js | 32 +++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/play.pokemonshowdown.com/js/client-topbar.js b/play.pokemonshowdown.com/js/client-topbar.js index d9bb2aecdc..ed2d8dab1b 100644 --- a/play.pokemonshowdown.com/js/client-topbar.js +++ b/play.pokemonshowdown.com/js/client-topbar.js @@ -469,7 +469,8 @@ 'change select[name=theme]': 'setTheme', 'change input[name=logchat]': 'setLogChat', 'change input[name=selfhighlight]': 'setSelfHighlight', - 'click img': 'avatars' + 'click img': 'avatars', + 'keydown input[name=statustext]': 'editstatus' }, update: function () { var name = app.user.get('name'); @@ -479,6 +480,12 @@ var buf = ''; buf += '

' + (avatar ? '' : '') + '' + BattleLog.escapeHTML(name) + '

'; buf += '

'; + if (!this.editingStatus) { + buf += '

'; + } else { + buf += '

'; + buf += '

'; + } if (app.user.get('named')) { var registered = app.user.get('registered'); if (registered && (registered.userid === app.user.get('userid'))) { @@ -662,6 +669,29 @@ avatars: function () { app.addPopup(AvatarsPopup); }, + editstatus: function (ev) { + // from an input, key isn't enter + // there's no event if it's a click fsr + if (ev && ev.keyCode !== 13) return; + if (!this.editingStatus) { + this.editingStatus = true; + this.update(); + } else { + var $input = $('input[name=statustext]'); + var statusText = $input.val(); + if (!toID(statusText).length) { + return; + } + + app.send('/status ' + statusText); + var $editButton = $('button[name=editstatus]'); + $editButton.text('Status updated!'); + $editButton.attr('disabled', true); + $input.remove(); + + this.editingStatus = false; + } + }, formatting: function () { app.addPopup(FormattingPopup); },