Detect how to display pdf files

Closes: #1099
This commit is contained in:
eikek
2021-10-06 23:20:16 +02:00
parent b6187bb88d
commit f216c472ee
15 changed files with 217 additions and 87 deletions

View File

@ -43,8 +43,21 @@
// this is required for transitioning; elm fails to parse the account
account["requireSecondFactor"] = false;
}
// hack to guess if the browser can display PDFs natively. It
// seems that almost all browsers allow to query the
// navigator.mimeTypes array, except firefox.
var ua = navigator.userAgent.toLowerCase();
var pdfSupported = false;
if (ua.indexOf("firefox") > -1) {
pdfSupported = ua.indexOf("mobile") == -1;
} else {
pdfSupported = "application/pdf" in navigator.mimeTypes;
}
var elmFlags = {
"account": account,
"pdfSupported": pdfSupported,
"config": {{{flagsJson}}}
};
</script>