summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2024-01-13 12:33:11 +0300
committerAndrew Dolgov <[email protected]>2024-01-13 12:33:11 +0300
commitdf96606477ea5bb866c8c615441037f07fafd3b0 (patch)
treef642667324bf90cea4b5e794cef9b296a670c34f /js
parentd31fcb72cc6f6b2d1d798a75ff62d06c4dcd0cb4 (diff)
fonts, service worker cleanup
Diffstat (limited to 'js')
-rw-r--r--js/app.js2
-rw-r--r--js/reader.js16
-rw-r--r--js/reader_iframe.js9
3 files changed, 12 insertions, 15 deletions
diff --git a/js/app.js b/js/app.js
index f2774f2..3f44002 100644
--- a/js/app.js
+++ b/js/app.js
@@ -97,7 +97,7 @@ const App = {
.text("Updated " + refreshed_files + " files...");
}
- if (event.data == 'client-reload') {
+ if (event.data == 'refresh-finished') {
localforage.setItem("epube.cache-timestamp", App.last_mtime);
localforage.setItem("epube.cache-version", App.version);
window.location.reload()
diff --git a/js/reader.js b/js/reader.js
index abc3e9e..d5b6ead 100644
--- a/js/reader.js
+++ b/js/reader.js
@@ -280,17 +280,21 @@ const Reader = {
});
const base_url = window.location.href.match(/^.*\//)[0];
+
+ // TODO: use resource loader for offline
+ const fonts_css = typeof EpubeApp != "undefined" ? "/assets/android.css" : base_url + "/lib/fonts/fonts.css";
+ $(contents.document.head).append($(`<link type="text/css" rel="stylesheet" media="screen" href="${fonts_css}" />`));
+
const res_names = [ "dist/app-libs.min.js", "dist/reader_iframe.min.js" ];
- const doc = contents.document;
for (let i = 0; i < res_names.length; i++) {
// we need to create script element with proper context, that is inside the iframe
- const elem = doc.createElement("script");
+ const elem = contents.document.createElement("script");
elem.type = 'text/javascript';
elem.text = Reader.Loader._res_data[base_url + res_names[i]];
- doc.head.appendChild(elem);
+ contents.document.head.appendChild(elem);
}
$(contents.document.head)
@@ -303,9 +307,7 @@ const Reader = {
$(contents.document).find("body")
.attr("class", typeof EpubeApp != "undefined" ? "is-epube-app" : "")
.addClass("theme-" + theme);
-
});
-
});
$('#settings-modal').on('shown.bs.modal', function() {
@@ -1133,8 +1135,8 @@ const Reader = {
Loader: {
_res_data: [],
init: function() {
- // we need to preload resources for reader iframe because it can't utilize our
- // service worker because while offline it is created outside our base server context
+
+ // we need to provide resources for reader iframe because service worker fetch() handler doesn't work inside iframes (chrome bug?)
const res_names = [ "dist/app-libs.min.js",
"dist/reader_iframe.min.js", "dist/reader_iframe.min.css" ];
diff --git a/js/reader_iframe.js b/js/reader_iframe.js
index 6a9a8e3..8848187 100644
--- a/js/reader_iframe.js
+++ b/js/reader_iframe.js
@@ -1,6 +1,6 @@
'use strict';
-/* global EpubeApp */
+/* global EpubeApp $ jQuery */
let Reader;
let App;
@@ -17,12 +17,7 @@ function enable_swipes() {
});
}
-if (typeof EpubeApp != "undefined") {
- const localCss = $('<link type="text/css" rel="stylesheet" media="screen" href="/assets/android.css" />');
- $("head").append(localCss);
-}
-
-$(document).ready(function() {
+jQuery(() => {
Reader = parent.__get_reader();
App = parent.__get_app();