Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-74247] extract inline JS script in TapStreamResult/body.jelly #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,7 @@ THE SOFTWARE.

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">

<script type="text/javascript">
<!-- TODO make sure load doesn't happen every time -->
function showStackTrace(id,query) {
var element = document.getElementById(id)
element.style.display = "";
document.getElementById(id + "-showlink").style.display = "none";
document.getElementById(id + "-hidelink").style.display = "";

var rqo = new XMLHttpRequest();
rqo.open('GET', query, true);
rqo.onreadystatechange = function() { element.innerHTML = rqo.responseText; }
rqo.send(null);
}

function hideStackTrace(id) {
document.getElementById(id).style.display = "none";
document.getElementById(id + "-showlink").style.display = "";
document.getElementById(id + "-hidelink").style.display = "none";
}
</script>

<st:adjunct includes="org.tap4j.plugin.model.TapStreamResult.tap-results"/>
<j:if test="${it.failCount!=0}">
<h2>${%All Failed Tests}</h2>
<table class="pane sortable">
Expand All @@ -58,10 +37,8 @@ THE SOFTWARE.
<j:forEach var="f" items="${it.failedTests2}" varStatus="i">
<tr>
<td class="pane">
<!--a id="test-${f.fullName}-showlink"
href="javascript:showStackTrace('test-${h.jsStringEscape(f.fullName)}','${f.getRelativePathFrom(it)}/')">&gt;&gt;&gt;</a-->
<a id="test-${f.fullName}-hidelink" style="display:none"
href="javascript:hideStackTrace('test-${h.jsStringEscape(f.fullName)}')">&lt;&lt;&lt;</a>
<!-- <a id="test-${f.fullName}-showlink" data-query="${f.getRelativePathFrom(it)}/">&gt;&gt;&gt;</a>-->
<a id="test-${f.fullName}-hidelink" style="display:none">&lt;&lt;&lt;</a>
<st:nbsp/>
<a href="${f.getRelativePathFrom(it)}" class="model-link"><st:out value="${f.fullName}"/></a>
<st:nbsp/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Behaviour.specify('a[id$="-showlink"]', 'tap-result', 0, function(e) {
const id = e.id.replace('-showlink', '');
e.onclick = function() {
const query = e.getAttribute('data-query');
const element = document.getElementById(id);

element.style.display = '';

const showLink = document.getElementById(`${id}-showlink`);
const hideLink = document.getElementById(`${id}-hidelink`);

if (showLink) showLink.style.display = 'none';
if (hideLink) hideLink.style.display = '';

var rqo = new XMLHttpRequest();
rqo.open('GET', query, true);
rqo.onreadystatechange = function() { element.innerHTML = rqo.responseText; }
rqo.send(null);
};
});

Behaviour.specify('a[id$="-hidelink"]', 'tap-result', 0, function(e) {
const id = e.id.replace('-hidelink', '');
e.onclick = function() {
const element = document.getElementById(id);
const showLink = document.getElementById(`${id}-showlink`);
const hideLink = document.getElementById(`${id}-hidelink`);

element.style.display = 'none';
showLink.style.display = '';
hideLink.style.display = 'none';
};
});
Loading