Don't show print dialog until styles loaded
This commit is contained in:
parent
1ad1684e67
commit
56e32d11b3
@ -593,11 +593,28 @@ function printResult() {
|
||||
wprint.document.title = 'pyRCV2 Report';
|
||||
|
||||
// Add stylesheets
|
||||
let numToLoad = 0;
|
||||
let numLoaded = 0;
|
||||
|
||||
function onLoadStylesheet() {
|
||||
numLoaded++;
|
||||
if (numLoaded == numToLoad) {
|
||||
wprint.print();
|
||||
}
|
||||
}
|
||||
|
||||
for (let elCSSBase of document.querySelectorAll('head link')) {
|
||||
numToLoad++;
|
||||
let elCSS = wprint.document.createElement('link');
|
||||
elCSS.rel = elCSSBase.rel;
|
||||
elCSS.type = elCSSBase.type;
|
||||
if (elCSSBase.href.endsWith('?v=GITVERSION')) {
|
||||
elCSS.href = elCSSBase.href.replace('?v=GITVERSION', '?v=' + Math.random());
|
||||
} else {
|
||||
elCSS.href = elCSSBase.href;
|
||||
}
|
||||
|
||||
elCSS.onload = onLoadStylesheet;
|
||||
wprint.document.head.appendChild(elCSS);
|
||||
}
|
||||
|
||||
@ -702,6 +719,4 @@ function printResult() {
|
||||
divResultLogs2 = wprint.document.createElement('div');
|
||||
divResultLogs2.innerHTML = divResultLogs1.innerHTML;
|
||||
elContainer.appendChild(divResultLogs2);
|
||||
|
||||
wprint.print();
|
||||
}
|
||||
|
Reference in New Issue
Block a user