Skip to content

Commit

Permalink
[ADD] ui & component logic for libzim wasm mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishabhg71 committed Nov 13, 2023
1 parent e772cff commit dc8a27b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,12 @@ <h3 data-i18n="configure-expert-settings-title">Expert settings</h3>
<span data-i18n="configure-expert-bypassappcache"><b>Bypass AppCache</b> (<i>disables offline use of PWA!</i>)</span>
</label>
</div>
<div class="checkbox" id="">
<label title="Libzim wasm mode">
<input type="checkbox" name="" id="libzimWasmModeToggle">
<span><b>Libzim Wasm mode</b> (<i>Uses unstable wasm api</i>)</span>
</label>
</div>
<p data-i18n="configure-expert-resetapp-description" class="pt-2">Reset the app to default settings and erase all caches:</p>
<div class="button">
<label data-i18n-tip="configure-expert-resetapp-tip" title="This will return the app to its original settings on launch, and will empty all caches and settings and deregister Service Workers. The app will then reload.">
Expand Down
5 changes: 5 additions & 0 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,11 @@ document.getElementById('bypassAppCacheCheck').addEventListener('change', functi
// This will also send any new values to Service Worker
refreshCacheStatus();
});

document.getElementById('libzimWasmModeToggle').addEventListener('change', function () {
settingsStore.setItem('libzimWasmMode', this.checked);
});

document.getElementById('disableDragAndDropCheck').addEventListener('change', function () {
params.disableDragAndDrop = !!this.checked;
settingsStore.setItem('disableDragAndDrop', params.disableDragAndDrop, Infinity);
Expand Down
3 changes: 3 additions & 0 deletions www/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
* @property {string} cacheIDB - Name of the Indexed DB database
* @property {boolean} isFileSystemApiSupported - A boolean indicating whether the FileSystem API is supported.
* @property {boolean} isWebkitDirApiSupported - A boolean indicating whether the Webkit Directory API is supported.
* @property {boolean} libzimWasmMode - A boolean indicating whether the Libzim wasm mode is turned on.
* @property {DecompressorAPI} decompressorAPI
/**
Expand Down Expand Up @@ -123,6 +124,7 @@ 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['libzimWasmMode'] = getSetting('libzimWasmMode'); // Sets a boolean indicating whether the libzim WASM mode is turned on

/**
* Apply any override parameters that might be in the querystring.
Expand Down Expand Up @@ -185,6 +187,7 @@ document.getElementById('useHomeKeyToFocusSearchBarCheck').checked = params.useH
document.getElementById('openExternalLinksInNewTabsCheck').checked = params.openExternalLinksInNewTabs;
document.getElementById('languageSelector').value = params.overrideBrowserLanguage || 'default';
document.getElementById('bypassAppCacheCheck').checked = !params.appCache;
document.getElementById('libzimWasmModeToggle').checked = params.libzimWasmMode;
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 dc8a27b

Please sign in to comment.