Skip to content

Commit

Permalink
[JENKINS-74199] Extract inline script block and event handler in `Pol…
Browse files Browse the repository at this point in the history
…lNowAction/action.jelly` (#47)

* Extract inline onClick handler and JS script

* Extract inline onClick handler and JS script

* Extract inline onClick handler and JS script

* Extract inline onClick handler and JS script
  • Loading branch information
shlomomdahan authored Dec 27, 2024
1 parent 8eb4e88 commit 70b2c2b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,8 @@ THE SOFTWARE.
<j:set var="icon" value="${action.iconClassName != null ? action.iconClassName + ' icon-md' : action.iconFileName}"/>
<j:if test="${icon!=null}">
<j:set var="id" value="${h.generateId()}"/>
<st:adjunct includes="org.jenkinsci.plugins.pollscm.PollNowAction.polling"/>
<l:task icon="${icon}" title="${action.displayName}"
href="${h.getActionUrl(it.url,action)}/polling" onclick="${'return poll_' + id + '(this)'}" post="true"/>
<script>
function poll_${id}(a) {
fetch(a.href, {
method: "post",
headers: crumb.wrap({}),
});
hoverNotification('${%Poll scheduled}',a.parentNode);
return false;
}
</script>
href="${h.getActionUrl(it.url,action)}/polling" data-callback="pollAction" post="true"/>
</j:if>
</j:jelly>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
window.pollAction = function(element, event) {
event.preventDefault();

fetch(element.href, {
method: "post",
headers: crumb.wrap({})
});

hoverNotification('Poll scheduled', element.parentNode);
return false;
};

0 comments on commit 70b2c2b

Please sign in to comment.