Skip to content

Commit

Permalink
add username warning
Browse files Browse the repository at this point in the history
Warning for people who select a username starting with a lowercase letter
  • Loading branch information
mrsrec authored Dec 6, 2023
1 parent 77a7cb5 commit d93f0dc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
3 changes: 2 additions & 1 deletion extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
],
"localBasePath": "resources",
"messages": [
"scratch-confirmaccount-click-copy-alert"
"scratch-confirmaccount-click-copy-alert",
"createacct-normalization"
],
"dependencies": [
"mediawiki.util",
Expand Down
19 changes: 18 additions & 1 deletion resources/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ $(function () {
if (!elem) return;
elem.onclick = function() {
copyToClipboard(document.getElementById("mw-scratch-confirmaccount-verifcode"));
mw.notify( mw.message( 'scratch-confirmaccount-click-copy-alert', { autoHide: true }, {autoHideSeconds: 5}) ); // Use an i18n message to send a notification
}
});

Expand All @@ -48,6 +49,22 @@ function copyToClipboard(temptext) {
tempItem.focus();
tempItem.select();
document.execCommand('copy');
mw.notify( mw.message( 'scratch-confirmaccount-click-copy-alert', { autoHide: true }, {autoHideSeconds: 5}) ); // Use an i18n message to send a notification
tempItem.parentElement.removeChild(tempItem);
}


$(function () {
const elem = document.getElementsByName("scratchusername")[0];
if (!elem) return;

elem.onblur = function() {
var currentname = elem.value || "";
var usernameblock = new OO.ui.infuse(elem.parentElement.parentElement.parentElement.parentElement);// Pain
var noticebox = [];
if(currentname.length > 0 && currentname[0].match("[a-z]")){
noticebox[0] = new mw.message("createacct-normalization", "", currentname[0].toUpperCase() + currentname.slice(1)).text();
}
console.log(noticebox);
usernameblock.setNotices(noticebox);
}
});
6 changes: 4 additions & 2 deletions src/SpecialRequestAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,14 @@ function usernameAndVerificationArea() {
new OOUI\TextInputWidget( [
'name' => 'scratchusername',
'required' => true,
'value' => $request->getText('scratchusername')
'value' => $request->getText('scratchusername'),
] ),
[
'label' => wfMessage('scratch-confirmaccount-scratchusername')->text(),
'align' => 'top',
]
'infusable' => true
],

),
new OOUI\FieldLayout(
new OOUI\TextInputWidget( [
Expand Down

0 comments on commit d93f0dc

Please sign in to comment.