Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsrec authored Aug 7, 2024
1 parent 2af9502 commit d8aeb4d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"localBasePath": "resources",
"messages": [
"scratch-confirmaccount-click-copy-alert",
"createacct-normalization"
"scratch-confirmaccount-username-disallowed",
"scratch-confirmaccount-username-warning"
],
"dependencies": [
"mediawiki.util",
Expand Down
2 changes: 2 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
"scratch-confirmaccount-welcome": "Welcome to the wiki!",
"scratch-confirmaccount-welcome-summary": "Welcome!",

"scratch-confirmaccount-username-disallowed": "Due to technical restrictions, usernames that start with an underscore, end with an underscore, or have two consecutive underscores in the middle cannot be used. Please use a different account to request. If you do not have any other accounts, please contact an administrator for help.",
"scratch-confirmaccount-username-warning": "Your username will show up as $1. You may change the capitalization of any of the letters, except for the first letter, which must be capitalized and cannot be lowercase.",
"scratch-confirmaccount-invalid-username": "The username is invalid. Make sure to type your Scratch username. Due to technical reasons, some usernames which start or end with underscore are not allowed. Please contact an administrator if this is the case for you",
"scratch-confirmaccount-user-exists": "The user is already registered.",
"scratch-confirmaccount-request-exists": "The request is already received. Please wait for the administrators to handle it.",
Expand Down
15 changes: 11 additions & 4 deletions resources/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,21 @@ $(function () {
const elem = document.getElementsByName("scratchusername")[0];
if (!elem) return;

elem.onblur = function() {
elem.onkeyup = function() {
var currentname = elem.value || "";
var usernameblock = new OO.ui.infuse(elem.closest('.oo-ui-layout'));
// Start with username input field, and go to the entire username container that OOUI will infuse onto
var noticebox = [];
if(currentname.length > 0 && currentname[0].match("[a-z]")){// Compare first letter to a regex, to check if it starts with a lowercase letter
noticebox[0] = new mw.message("createacct-normalization", "", currentname[0].toUpperCase() + currentname.slice(1)).text();
// If it'd change, add a notice with the first letter captialized
if(currentname.length > 0){
if(currentname.match("^_+|_+$|__+")){
noticebox[0] = new mw.message("scratch-confirmaccount-username-disallowed").text();
}
else{
if(currentname[0].match("[A-Za-z]")){// Compare first letter to a regex, to check if it starts with a lowercase letter
noticebox[0] = new mw.message("scratch-confirmaccount-username-warning", currentname[0].toUpperCase() + currentname.slice(1)).text();
// If it'd change, add a notice with the first letter captialized
}
}
}
usernameblock.setNotices(noticebox);// Save out any notices (importantly, this will *remove* a notice if it no longer applies)
}
Expand Down

0 comments on commit d8aeb4d

Please sign in to comment.