Detect and report zimStyle to Config

This commit is contained in:
Jaifroid 2025-06-10 06:28:56 +01:00
parent 2744495cae
commit 4522b74814
2 changed files with 3 additions and 1 deletions

View File

@ -978,7 +978,7 @@
<label class="radio" title="The uses the style that is the default for the ZIM file you load. For Wikimedia ZIMs, this is now usually a 'mobile' display style. Note that 'mobile' hides certain elements, like some navigation boxes. If you want to see these in Wikimedia ZIMs, switch to 'desktop' style below.">
<input name="cssInjectionMode" id="cssModeAutoRadio" type="radio" value="auto">
<span class="radiobtn"></span>
<b>Default ZIM style</b> (in recent WikiMedia ZIMs, this is usually mobile)
<b>Default ZIM style</b> (<span id="zimtype">for Wikimedia ZIMs</span>)
</label>
<label class="radio" title="This is only relevant for Wikimedia ZIMs. It simulates the Wikipedia 'desktop' display style even for ZIMs with an embedded mobile style. Please note that this simulation involves adding in our own stylesheets and moving some elements, so it may not be 100% accurate.">
<input name="cssInjectionMode" id="cssModeDesktopRadio" type="radio" value="desktop">

View File

@ -6503,6 +6503,8 @@ function displayArticleContentInContainer (dirEntry, htmlArticle) {
zimType = /gutenberg\.css/i.test(testCSS) ? 'desktop-gtb' : zimType; // Support Gutenberg
zimType = /minerva|mobile/i.test(testCSS) ? 'mobile' : zimType;
cssSource = cssSource == 'auto' ? zimType : cssSource; // Default to in-built zimType if user has selected automatic detection of styles
// Report ZIM style to config #zimstyle
document.getElementById('zimtype').innerHTML = 'current ZIM style: <b>' + zimType + '</b>';
if (/minerva|inserted.style|pcs\.css/i.test(testCSS) && (cssCache || zimType != cssSource)) {
// Substitute ridiculously long style name TODO: move this code to transformStyles
for (var i = arr.length; i--;) { // TODO: move to transfromStyles