fix: Improve JavaScript Functionality for Login Screen#56
Open
sergioceron wants to merge 2 commits intomasterfrom
Open
fix: Improve JavaScript Functionality for Login Screen#56sergioceron wants to merge 2 commits intomasterfrom
sergioceron wants to merge 2 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR attempts to add client-side validation/behavior for the login screen by introducing new login-specific helpers in the globally loaded cpanel.js and wiring the login page markup to them.
Changes:
- Added
validateLoginForm()/addLoginFormListeners()tojscripts/cpanel.js. - Modified
index.phpto includecpanel.jsand introduce a#loginFormform hook.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| jscripts/cpanel.js | Adds login form validation/listeners, but introduces syntax/runtime issues in a globally loaded script. |
| index.php | Attempts to hook the login page to the new JS, but introduces invalid HTML (nested forms / mismatched tags) and redundant script loading. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <table style="margin: 15px 0pt 0pt;" border="0" cellpadding="0" | ||
| cellspacing="0"> | ||
| <tbody> | ||
| <script src='jscripts/cpanel.js'></script> |
Comment on lines
28
to
38
| <form action="action_login.php" method="post" name="settings"> | ||
| <table style="margin: 15px 0pt 0pt;" border="0" cellpadding="0" | ||
| cellspacing="0"> | ||
| <tbody> | ||
| <script src='jscripts/cpanel.js'></script> | ||
| <tr> | ||
| <th align="right" nowrap="nowrap"><?=$_i18n[ "user" ]?> : </th> | ||
| <td><input name="userName" size="35" type="text" class="rounded"> <?php if( strpos( $fields, 'userName' ) ){?><br> | ||
| <span class="errormsg" id="errormsg_0"> <?=$_i18n[ "error.required" ]?> | ||
| </span><?php } ?></td> | ||
| </tr> | ||
| <form id='loginForm' action='action_login.php' method='post' name='settings'> | ||
| <tr> |
Comment on lines
29
to
32
| <table style="margin: 15px 0pt 0pt;" border="0" cellpadding="0" | ||
| cellspacing="0"> | ||
| <tbody> | ||
| <script src='jscripts/cpanel.js'></script> | ||
| <tr> |
Comment on lines
+131
to
147
| } | ||
| const usernameField = loginForm.elements['username']; | ||
| usernameField.addEventListener('input', function() { | ||
| if (this.value.trim()) { | ||
| this.style.borderColor = ''; | ||
| } | ||
| }); | ||
| const passwordField = loginForm.elements['password']; | ||
| passwordField.addEventListener('input', function() { | ||
| if (this.value.trim()) { | ||
| this.style.borderColor = ''; | ||
| } | ||
| }); | ||
| } | ||
| } | ||
| }; | ||
|
|
Comment on lines
145
to
146
| } | ||
| }; |
Comment on lines
+123
to
+139
| function addLoginFormListeners() { | ||
| const loginForm = document.querySelector('#loginForm'); | ||
| if (loginForm) { | ||
| loginForm.addEventListener('submit', function(event) { | ||
| if (!validateLoginForm(this)) { | ||
| event.preventDefault(); | ||
| } | ||
| }); | ||
| } | ||
| const usernameField = loginForm.elements['username']; | ||
| usernameField.addEventListener('input', function() { | ||
| if (this.value.trim()) { | ||
| this.style.borderColor = ''; | ||
| } | ||
| }); | ||
| const passwordField = loginForm.elements['password']; | ||
| passwordField.addEventListener('input', function() { |
Comment on lines
+110
to
+111
| const username = form.elements['username'].value.trim(); | ||
| const password = form.elements['password'].value.trim(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automated fix by CoderOps.
Swarm: sw5
Task: Improve JavaScript Functionality for Login Screen