diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2026-03-29 09:54:51 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2026-03-29 09:54:51 +0300 |
| commit | 7d1f357a5e263567707b8f018da17f74c44c6d50 (patch) | |
| tree | faefd91113c180f3591002a8fdf291dbfdf6e692 /dist/appcommon.js | |
| parent | d2ea17abf815b6cd754511e27f4853045e0b3ca2 (diff) | |
| download | the-epube-ts.tar.gz the-epube-ts.tar.xz | |
horrors of ts ts
Diffstat (limited to 'dist/appcommon.js')
| -rw-r--r-- | dist/appcommon.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/dist/appcommon.js b/dist/appcommon.js new file mode 100644 index 0000000..c457e6b --- /dev/null +++ b/dist/appcommon.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AppCommon = void 0; +class AppCommon { + urlParam(name) { + try { + const results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); + return decodeURIComponent(results[1].replace(/\+/g, " ")) || 0; + } + catch (e) { + return 0; + } + } + isOnline() { + if (typeof EpubeApp != "undefined" && typeof EpubeApp.isOnline != "undefined") + return EpubeApp.isOnline(); + else + return navigator.onLine; + } + initNightMode() { + if (typeof EpubeApp != "undefined") { + this.applyNightMode(EpubeApp.isNightMode()); + return; + } + if (window.matchMedia) { + const mql = window.matchMedia('(prefers-color-scheme: dark)'); + mql.addEventListener("change", () => { + this.applyNightMode(mql.matches); + }); + this.applyNightMode(mql.matches); + } + } + applyNightMode(is_night) { + console.log("night mode changed to", is_night); + $("#theme_css").attr("href", "lib/bootstrap/v3/css/" + (is_night ? "theme-dark.min.css" : "bootstrap-theme.min.css")); + } +} +exports.AppCommon = AppCommon; |
