Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
98 changes: 89 additions & 9 deletions WebContent/WEB-INF/jsp/include/userComment.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,94 @@

var commentTypeId;
var commentReferenceId;

function ensureCommentDialog() {
var dlg = dojo.widget.byId && dojo.widget.byId("CommentDialog");
if (!dlg) {
try { dojo.widget.parse(); dlg = dojo.widget.byId && dojo.widget.byId("CommentDialog"); } catch(e) {}
}
return dlg;
}

function unhideCommentSource() {
var n = document.getElementById("CommentDialog");
if (!n) return n;
n.removeAttribute("hidden");
n.setAttribute("aria-hidden", "false");
n.style.visibility = "visible";
n.style.display = "";
n.style.float = "none";
return n;
}
Comment on lines +42 to +51
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use cssFloat instead of float for CSS property access.

float is a reserved word in JavaScript. While browsers generally tolerate style.float, the standard DOM property name is cssFloat.

🔧 Suggested fix
  function unhideCommentSource() {
    var n = document.getElementById("CommentDialog");
    if (!n) return n;
    n.removeAttribute("hidden");
    n.setAttribute("aria-hidden", "false");
    n.style.visibility = "visible";
    n.style.display = "";
-    n.style.float = "none";
+    n.style.cssFloat = "none";
    return n;
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function unhideCommentSource() {
var n = document.getElementById("CommentDialog");
if (!n) return n;
n.removeAttribute("hidden");
n.setAttribute("aria-hidden", "false");
n.style.visibility = "visible";
n.style.display = "";
n.style.float = "none";
return n;
}
function unhideCommentSource() {
var n = document.getElementById("CommentDialog");
if (!n) return n;
n.removeAttribute("hidden");
n.setAttribute("aria-hidden", "false");
n.style.visibility = "visible";
n.style.display = "";
n.style.cssFloat = "none";
return n;
}
🤖 Prompt for AI Agents
In @WebContent/WEB-INF/jsp/include/userComment.jsp around lines 42 - 51, In
unhideCommentSource(), replace the use of the reserved style property name
"float" with the standard DOM property cssFloat: change the assignment that sets
n.style.float = "none" to assign n.style.cssFloat = "none" (or use
style.setProperty("float", "none") if you prefer), so the function manipulates
the element's float correctly and avoids using the reserved identifier.



function normalizeWrapper(dlg, srcNode) {
var w = (dlg && dlg.domNode) ? dlg.domNode : srcNode;
if (!w) return;

w.style.display = "block";
w.style.visibility = "visible";
w.style.opacity = "1";
w.style.position = "fixed";
w.style.top = "50%";
w.style.left = "50%";
w.style.transform = "translate(-50%, -50%)";
w.style.margin = "0";
w.style.zIndex = "20010";
w.style.overflow = "visible";
}

function normalizeUnderlay() {
var u = document.getElementById("dialogUnderlay");
if (!u) return;
u.style.position = "fixed";
u.style.top = "0"; u.style.left = "0"; u.style.right = "0"; u.style.bottom = "0";
u.style.width = "100%";
u.style.height = "100%";
u.style.zIndex = "20000";
u.style.display = "block";
}

function resetUnderlay() {
var u = document.getElementById("dialogUnderlay");
if (!u) return;
u.style.display = "none";
u.style.zIndex = "";
u.style.position = "";
u.style.top = "";
u.style.left = "";
u.style.right = "";
u.style.bottom = "";
u.style.width = "";
u.style.height = "";
}

function openCommentDialog(typeId, referenceId) {
commentTypeId = typeId;
commentReferenceId = referenceId;
$set("commentText", "");
dojo.widget.byId("CommentDialog").show();
$("commentText").focus();
commentTypeId = typeId;
commentReferenceId = referenceId;

var ta = document.getElementById("commentText");
if (ta) ta.value = "";

var src = unhideCommentSource();
var dlg = ensureCommentDialog();
if (!dlg) return;

normalizeWrapper(dlg, src);
normalizeUnderlay();
if (dlg.show) dlg.show();
setTimeout(function(){
normalizeWrapper(dlg, src);
var ct = document.getElementById("commentText");
if (ct && ct.focus) try { ct.focus(); } catch(e){}
}, 0);
}

function saveComment() {
var comment = $get("commentText");
var comment = (document.getElementById("commentText") || {}).value || "";
MiscDwr.addUserComment(commentTypeId, commentReferenceId, comment, saveCommentCB);
}

function saveCommentCB(comment) {
if (!comment)
alert("<spring:message code="notes.enterComment"/>");
Expand All @@ -64,7 +139,9 @@
}

function closeCommentDialog() {
dojo.widget.byId("CommentDialog").hide();
var dlg = dojo.widget.byId && dojo.widget.byId("CommentDialog");
if (dlg && dlg.hide) dlg.hide();
resetUnderlay();
}
</script>
<style type="text/css">
Expand All @@ -82,7 +159,10 @@
}
</style>

<div dojoType="dialog" id="CommentDialog" bgColor="white" bgOpacity="0.5" toggle="fade" toggleDuration="250">
<div dojoType="dialog" id="CommentDialog" bgColor="white" bgOpacity="0.5" toggle="fade" toggleDuration="250"
style="display:none; visibility:hidden;"
aria-hidden="true"
hidden>
<span class="smallTitle"><spring:message code="notes.addNote"/></span>
<table>
<tr>
Expand Down
12 changes: 12 additions & 0 deletions WebContent/WEB-INF/jsp/views.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
along with this program. If not, see http://www.gnu.org/licenses/.
--%>
<%@ include file="/WEB-INF/jsp/include/tech.jsp"%>
<%@page import="com.serotonin.mango.vo.UserComment"%>
<tag:page dwr="ViewDwr"
js="view,dygraphs/dygraph-dev,dygraph-extra,dygraphsSplineUtils,dygraphsCharts"
css="jQuery/plugins/jquery-ui/css/south-street/jquery-ui-1.10.3.custom.min,jQuery/plugins/datetimepicker/jquery-ui-timepicker-addon,jQuery/plugins/jpicker/css/jPicker-1.1.6.min"
jqplugins="jquery-ui/js/jquery-ui-1.10.3.custom.min,jpicker/jpicker-1.1.6.min,datetimepicker/jquery-ui-timepicker-addon" >
<%@ include file="/WEB-INF/jsp/include/userComment.jsp" %>
<script type="text/javascript" src="resources/wz_jsgraphics.js"></script>
<script type="text/javascript" src="resources/shortcut.js"></script>
<script type="text/javascript" src="resources/customClientScripts/customView.js"></script>
Expand All @@ -41,6 +43,16 @@
.rowTableAlt {
background-color: #DCDCDC;
}
.dojoDialog textarea,
.dojoDialog input,
.dojoDialog select,
.commonDialog textarea,
.commonDialog input,
.commonDialog select {
border: 1px solid var(--slts-color-primary) !important;
background: #fff !important;
box-shadow: none !important;
}
</style>
<script type="text/javascript" src="resources/node_modules/sweetalert2/dist/sweetalert2.min.js"></script>

Expand Down
25 changes: 22 additions & 3 deletions WebContent/WEB-INF/snippet/alarmList.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,28 @@
<c:if test="${!hideIdColumn}"><td align="center">${event.id}</td></c:if>
<c:if test="${!hideAlarmLevelColumn}"><td align="center"><tag:eventIcon event="${event}"/></td></c:if>
<c:if test="${!hideTimestampColumn}"><td align="center">${sst:time(event.activeTimestamp)}</td></c:if>
<td onmouseover="this.style.whiteSpace='normal'" onmouseout="this.style.whiteSpace='nowrap'" style=" white-space: nowrap; max-width:100vh;">
<p style="margin:auto; overflow: hidden; text-overflow: ellipsis; font-weight: bold;"><sst:i18n message="${event.message}"/></p>
</td>
<td>
<table cellspacing="0" cellpadding="0" width="100%">
<colgroup>
<col />
<col />
<col style="width:1%" />
</colgroup>

<tr>
<td colspan="2"><b><sst:i18n message="${event.message}"/></b></td>
<td align="right">
<tag:img png="comment_add" title="notes.addNote"
onclick="openCommentDialog(${applicationScope['constants.UserComment.TYPE_EVENT']}, ${event.id})"/>
</td>
</tr>

<tbody id="eventComments${event.id}">
<tag:comments comments="${event.eventComments}"/>
</tbody>
</table>
</td>

Comment on lines +36 to +57
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify the constant is defined somewhere predictable
rg -n --hidden -S "constants\.UserComment\.TYPE_EVENT|TYPE_EVENT" | head -30

Repository: SCADA-LTS/Scada-LTS

Length of output: 3626


🏁 Script executed:

#!/bin/bash
# Inspect the tag implementation/usage to see what it renders (TR vs TBODY)
rg -n --hidden -S "<tag:comments\b" -A 2 -B 2 | head -50

Repository: SCADA-LTS/Scada-LTS

Length of output: 1265


🏁 Script executed:

#!/bin/bash
# Check for JSP constant patterns in other files
rg -n --hidden -S "jsp:useBean.*constants" | head -20

Repository: SCADA-LTS/Scada-LTS

Length of output: 45


🏁 Script executed:

#!/bin/bash
# Check eventList.jsp to see if it uses a better pattern for the constant
cat WebContent/WEB-INF/snippet/eventList.jsp | head -100

Repository: SCADA-LTS/Scada-LTS

Length of output: 4710


🏁 Script executed:

#!/bin/bash
# Find the tag:comments tag file implementation
fd -t f "comments.tag" WebContent/

Repository: SCADA-LTS/Scada-LTS

Length of output: 99


🏁 Script executed:

#!/bin/bash
# Inspect the comments.tag implementation
cat WebContent/WEB-INF/tags/comments.tag

Repository: SCADA-LTS/Scada-LTS

Length of output: 1612


Make the "add comment" control keyboard accessible.

The tag:img element with onclick is mouse-only. Replace it with a proper <button type="button"> to ensure keyboard navigation and screen reader support. You can wrap the image inside the button for visual consistency:

<button type="button"
        onclick="openCommentDialog(${applicationScope['constants.UserComment.TYPE_EVENT']}, ${event.id})"
        title="<spring:message code='notes.addNote'/>">
  <tag:img png="comment_add" alt=""/>
</button>

The constant ${applicationScope['constants.UserComment.TYPE_EVENT']} is reliably set at startup (MangoContextListener.java:442-443) and does not risk being empty. The current table structure—with the header <tr> before the <tbody> and comment rows inside—is semantically correct per HTML specification.

<c:if test="${!hideInactivityColumn}">
<td>
<c:choose>
Expand Down
Loading