Skip to content

Commit

Permalink
JavaScript XML (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
slominskir authored Jul 8, 2024
1 parent fce628c commit 425b831
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/main/webapp/resources/js/downtime-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ jlab.doParetoChart = function () {

if (href) {
$(this).text("");
$(this).append('<a href="' + href + '" title="' + title + '">' + label + '</a>');
$(this).append('<a href="' + String(href).encodeXml() + '" title="' + String(title).encodeXml() + '">' + String(label).encodeXml() + '</a>');
}
});

Expand Down Expand Up @@ -353,7 +353,7 @@ jlab.doRowChart = function () {

if (href) {
$(this).text("");
$(this).append('<a href="' + href + '" title="' + title + '">' + label + '</a>');
$(this).append('<a href="' + String(href).encodeXml() + '" title="' + String(title).encodeXml() + '">' + String(label).encodeXml() + '</a>');
}
});
};
Expand Down Expand Up @@ -475,7 +475,7 @@ jlab.doPieChart = function () {

if (href) {
$(this).text("");
$(this).append('<a href="' + href + '" title="' + title + '">' + label + '</a> ' + extra);
$(this).append('<a href="' + String(href).encodeXml() + '" title="' + String(title).encodeXml() + '">' + String(label).encodeXml() + '</a> ' + String(extra).encodeXml());
} else {
$(this).text(label + " " + extra);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/resources/js/dtm.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jlab.uploadRARFile = function(incidentId, form) {

promise.done(function(data){
$("#rar-link").empty();
$("#rar-link").append('<a href="' + jlab.contextPath + jlab.rarLink + incidentId + '">RAR Document</a>');
$("#rar-link").append('<a href="' + String(jlab.contextPath + jlab.rarLink + incidentId).encodeXml() + '">RAR Document</a>');
});

promise.fail(function(xhr, textStatus){
Expand Down Expand Up @@ -152,7 +152,7 @@ jlab.filterSystemListByCategory = function (categoryId, systemSelectSelector, ap
$select.append('<option></option>');
}
$(data.optionList).each(function () {
$select.append('<option value="' + this.value + '">' + this.name + '</option>');
$select.append('<option value="' + String(this.value).encodeXml() + '">' + String(this.name).encodeXml() + '</option>');
});
if (!keephidden) {
$select.slideDown();
Expand Down
14 changes: 7 additions & 7 deletions src/main/webapp/resources/js/event-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ jlab.dtm.prepareIncidentFormForEdit = function (skipSystemListLoad) {

if (skipSystemListLoad === true) {
$("#system").empty();
$("#system").append('<option selected="selected" value="' + systemId + '"> </option>');
$("#system").append('<option selected="selected" value="' + String(systemId).encodeXml() + '"> </option>');
} else {
jlab.dtm.filterSystemSelect(systemId);
}
Expand Down Expand Up @@ -595,7 +595,7 @@ jlab.dtm.filterSystemSelect = function (setToSystemId) {
$("#system").empty();
$("#system").append('<option value=""> </option>');
$(json.data).each(function () {
$("#system").append('<option value="' + this.id + '">' + this.name + '</option>');
$("#system").append('<option value="' + String(this.id).encodeXml() + '">' + String(this.name).encodeXml() + '</option>');
});
if (json.data.length === 1) {
$("#system").val(json.data[0].id);
Expand Down Expand Up @@ -881,13 +881,13 @@ $(document).on("click", ".open-edit-expert-review-dialog-button", function () {
var experts = expertReviewerTsv.split("\t");

for(var e of experts) {
$("#edit-expert-reviewers").append("<div>" + e + "</div>");
$("#edit-expert-reviewers").append("<div>" + String(e).encodeXml() + "</div>");
}

$("#rar-link").empty();

if(rarExt !== '') {
$("#rar-link").append('<a href="' + jlab.contextPath + jlab.rarLink + incidentId + '">RAR Document</a>');
$("#rar-link").append('<a href="' + String(jlab.contextPath + jlab.rarLink + incidentId).encodeXml() + '">RAR Document</a>');
}

var $acknowledgedKey = $("#acknowledged-key");
Expand Down Expand Up @@ -1000,7 +1000,7 @@ $(document).on("click", ".explanation-link", function () {
$(".resolution-handle").remove();

var explanation = $(this).attr("data-explanation");
$(this).append('<div class="explanation-handle"><div class="explanation-panel"><button class="close-bubble">X</button><div><h4>Explanation:</h4><div class="explanation-content">' + explanation + '</div></div></div></div>');
$(this).append('<div class="explanation-handle"><div class="explanation-panel"><button class="close-bubble">X</button><div><h4>Explanation:</h4><div class="explanation-content">' + String(explanation).encodeXml() + '</div></div></div></div>');
return false;
});
$(document).on("click", ".review-link", function () {
Expand Down Expand Up @@ -1028,13 +1028,13 @@ $(document).on("click", ".review-link", function () {
var experts = expertReviewerTsv.split("\t");

for(var e of experts) {
$("#review-dialog-sys-reviewer").append("<div>" + e + "</div>");
$("#review-dialog-sys-reviewer").append("<div>" + String(e).encodeXml() + "</div>");
}

$("#review-dialog-rar-link").empty();

if(rarExt !== '') {
$("#review-dialog-rar-link").append('<a href="' + jlab.contextPath + jlab.rarLink + incidentId + '">RAR Document</a>');
$("#review-dialog-rar-link").append('<a href="' + String(jlab.contextPath + jlab.rarLink + incidentId).encodeXml() + '">RAR Document</a>');
}

$("#review-dialog").dialog("open");
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/resources/js/monthly-repair.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jlab.getDataSource = function (bar) {
/*yvalue = parseFloat($("td." + jlab.flotSourceColumnClass, value).text().replace(/,/g, '')),*/
duration = parseFloat($("td:nth-child(3)", value).text().replace(/,/g, '')),
grouping = $("td:first-child", value).text(),
id = $("td:first-child", value).attr("data-id"),
id = parseInt($("td:first-child", value).attr("data-id")),
series = dataMap[grouping] || {};

nameToIdMap[grouping] = id;
Expand Down Expand Up @@ -231,7 +231,7 @@ jlab.getDataSource = function (bar) {
}

if (includeCount) {
rowStr = rowStr + '<td>' + countMap[groupingNames[i]] + '</td>';
rowStr = rowStr + '<td>' + String(countMap[groupingNames[i]]).encodeXml() + '</td>';
}
if (includeRate) {
rowStr = rowStr + '<td>' + tripPerHourMap[groupingNames[i]].toFixed(1) + '</td>';
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/resources/js/run-compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ $(document).on("click", "#add-selected-run-button", function(){
return;
}

$("#run-list").append('<li>' + label + '<input type="hidden" name="label" value="' + label + '"/><input type="hidden" name="start" value="' + start + '"/><input type="hidden" name="end" value="' + end + '"/> <button type="button">X</button></li>');
$("#run-list").append('<li>' + String(label).encodeXml() + '<input type="hidden" name="label" value="' + String(label).encodeXml() + '"/><input type="hidden" name="start" value="' + String(start).encodeXml() + '"/><input type="hidden" name="end" value="' + String(end).encodeXml() + '"/> <button type="button">X</button></li>');
$("#add-run-dialog").dialog("close");
});

Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/resources/js/subsystem-expert.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jlab.dtm.deleteRow = function () {
};

jlab.dtm.addRow = function (expertId, username, first, last) {
var $row = ("<tr data-expert-id=\"" + expertId + "\"><td>" + last + ", " + first + " (" + username + ")</td></tr>");
var $row = ("<tr data-expert-id=\"" + String(expertId).encodeXml() + "\"><td>" + String(last).encodeXml() + ", " + String(first).encodeXml() + " (" + String(username).encodeXml() + ")</td></tr>");
$("#expert-table tbody").append($row);
};

Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/resources/js/weekly-repair.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jlab.prepareIncidentFormForEdit = function(skipSystemListLoad) {

if (skipSystemListLoad === true) {
$("#system").empty();
$("#system").append('<option selected="selected" value="' + systemId + '"> </option>');
$("#system").append('<option selected="selected" value="' + String(systemId).encodeXml() + '"> </option>');
} else {
jlab.dtm.filterSystemSelect(systemId);
}
Expand Down

0 comments on commit 425b831

Please sign in to comment.