Added sorting to Hold Lot table.
This commit is contained in:
parent
a963525b43
commit
715f3709a9
@ -16,15 +16,15 @@
|
||||
|
||||
<h1 class="text-center">Hold Lots</h1>
|
||||
<br /><br />
|
||||
<table class="table text-center">
|
||||
<table class="table text-center" id="sortTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">WO</th>
|
||||
<th scope="col">RDS</th>
|
||||
<th scope="col">Reactor</th>
|
||||
<th scope="col">Hold Time</th>
|
||||
<th scope="col">Hold User</th>
|
||||
<th scope="col">Hold Reason</th>
|
||||
<th scope="col" class="text-start"><button class="btn"><i class="fa-solid fa-arrow-up" id="i-0" onclick="sortTable(0)"></i></button>WO</th>
|
||||
<th scope="col" class="text-start"><button class="btn"><i class="fa-solid fa-arrow-up" id="i-1" onclick="sortTable(1)"></i></button>RDS</th>
|
||||
<th scope="col" class="text-start"><button class="btn"><i class="fa-solid fa-arrow-up" id="i-2" onclick="sortTable(2)"></i></button>Reactor</th>
|
||||
<th scope="col" class="text-start" style="padding-left: 2.5rem;"><button class="btn"><i class="fa-solid fa-arrow-up" id="i-3" onclick="sortTable(3)"></i></button>Hold Time</th>
|
||||
<th scope="col" class="text-start"><button class="btn"><i class="fa-solid fa-arrow-up" id="i-4" onclick="sortTable(4)"></i></button>Hold User</th>
|
||||
<th scope="col" class="text-start" style="padding-left: 12rem;"><button class="btn"><i class="fa-solid fa-arrow-up" id="i-5" onclick="sortTable(5)"></i></button>Hold Reason</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -1 +1 @@
|
||||
[{"Date":"2023-01-09T00:00:00-07:00","ASM":8,"HTR":16},{"Date":"2023-01-10T00:00:00-07:00","ASM":8,"HTR":16},{"Date":"2023-01-11T00:00:00-07:00","ASM":8,"HTR":16},{"Date":"2023-01-12T00:00:00-07:00","ASM":7,"HTR":16},{"Date":"2023-01-13T00:00:00-07:00","ASM":7,"HTR":15},{"Date":"2023-01-14T00:00:00-07:00","ASM":8,"HTR":15},{"Date":"2023-01-15T00:00:00-07:00","ASM":9,"HTR":15},{"Date":"2023-01-17T00:00:00-07:00","ASM":9,"HTR":15},{"Date":"2023-01-18T00:00:00-07:00","ASM":9,"HTR":15}]
|
||||
[{"Date":"2023-01-09T00:00:00-07:00","ASM":8,"HTR":16},{"Date":"2023-01-10T00:00:00-07:00","ASM":8,"HTR":16},{"Date":"2023-01-11T00:00:00-07:00","ASM":8,"HTR":16},{"Date":"2023-01-12T00:00:00-07:00","ASM":7,"HTR":16},{"Date":"2023-01-13T00:00:00-07:00","ASM":7,"HTR":15},{"Date":"2023-01-14T00:00:00-07:00","ASM":8,"HTR":15},{"Date":"2023-01-15T00:00:00-07:00","ASM":9,"HTR":15},{"Date":"2023-01-17T00:00:00-07:00","ASM":9,"HTR":15},{"Date":"2023-01-18T00:00:00-07:00","ASM":9,"HTR":15},{"Date":"2023-01-19T00:00:00-07:00","ASM":9,"HTR":15}]
|
@ -158,3 +158,67 @@ function toggleWeek() {
|
||||
rptTableDiv[i].classList.toggle("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
function sortTable(n) {
|
||||
var table, rows, switching, i, x, y, shouldSwitch, dir, switchCount = 0;
|
||||
table = document.getElementById("sortTable");
|
||||
switching = true;
|
||||
dir = "asc";
|
||||
|
||||
while (switching) {
|
||||
switching = false;
|
||||
rows = table.rows;
|
||||
|
||||
for (i = 1; i < rows.length - 1; i++) {
|
||||
shouldSwitch = false;
|
||||
x = rows[i].getElementsByTagName("td")[n];
|
||||
y = rows[i + 1].getElementsByTagName("td")[n];
|
||||
|
||||
if (compareStrings(n == 3, dir, x.innerHTML.toLowerCase(), y.innerHTML.toLowerCase())) {
|
||||
shouldSwitch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSwitch) {
|
||||
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
|
||||
switching = true;
|
||||
switchCount++;
|
||||
} else {
|
||||
if (switchCount == 0 && dir == "asc") {
|
||||
dir = "desc";
|
||||
switching = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
icon = document.getElementById("i-" + n);
|
||||
|
||||
icon.classList.toggle("fa-arrow-down")
|
||||
icon.classList.toggle("fa-arrow-up")
|
||||
}
|
||||
|
||||
function compareStrings(isDate, dir, string1, string2) {
|
||||
if (isDate) {
|
||||
var date1 = new Date(string1);
|
||||
var date2 = new Date(string2);
|
||||
|
||||
console.log(date1);
|
||||
console.log(date2);
|
||||
|
||||
if (dir == "asc" && date1 > date2)
|
||||
return true;
|
||||
|
||||
if (dir == "desc" && date1 < date2)
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (dir == "asc" && string1 > string2)
|
||||
return true;
|
||||
|
||||
if (dir == "desc" && string1 < string2)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user