Skip to content

Commit

Permalink
[CHANGE] checkbox for libzim | cleanup for dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishabhg71 committed Dec 18, 2023
1 parent aaed6b0 commit ab8841b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
10 changes: 8 additions & 2 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,15 @@ <h3 data-i18n="configure-expert-settings-title">Expert settings</h3>
</div>
<div class="checkbox" id="">
<label title="Libzim wasm mode">
<span><b>Libzim Wasm mode</b> (<i>Uses unstable wasm api</i>)</span>
<input type="checkbox" name="useLibzim" id="useLibzim">
<span><b>Use Libzim for loading zim</b> (<i>Uses unstable libzim api for reading zim</i>)</span>
</label>
</div>
<div class="checkbox" id="libzimMode" style="display: none;">
<label title="Libzim wasm mode">
<span><b>Libzim version</b> (<i>Select which version to use</i>)</span>
<select id="libzimModeSelect">
<option value="default">Default</option>
<!-- <option value="default">Default (Full text search)</option> -->
<option value="wasm">WASM</option>
<option value="asm">ASM</option>
<option value="wasm.dev">WASM Debug</option>
Expand Down
9 changes: 7 additions & 2 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,17 @@ document.getElementById('bypassAppCacheCheck').addEventListener('change', functi
refreshCacheStatus();
});

if (params.useLibzim) document.getElementById('libzimMode').style.display = '';
document.getElementById('libzimModeSelect').addEventListener('change', function (e) {
// console.log(settingsStore.getItem('libzimMode'));
settingsStore.setItem('libzimMode', e.target.value);
window.location.reload();
});

document.getElementById('useLibzim').addEventListener('click', function (e) {
settingsStore.setItem('useLibzim', !params.useLibzim);
window.location.reload();
});

document.getElementById('disableDragAndDropCheck').addEventListener('change', function () {
params.disableDragAndDrop = !!this.checked;
settingsStore.setItem('disableDragAndDrop', params.disableDragAndDrop, Infinity);
Expand Down Expand Up @@ -2526,7 +2531,7 @@ function displayArticleContentInIframe (dirEntry, htmlArticle) {
// Get the url and the resolution from the srcset entry
var urlMatch = imgAndResolutionUrl.match(/^\s*([^\s]+)\s+([0-9.]+\w+)\s*$/);
var url = urlMatch ? urlMatch[1] : '';
var resolution = urlMatch ? urlMatch[2]: '';
var resolution = urlMatch ? urlMatch[2] : '';
selectedArchive.getDirEntryByPath(url).then(function (srcEntry) {
selectedArchive.readBinaryFile(srcEntry, function (fileDirEntry, content) {
var mimetype = srcEntry.getMimetype();
Expand Down
5 changes: 3 additions & 2 deletions www/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ params['cacheAPI'] = 'kiwix-js'; // Sets name of the prefix used to identify the
params['cacheIDB'] = 'kiwix-zim'; // Sets name of the Indexed DB database
params['isFileSystemApiSupported'] = typeof window.showOpenFilePicker === 'function'; // Sets a boolean indicating whether the FileSystem API is supported
params['isWebkitDirApiSupported'] = 'webkitdirectory' in document.createElement('input'); // Sets a boolean indicating whether the Webkit Directory API is supported
params['libzimMode'] = getSetting('libzimMode') || 'default'; // Sets a value indicating which libzim mode is selected
params['useLibzim'] = params.libzimMode !== 'default'; // Sets a value indicating which libzim mode is selected
params['libzimMode'] = getSetting('libzimMode') || 'wasm'; // Sets a value indicating which libzim mode is selected
params['useLibzim'] = !!getSetting('useLibzim'); // Sets a value indicating which libzim mode is selected

/**
* Apply any override parameters that might be in the querystring.
Expand Down Expand Up @@ -190,6 +190,7 @@ document.getElementById('openExternalLinksInNewTabsCheck').checked = params.open
document.getElementById('languageSelector').value = params.overrideBrowserLanguage || 'default';
document.getElementById('bypassAppCacheCheck').checked = !params.appCache;
document.getElementById('libzimModeSelect').value = params.libzimMode;
document.getElementById('useLibzim').checked = params.useLibzim;
document.getElementById('appVersion').textContent = 'Kiwix ' + params.appVersion;

// This is a simplified version of code in settingsStore, because that module is not available in init.js
Expand Down

0 comments on commit ab8841b

Please sign in to comment.