Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning when username starts with a lowercase letter #194

Merged
merged 4 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
mrsrec marked this conversation as resolved.
Show resolved Hide resolved
],
"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
mrsrec marked this conversation as resolved.
Show resolved Hide resolved
var noticebox = [];
if(currentname.length > 0 && currentname[0].match("[a-z]")){
mrsrec marked this conversation as resolved.
Show resolved Hide resolved
noticebox[0] = new mw.message("createacct-normalization", "", currentname[0].toUpperCase() + currentname.slice(1)).text();
Kenny2github marked this conversation as resolved.
Show resolved Hide resolved
}
console.log(noticebox);
mrsrec marked this conversation as resolved.
Show resolved Hide resolved
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
mrsrec marked this conversation as resolved.
Show resolved Hide resolved
],

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