Fix calculation of table widths for print view

This commit is contained in:
RunasSudo 2021-05-25 01:34:26 +10:00
parent 56e32d11b3
commit 339e1496a7
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -594,7 +594,7 @@ function printResult() {
// Add stylesheets
let numToLoad = 0;
let numLoaded = 0;
let numLoaded = -1;
function onLoadStylesheet() {
numLoaded++;
@ -676,7 +676,7 @@ function printResult() {
return tdsAdded;
}
function copyTableColumns(startCol) {
async function copyTableColumns(startCol) {
// Add table
let elTable2 = wprint.document.createElement('table');
elTable2.className = 'result';
@ -701,6 +701,9 @@ function printResult() {
for (let c = startCol; c < rows[0].length + 1; c++) { // +1 to account for final status column
let tdsAdded = copyColumn(c, elTrs2);
// Nasty hack: DOM can take a while to update clientWidth
await new Promise(wprint.requestAnimationFrame);
// Check if overflowed
if (elTable2.clientWidth > printableWidth) {
for (let elTd2 of tdsAdded) {
@ -712,11 +715,14 @@ function printResult() {
}
}
copyTableColumns(1);
copyTableColumns(1).then(function() {
// Copy result logs2
divResultLogs1 = document.getElementById('resultLogs2');
divResultLogs2 = wprint.document.createElement('div');
divResultLogs2.innerHTML = divResultLogs1.innerHTML;
elContainer.appendChild(divResultLogs2);
// Copy result logs2
divResultLogs1 = document.getElementById('resultLogs2');
divResultLogs2 = wprint.document.createElement('div');
divResultLogs2.innerHTML = divResultLogs1.innerHTML;
elContainer.appendChild(divResultLogs2);
// Trigger print when ready
onLoadStylesheet();
});
}