blob: c457e6b43624c10579428d265f89e481b4d1128a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;
|