mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-13 06:22:09 -04:00
Improve CSS rendering in Zimit archives
Former-commit-id: 8769e7b760a0689e87aec43bf994ac22fe9f2b42 [formerly f08d021ba6b6f3fac72256e6e86d9bc809246ce0 [formerly bc43f9b50dd87955c40f0e5d983b4279bf720fe4]] Former-commit-id: a3f2a57f92cd218d8f9195528878ddd1992c3506 [formerly 552ded0128b039024697db53b46311fd6a5d25d9] Former-commit-id: e11caebd562b7e0a5f53cf6068dc0180759f5897
This commit is contained in:
parent
c6e78fcf50
commit
a05f44cf32
@ -1600,6 +1600,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
|
||||
}
|
||||
document.getElementById('darkInvert').style.display = determinedWikiTheme == 'light' ? 'none' : 'block';
|
||||
}
|
||||
|
||||
document.getElementById('resetDisplayOnResizeCheck').addEventListener('click', function () {
|
||||
params.resetDisplayOnResize = this.checked;
|
||||
settingsStore.setItem('resetDisplayOnResize', this.checked, Infinity);
|
||||
@ -3667,6 +3668,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
|
||||
setupTableOfContents();
|
||||
listenForSearchKeys();
|
||||
}
|
||||
switchCSSTheme();
|
||||
//Set relative font size + Stackexchange-family multiplier
|
||||
var zimType = /-\/s\/style\.css/i.test(doc.head.innerHTML) ? "desktop" : "mobile";
|
||||
zimType = /-\/static\/main\.css/i.test(doc.head.innerHTML) ? "desktop-stx" : zimType; //Support stackexchange
|
||||
@ -4217,6 +4219,11 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
|
||||
params.containsMathTex = params.useMathJax ? /<script\s+type\s*=\s*['"]\s*math\/tex\s*['"]/i.test(htmlArticle) : false;
|
||||
params.containsMathSVG = params.useMathJax ? /<img\s+(?=[^>]+?math-fallback-image)[^>]*?alt\s*=\s*['"][^'"]+[^>]+>/i.test(htmlArticle) : false;
|
||||
|
||||
// If there is no CSP, add one to prevent external scripts and content
|
||||
if (!/<meta\b[^>]+Content-Security-Policy/i.test(htmlArticle)) {
|
||||
htmlArticle = htmlArticle.replace(/(\s*<\/head>)/, '\n <meta http-equiv="Content-Security-Policy" content="default-src \'self\' data: blob: bingmaps: \'unsafe-inline\' \'unsafe-eval\';"></meta>$1');
|
||||
}
|
||||
|
||||
if (params.zimType === 'open') {
|
||||
//Adapt German Wikivoyage POI data format
|
||||
var regexpGeoLocationDE = /<span\s+class="[^"]+?listing-coordinates[\s\S]+?latitude">([^<]+)[\s\S]+?longitude">([^<]+)<[\s\S]+?(<bdi\s[^>]+?listing-name[^>]+>(?:<a\b\s+href[^>]+>)?([^<]+))/ig;
|
||||
@ -4283,11 +4290,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
|
||||
});
|
||||
}
|
||||
|
||||
// If there is no CSP, add one to prevent external scripts and content
|
||||
if (!/<meta\b[^>]+Content-Security-Policy/i.test(htmlArticle)) {
|
||||
htmlArticle = htmlArticle.replace(/(\s*<\/head>)/, '\n <meta http-equiv="Content-Security-Policy" content="default-src \'self\' data: blob: bingmaps: \'unsafe-inline\' \'unsafe-eval\';"></meta>$1');
|
||||
}
|
||||
|
||||
if (params.zimType === 'open' || params.contentInjectionMode === 'jquery') {
|
||||
//Preload stylesheets [kiwix-js #149]
|
||||
console.log("Loading stylesheets...");
|
||||
//Set up blobArray of promises
|
||||
@ -4307,6 +4310,10 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
|
||||
htmlArticle = htmlArticle.replace(/\s*(<\/head>)/i, contentThemeStyle + '$1');
|
||||
injectHTML();
|
||||
}
|
||||
} else {
|
||||
// Zimit ZIMs in SW mode should not manipulate styles
|
||||
injectHTML();
|
||||
}
|
||||
|
||||
//Extract CSS URLs from given array of links
|
||||
function getBLOB(arr) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user