Skip to content

Commit

Permalink
Add a button to change your status to the Options menu
Browse files Browse the repository at this point in the history
  • Loading branch information
mia-pi-git committed Jul 31, 2024
1 parent d3bd677 commit d497a2e
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion play.pokemonshowdown.com/js/client-topbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -479,6 +480,12 @@
var buf = '';
buf += '<p>' + (avatar ? '<img class="trainersprite" src="' + Dex.resolveAvatar(avatar) + '" width="40" height="40" style="vertical-align:middle;cursor:pointer" />' : '') + '<strong>' + BattleLog.escapeHTML(name) + '</strong></p>';
buf += '<p><button class="button" name="avatars">Avatar...</button></p>';
if (!this.editingStatus) {
buf += '<p><button class="button" name="editstatus">Status...</button></p>';
} else {
buf += '<p><input name="statustext" />';
buf += '<button class="button" name="editstatus"><i class="fa fa-pencil"></i></button></p>';
}
if (app.user.get('named')) {
var registered = app.user.get('registered');
if (registered && (registered.userid === app.user.get('userid'))) {
Expand Down Expand Up @@ -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);
},
Expand Down

0 comments on commit d497a2e

Please sign in to comment.