Skip to content

Commit

Permalink
[JENKINS-60866] Extract inline JS from progressive rendering (#6860)
Browse files Browse the repository at this point in the history
* [JENKINS-60866] Extract inline JS from progressive rendering

* Remove unused variable

Co-authored-by: Tim Jacomb <[email protected]>

Co-authored-by: Daniel Beck <[email protected]>
Co-authored-by: Tim Jacomb <[email protected]>
  • Loading branch information
3 people authored Jul 21, 2022
1 parent 7fd9f22 commit f0f6b1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/src/main/resources/lib/layout/progressiveRendering.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ THE SOFTWARE.
Instance of jenkins.util.ProgressiveRendering.
</st:attribute>
<st:attribute name="callback" use="required">
JavaScript expression that evaluates to the function taking one JSON-valued parameter which renders results as they come.
Name of a global scope JavaScript function that takes one JSON-valued parameter which renders results as they come.
</st:attribute>
<st:attribute name="tooltip">
Optional tooltip for progress bar.
Expand All @@ -38,5 +38,5 @@ THE SOFTWARE.
<j:set var="id" value="${h.generateId()}"/>
<t:progressBar id="${id}" pos="0" tooltip="${tooltip ?: '%progressMessage'}"/>
<st:bind var="proxy" value="${handler}" />
<script>progressivelyRender(proxy, ${callback}, '${id}');</script>
<div class="progressive-rendering-information-holder" data-id="${id}" data-callback="${callback}" />
</j:jelly>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* The MIT License
*
* Copyright 2012 Jesse Glick.
Expand Down Expand Up @@ -51,3 +51,9 @@ function progressivelyRender(handler, callback, statusId) {
checkNewsLater(0);
});
}

document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('.progressive-rendering-information-holder').forEach(function (holder) {
progressivelyRender(window.proxy, window[holder.getAttribute('data-callback')], holder.getAttribute('data-id'));
});
});

0 comments on commit f0f6b1e

Please sign in to comment.