Skip to content

fix: Update JavaScript functions#33

Open
sergioceron wants to merge 1 commit into
masterfrom
coderops/fix-d4cb7713-task-781
Open

fix: Update JavaScript functions#33
sergioceron wants to merge 1 commit into
masterfrom
coderops/fix-d4cb7713-task-781

Conversation

@sergioceron

Copy link
Copy Markdown
Member

Automated fix by CoderOps.

Swarm: swarm50
Task: Update JavaScript functions

Copilot AI review requested due to automatic review settings April 10, 2026 04:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread jscripts/cpanel.js
Comment on lines +72 to +76
document.onclick=function(event){
if(document.getElementById('servicelist').style.display=="block"){
hideItem('servicelist');
}
};

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

document.onclick assumes #servicelist always exists; on pages where the menu isn’t rendered (e.g., logged-out views), getElementById('servicelist') is null and .style will throw, breaking all click handling. Add a null-check (or early return) before reading .style.display (and ideally only register the handler when the element exists).

Suggested change
document.onclick=function(event){
if(document.getElementById('servicelist').style.display=="block"){
hideItem('servicelist');
}
};
var servicelist = document.getElementById('servicelist');
if (servicelist) {
document.onclick=function(event){
if(servicelist.style.display=="block"){
hideItem('servicelist');
}
};
}

Copilot uses AI. Check for mistakes.
Comment thread jscripts/cpanel.js
oEvent = window.event; // IE
}
if (msg && test_values_set()) {
oEvent.returnValue = msg;

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

window.onbeforeunload handler sets oEvent.returnValue but never returns the message. Some browsers only show the confirmation prompt when the handler returns a non-empty string; return msg when test_values_set() is true.

Suggested change
oEvent.returnValue = msg;
oEvent.returnValue = msg;
return msg;

Copilot uses AI. Check for mistakes.
Comment thread jscripts/cpanel.js
Comment on lines +582 to +586
for (i=0,n=theForm.elements.length;i<n;i++)
if (theForm.elements[i].name.indexOf('COLLECTION_SELECTION_') !=-1 && theForm.elements[i].checked == true){
name = theForm.elements[i].name;
id = name.substring( name.lastIndexOf( "_" )+1, name.lastIndexOf( "." ) );
ids = name.substring( name.lastIndexOf( "." )+1 );

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

This loop assigns to i, n, name, id, and ids without declarations, creating/overwriting globals (e.g., window.name) and risking cross-function interference. Declare these variables locally (e.g., var/let) inside deleteArticle.

Suggested change
for (i=0,n=theForm.elements.length;i<n;i++)
if (theForm.elements[i].name.indexOf('COLLECTION_SELECTION_') !=-1 && theForm.elements[i].checked == true){
name = theForm.elements[i].name;
id = name.substring( name.lastIndexOf( "_" )+1, name.lastIndexOf( "." ) );
ids = name.substring( name.lastIndexOf( "." )+1 );
for (var i=0, n=theForm.elements.length; i<n; i++)
if (theForm.elements[i].name.indexOf('COLLECTION_SELECTION_') !=-1 && theForm.elements[i].checked == true){
var name = theForm.elements[i].name;
var id = name.substring( name.lastIndexOf( "_" )+1, name.lastIndexOf( "." ) );
var ids = name.substring( name.lastIndexOf( "." )+1 );

Copilot uses AI. Check for mistakes.
Comment thread jscripts/cpanel.js
Comment on lines +597 to +603
for (i=0,n=theForm.elements.length;i<n;i++)
if (theForm.elements[i].name.indexOf('COLLECTION_SELECTION_') !=-1 && theForm.elements[i].checked == true){
name = theForm.elements[i].name;
id = name.substring( name.lastIndexOf( "_" )+1, name.lastIndexOf( "." ) );
ids = name.substring( name.lastIndexOf( "." )+1 );
getResponse( page + "?id=" + ids, id );
}

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

This loop assigns to i, n, name, id, and ids without declarations, creating/overwriting globals and risking cross-function interference. Declare these variables locally inside deleteArticleAdmin.

Copilot uses AI. Check for mistakes.
Comment thread jscripts/cpanel.js
Comment on lines +612 to +616
for (i=0,n=theForm.elements.length;i<n;i++)
if (theForm.elements[i].name.indexOf('COLLECTION_SELECTION_') !=-1 && theForm.elements[i].checked == true){
name = theForm.elements[i].name;
id = name.substring( name.lastIndexOf( "_" )+1, name.lastIndexOf( "." ) );
ids = name.substring( name.lastIndexOf( "." )+1 );

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

This loop assigns to i, n, name, id, and ids without declarations, creating/overwriting globals and risking cross-function interference. Declare these variables locally inside deleteCategory.

Suggested change
for (i=0,n=theForm.elements.length;i<n;i++)
if (theForm.elements[i].name.indexOf('COLLECTION_SELECTION_') !=-1 && theForm.elements[i].checked == true){
name = theForm.elements[i].name;
id = name.substring( name.lastIndexOf( "_" )+1, name.lastIndexOf( "." ) );
ids = name.substring( name.lastIndexOf( "." )+1 );
for (var i=0, n=theForm.elements.length; i<n; i++)
if (theForm.elements[i].name.indexOf('COLLECTION_SELECTION_') !=-1 && theForm.elements[i].checked == true){
var name = theForm.elements[i].name;
var id = name.substring( name.lastIndexOf( "_" )+1, name.lastIndexOf( "." ) );
var ids = name.substring( name.lastIndexOf( "." )+1 );

Copilot uses AI. Check for mistakes.
Comment thread jscripts/cpanel.js
Comment on lines +627 to +631
for (i=0,n=theForm.elements.length;i<n;i++)
if (theForm.elements[i].name.indexOf('COLLECTION_SELECTION_') !=-1 && theForm.elements[i].checked == true){
name = theForm.elements[i].name;
id = name.substring( name.lastIndexOf( "_" )+1, name.lastIndexOf( "." ) );
ids = name.substring( name.lastIndexOf( "." )+1 );

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

This loop assigns to i, n, name, id, and ids without declarations, creating/overwriting globals and risking cross-function interference. Declare these variables locally inside deleteSale.

Suggested change
for (i=0,n=theForm.elements.length;i<n;i++)
if (theForm.elements[i].name.indexOf('COLLECTION_SELECTION_') !=-1 && theForm.elements[i].checked == true){
name = theForm.elements[i].name;
id = name.substring( name.lastIndexOf( "_" )+1, name.lastIndexOf( "." ) );
ids = name.substring( name.lastIndexOf( "." )+1 );
for (var i=0, n=theForm.elements.length; i<n; i++)
if (theForm.elements[i].name.indexOf('COLLECTION_SELECTION_') !=-1 && theForm.elements[i].checked == true){
var name = theForm.elements[i].name;
var id = name.substring( name.lastIndexOf( "_" )+1, name.lastIndexOf( "." ) );
var ids = name.substring( name.lastIndexOf( "." )+1 );

Copilot uses AI. Check for mistakes.
Comment thread jscripts/cpanel.js
Comment on lines +642 to +646
for (i=0,n=theForm.elements.length;i<n;i++)
if (theForm.elements[i].name.indexOf('COLLECTION_SELECTION_') !=-1 && theForm.elements[i].checked == true){
name = theForm.elements[i].name;
id = name.substring( name.lastIndexOf( "_" )+1, name.lastIndexOf( "." ) );
ids = name.substring( name.lastIndexOf( "." )+1 );

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

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

This loop assigns to i, n, name, id, and ids without declarations, creating/overwriting globals and risking cross-function interference. Declare these variables locally inside deleteUser.

Suggested change
for (i=0,n=theForm.elements.length;i<n;i++)
if (theForm.elements[i].name.indexOf('COLLECTION_SELECTION_') !=-1 && theForm.elements[i].checked == true){
name = theForm.elements[i].name;
id = name.substring( name.lastIndexOf( "_" )+1, name.lastIndexOf( "." ) );
ids = name.substring( name.lastIndexOf( "." )+1 );
for (var i=0, n=theForm.elements.length; i<n; i++)
if (theForm.elements[i].name.indexOf('COLLECTION_SELECTION_') !=-1 && theForm.elements[i].checked == true){
var name = theForm.elements[i].name;
var id = name.substring( name.lastIndexOf( "_" )+1, name.lastIndexOf( "." ) );
var ids = name.substring( name.lastIndexOf( "." )+1 );

Copilot uses AI. Check for mistakes.
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