Skip to content

fix: Improve JavaScript Functionality for Login Screen#56

Open
sergioceron wants to merge 2 commits intomasterfrom
coderops/fix-swarm-70-task-d1a
Open

fix: Improve JavaScript Functionality for Login Screen#56
sergioceron wants to merge 2 commits intomasterfrom
coderops/fix-swarm-70-task-d1a

Conversation

@sergioceron
Copy link
Copy Markdown
Member

Automated fix by CoderOps.

Swarm: sw5
Task: Improve JavaScript Functionality for Login Screen

Copilot AI review requested due to automatic review settings April 15, 2026 00:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() to jscripts/cpanel.js.
  • Modified index.php to include cpanel.js and introduce a #loginForm form 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.

Comment thread index.php
<table style="margin: 15px 0pt 0pt;" border="0" cellpadding="0"
cellspacing="0">
<tbody>
<script src='jscripts/cpanel.js'></script>
Comment thread index.php
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" ]?> :&nbsp;&nbsp;&nbsp;&nbsp;</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 thread index.php
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 thread jscripts/cpanel.js
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 thread jscripts/cpanel.js
Comment on lines 145 to 146
}
};
Comment thread jscripts/cpanel.js
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 thread jscripts/cpanel.js
Comment on lines +110 to +111
const username = form.elements['username'].value.trim();
const password = form.elements['password'].value.trim();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants