Skip to content

Commit

Permalink
Merge pull request #224 from yaroslavafenkin/csp-fixes
Browse files Browse the repository at this point in the history
[JENKINS-74149][JENKINS-74148] Extract inline JavaScript
  • Loading branch information
alexh-sauce authored Jan 14, 2025
2 parents e53bee1 + 3f53618 commit 757f769
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<font color="${job.getStatusColor()}">${job.getStatus()}</font>
<j:if test="${job.hasFailureMessage()}">
<div class="divider"/>
<button onclick="dropdown(this)" class="dropdown-button">Info</button>
<button class="dropdown-button">Info</button>
<div class="dropdown-content">
${job.getFailureMessage()}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<font color="${job.getStatusColor()}">${job.getStatus()}</font>
<j:if test="${job.hasFailureMessage()}">
<div class="divider"/>
<button onclick="dropdown(this)" class="dropdown-button">Info</button>
<button class="dropdown-button">Info</button>
<div class="dropdown-content">
${job.getFailureMessage()}
</div>
Expand Down
27 changes: 27 additions & 0 deletions src/main/webapp/css/analytics.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,30 @@
.sauce-labs-statistics > p {
margin: 0;
}

.dropdown {
position: relative;
display: inline-block;
}

.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 1;
overflow-y: scroll;
white-space: pre;
}

.show {
display: block;
}

.divider {
width: 5px;
height: auto;
display: inline-block;
}
12 changes: 9 additions & 3 deletions src/main/webapp/js/dropdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function dropdown(target) {
target.parentNode.getElementsByClassName("dropdown-content")[0].classList.toggle("show");
function dropdown(event) {
event.target.parentNode.getElementsByClassName("dropdown-content")[0].classList.toggle("show");
}

// close the dropdown if the user clicks outside the button or dropdown content
Expand All @@ -14,4 +14,10 @@ window.onclick = function(event) {
}
}
}
}
}

document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".dropdown-button").forEach((button) => {
button.addEventListener("click", dropdown);
});
});

0 comments on commit 757f769

Please sign in to comment.