mirror of https://github.com/CGAL/cgal
Use jQuery TableSorter for sorting tables
This commit is contained in:
parent
de1872f46c
commit
58cf16de67
|
|
@ -179,23 +179,25 @@ function platformContainer(platforms) {
|
||||||
$tplTable.toggle();
|
$tplTable.toggle();
|
||||||
}
|
}
|
||||||
}).appendTo($container);
|
}).appendTo($container);
|
||||||
const $tplTable = $('<table>', { class: 'tpl-table', css: { display: 'none' } }).appendTo($container);
|
const $tplTable = $('<table>', {
|
||||||
|
class: 'tablesorter',
|
||||||
|
css: {
|
||||||
|
display: 'none',
|
||||||
|
maxWidth: '300px'
|
||||||
|
}
|
||||||
|
}).appendTo($container);
|
||||||
const $thead = $('<thead>').appendTo($tplTable);
|
const $thead = $('<thead>').appendTo($tplTable);
|
||||||
const $tbody = $('<tbody>').appendTo($tplTable);
|
const $tbody = $('<tbody>').appendTo($tplTable);
|
||||||
const $headerRow = $('<tr>');
|
const $headerRow = $('<tr>');
|
||||||
$('<th>', { class: 'sortable', 'data-sort': 0, text: 'Library' }).appendTo($headerRow);
|
$('<th>', { text: 'Library' }).appendTo($headerRow);
|
||||||
$('<th>', { class: 'sortable', 'data-sort': 1, text: 'Version' }).appendTo($headerRow);
|
$('<th>', { text: 'Version' }).appendTo($headerRow);
|
||||||
$('<th>', { class: 'sortable', 'data-sort': 2, text: 'Status' }).appendTo($headerRow);
|
|
||||||
$headerRow.appendTo($thead);
|
$headerRow.appendTo($thead);
|
||||||
tplArray.forEach(tpl => {
|
tplArray.forEach(tpl => {
|
||||||
$('<tr>').append(
|
$('<tr>').append(
|
||||||
$('<td>').html(`<a href="#" class="tpl-link" data-tpl="${tpl.name}">${tpl.name}</a>`),
|
$('<td>').html(`<a href="#" class="tpl-link" data-tpl="${tpl.name}">${tpl.name}</a>`),
|
||||||
$('<td>').text(tpl.version || 'N/A'),
|
$('<td>').text(tpl.version || 'N/A'),
|
||||||
$('<td>').text(tpl.status)
|
|
||||||
).appendTo($tbody);
|
).appendTo($tbody);
|
||||||
});
|
});
|
||||||
initializeTableSorting($thead, $tbody);
|
|
||||||
$thead.find('.sortable').first().click();
|
|
||||||
$('.tpl-link').click(function(event) {
|
$('.tpl-link').click(function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const tplName = $(this).data('tpl');
|
const tplName = $(this).data('tpl');
|
||||||
|
|
@ -268,7 +270,6 @@ function showVersionsForTPL(tplName) {
|
||||||
<tr class="modal-table-row">
|
<tr class="modal-table-row">
|
||||||
<td>${platform.name}</td>
|
<td>${platform.name}</td>
|
||||||
<td>${matchingTPL.version || 'N/A'}</td>
|
<td>${matchingTPL.version || 'N/A'}</td>
|
||||||
<td><strong>${matchingTPL.status}</strong></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
@ -276,6 +277,7 @@ function showVersionsForTPL(tplName) {
|
||||||
if (!tplFound) {
|
if (!tplFound) {
|
||||||
$modalBody.append('<tr><td colspan="3">No versions of this TPL found across platforms.</td></tr>');
|
$modalBody.append('<tr><td colspan="3">No versions of this TPL found across platforms.</td></tr>');
|
||||||
}
|
}
|
||||||
|
$modalTable.trigger("update");
|
||||||
$modal.show();
|
$modal.show();
|
||||||
$('.close').click(function() {
|
$('.close').click(function() {
|
||||||
$modal.hide();
|
$modal.hide();
|
||||||
|
|
@ -285,28 +287,6 @@ function showVersionsForTPL(tplName) {
|
||||||
$modal.hide();
|
$modal.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const $thead = $modalTable.find('thead');
|
|
||||||
initializeTableSorting($thead, $modalBody);
|
|
||||||
$thead.find('.sortable').first().click();
|
|
||||||
}
|
|
||||||
|
|
||||||
function initializeTableSorting($thead, $tbody) {
|
|
||||||
let sortOrder = 1;
|
|
||||||
$thead.find('.sortable').click(function() {
|
|
||||||
const columnIndex = $(this).data('sort');
|
|
||||||
const rows = $tbody.find('tr').get();
|
|
||||||
rows.sort((a, b) => {
|
|
||||||
const keyA = $(a).children('td').eq(columnIndex).text().toUpperCase();
|
|
||||||
const keyB = $(b).children('td').eq(columnIndex).text().toUpperCase();
|
|
||||||
if (keyA < keyB) return -1 * sortOrder;
|
|
||||||
if (keyA > keyB) return 1 * sortOrder;
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
$.each(rows, (_index, row) => {
|
|
||||||
$tbody.append(row);
|
|
||||||
});
|
|
||||||
sortOrder *= -1;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
|
|
@ -319,7 +299,9 @@ function main() {
|
||||||
platformContainer(data.platforms);
|
platformContainer(data.platforms);
|
||||||
packageContainer(data.platforms);
|
packageContainer(data.platforms);
|
||||||
$packageContainer.hide();
|
$packageContainer.hide();
|
||||||
|
$(document).ready(function() {
|
||||||
|
$("table.tablesorter").tablesorter();
|
||||||
|
});
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
const platform = urlParams.get('platform');
|
const platform = urlParams.get('platform');
|
||||||
if (platform) {
|
if (platform) {
|
||||||
|
|
|
||||||
|
|
@ -838,6 +838,7 @@ sub create_summary_page {
|
||||||
<title>Summary</title>
|
<title>Summary</title>
|
||||||
<link rel="shortcut icon" href="cgal.ico">
|
<link rel="shortcut icon" href="cgal.ico">
|
||||||
<link rel="stylesheet" type="text/css" href="testresult.css">
|
<link rel="stylesheet" type="text/css" href="testresult.css">
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.3/css/theme.default.min.css">
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
var searchURLs = $json_urls;
|
var searchURLs = $json_urls;
|
||||||
|
|
@ -849,15 +850,14 @@ sub create_summary_page {
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<span class="close">×</span>
|
<span class="close">×</span>
|
||||||
<h2 id="tplModalTitle">Versions of TPL</h2>
|
<h2 id="tplModalTitle">Versions of TPL</h2>
|
||||||
<table class="modaltable">
|
<table class="tablesorter">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="modalHeader sortable" data-sort="0">Platform</th>
|
<th>Platform</th>
|
||||||
<th class="modalHeader sortable" data-sort="1">Version</th>
|
<th>Version</th>
|
||||||
<th class="modalHeader sortable" data-sort="2">Status</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="modalBody"></tbody>
|
<tbody></tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -891,6 +891,7 @@ sub create_summary_page {
|
||||||
<div id="package_container"></div>
|
<div id="package_container"></div>
|
||||||
</div>
|
</div>
|
||||||
<script src="$release_name/Summary_Script.js" type="application/javascript"></script>
|
<script src="$release_name/Summary_Script.js" type="application/javascript"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.32.0/js/jquery.tablesorter.min.js"></script>
|
||||||
EOF
|
EOF
|
||||||
if (-e $summary_script_src) {
|
if (-e $summary_script_src) {
|
||||||
copy($summary_script_src, $summary_script_dest) or die "Copy failed: $!";
|
copy($summary_script_src, $summary_script_dest) or die "Copy failed: $!";
|
||||||
|
|
|
||||||
|
|
@ -170,11 +170,6 @@ TABLE.result TD > a.package_name {
|
||||||
color: #1A0DAB;
|
color: #1A0DAB;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sortable{
|
|
||||||
cursor: pointer;
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TPL Modal */
|
/* TPL Modal */
|
||||||
.modal {
|
.modal {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
@ -222,24 +217,51 @@ TABLE.result TD > a.package_name {
|
||||||
color: #555;
|
color: #555;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modaltable{
|
table.tablesorter {
|
||||||
|
width: 100%;
|
||||||
|
margin: 20px 0;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
cellspacing: 0;
|
background-color: #f0f0f0;
|
||||||
|
color: #333;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modalHeader{
|
table.tablesorter thead th {
|
||||||
text-align: center;
|
background-color: #d9d9d9;
|
||||||
width: auto;
|
color: #333;
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
text-align: left;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modalBody {
|
table.tablesorter thead th.tablesorter-headerAsc {
|
||||||
text-align: center;
|
background-repeat: no-repeat;
|
||||||
|
background-position: right center;
|
||||||
|
padding-right: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-table-row {
|
table.tablesorter thead th.tablesorter-headerDesc {
|
||||||
border-bottom: 2px ridge #000;
|
background-repeat: no-repeat;
|
||||||
|
background-position: right center;
|
||||||
|
padding-right: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-table-row td {
|
table.tablesorter tbody tr:nth-child(odd) {
|
||||||
padding: 7px;
|
background-color: #e6e6e6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table.tablesorter tbody tr:nth-child(even) {
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.tablesorter tbody td {
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.tablesorter tbody tr:hover {
|
||||||
|
background-color: #d1d1d1
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue