Skip to content

Commit

Permalink
[JENKINS-73944] Extract inline event handler from POSTHyperlinkNote (
Browse files Browse the repository at this point in the history
  • Loading branch information
yaroslavafenkin authored Oct 16, 2024
1 parent f8d41ac commit dc0c358
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public POSTHyperlinkNote(String url, int length) {

@Override protected String extraAttributes() {
// TODO perhaps add hoverNotification
return " onclick=\"fetch(decodeURIComponent(atob('" + encodeForJavascript(url) + "')), { method: 'post', headers: crumb.wrap({})}); return false\"";
return " data-encoded-url='" + encodeForJavascript(url) + "' class='post-hyperlink-note-button'";
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Behaviour.specify("A.post-hyperlink-note-button", "POSTHyperLinkNote", 0, function (element) {
element.addEventListener("click", (event) => {
event.preventDefault();
const url = decodeURIComponent(atob(element.dataset.encodedUrl));
fetch(url, {
method: "post",
headers: crumb.wrap({}),
});
});
});

0 comments on commit dc0c358

Please sign in to comment.