Skip to content

Commit

Permalink
Merge pull request #95 from iMattPro/emoji-count
Browse files Browse the repository at this point in the history
Limit shortname length, but support emoji
  • Loading branch information
iMattPro authored Dec 5, 2024
2 parents c9f920f + 60cca5b commit d80f971
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 16 additions & 0 deletions adm/style/event/acp_overall_footer_after.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% if S_PWA_OPTIONS %}
<script>
const input = document.getElementById('pwa_short_name');
const maxLength = 12;

input.addEventListener('input', () => {
// Use Array.from to count characters correctly
const inputChars = Array.from(input.value);

// If input exceeds maxLength, truncate it
if (inputChars.length > maxLength) {
input.value = inputChars.slice(0, maxLength).join('');
}
});
</script>
{% endif %}
4 changes: 3 additions & 1 deletion event/listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ public function acp_pwa_options($event)
];

$event->update_subarray('display_vars', 'vars', phpbb_insert_config_array($event['display_vars']['vars'], $my_config_vars, ['before' => 'legend4']));

$this->template->assign_var('S_PWA_OPTIONS', true);
}
}

Expand Down Expand Up @@ -213,7 +215,7 @@ public function pwa_short_sitename($value, $key)
{
$placeholder = $this->trim_shortname($this->config['sitename']);

return '<input id="' . $key . '" type="text" size="40" maxlength="12" name="config[' . $key . ']" value="' . $value . '" placeholder="' . $placeholder . '">';
return '<input id="' . $key . '" type="text" size="40" maxlength="24" name="config[' . $key . ']" value="' . $value . '" placeholder="' . $placeholder . '">';
}

/**
Expand Down

0 comments on commit d80f971

Please sign in to comment.