Files
HowBadIsMyBatch/docs/batchCodeTable.html
frankknoll a0a05bfed9 refactoring
2022-02-20 12:33:21 +01:00

97 lines
2.8 KiB
HTML

<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Batch Codes</title>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.css">
<link rel="stylesheet" type="text/css" href="batchCodeTable.css">
<link rel="stylesheet" type="text/css" href="forkMeOnGitHub.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" charset="utf8"
src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.min.js"></script>
<script>
function loadBatchCodeTable() {
const columnIndex = {
'Batch': 0,
'Adverse Reaction Reports': 1,
'Deaths': 2,
'Disabilities': 3,
'Life Threatening Illnesses': 4,
'Company': 5,
'Lethality': 6
};
$('#batchCodeTable').DataTable(
{
ajax: "data/batchCodeTable.json",
language:
{
searchPlaceholder: "Enter Batch Code"
},
search:
{
return: false
},
processing: true,
deferRender: true,
order: [[columnIndex['Adverse Reaction Reports'], "desc"]],
columnDefs:
[
{
searchable: false,
targets: [
columnIndex['Adverse Reaction Reports'],
columnIndex['Deaths'],
columnIndex['Disabilities'],
columnIndex['Life Threatening Illnesses'],
columnIndex['Company'],
columnIndex['Lethality']
]
},
{
render: (data, type, row) => {
const lethality = parseFloat(data);
return !isNaN(lethality) ? lethality.toFixed(2) + " %" : '';
},
targets: [columnIndex['Lethality']]
}
]
});
}
function selectInput() {
const input = document.querySelector(".dataTables_filter input");
input.focus();
input.select();
}
$(document).ready(function () {
loadBatchCodeTable();
selectInput();
});
</script>
</head>
<body>
<span id="forkongithub"><a href="https://github.com/KnollFrank/HowBadIsMyBatch">Fork me on GitHub</a></span>
<h1>Batch Codes</h1>
<p>
<b>Check out your batch code</b> (last updated 16th February 2022)
<table class="display" id="batchCodeTable">
<thead>
<tr>
<th>Batch</th>
<th>Adverse Reaction Reports</th>
<th>Deaths</th>
<th>Disabilities</th>
<th>Life Threatening Illnesses</th>
<th>Company</th>
<th>Lethality</th>
</tr>
</thead>
</table>
</p>
</body>
</html>