summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-05-18 09:00:12 +0300
committerAndrew Dolgov <[email protected]>2020-05-18 09:00:12 +0300
commit021a845638d8003751980a8bc16da149702cf46b (patch)
tree74daa975cb1199aefdfae294fc3955fb03037867 /js
parent6c40c6da461294aad6d789154b6342734e0b502e (diff)
show script last modified timestamp in settings UI
last-read / style related fixes
Diffstat (limited to 'js')
-rw-r--r--js/reader.js51
1 files changed, 38 insertions, 13 deletions
diff --git a/js/reader.js b/js/reader.js
index 5b03a8c..a842a74 100644
--- a/js/reader.js
+++ b/js/reader.js
@@ -161,9 +161,11 @@ const Reader = {
minSpreadWidth: 961
});
- rendition.hooks.content.register(function() {
+ Reader.applyStyles(true);
+
+ /* rendition.hooks.content.register(function() {
Reader.applyStyles();
- });
+ }); */
rendition.display().then(function() {
console.log("book displayed");
@@ -239,6 +241,13 @@ const Reader = {
});
});
+ localforage.getItem("epube.cache-timestamp").then(function(stamp) {
+ if (parseInt(stamp))
+ $(".last-mod-timestamp").text("V: " + new Date(stamp*1000).toLocaleString("en-GB"))
+ else
+ $(".last-mod-timestamp").text("");
+ });
+
localforage.getItem("epube.fontFamily").then(function(font) {
if (!font) font = DEFAULT_FONT_FAMILY;
@@ -508,6 +517,7 @@ const Reader = {
$(".loading_message").html("Opening chapter...");
window.setTimeout(function() {
+ Reader.resizeSideColumns();
Reader.Page.openLastRead();
$(".loading").hide();
@@ -611,7 +621,7 @@ const Reader = {
}
});
},
- applyStyles: function() {
+ applyStyles: function(default_only) {
Promise.all([
localforage.getItem("epube.fontSize"),
localforage.getItem("epube.fontFamily"),
@@ -625,13 +635,28 @@ const Reader = {
console.log('style', fontFamily, fontSize, lineHeight);
- $.each(window.book.rendition.getContents(), function(i, c) {
- c.css("font-size", fontSize);
- c.css("font-family", "'" + fontFamily + "'");
- c.css("line-height", lineHeight);
- c.css("text-align", "justify");
+ console.log('applying default theme...');
+
+ window.book.rendition.themes.default({
+ html: {
+ 'font-size': fontSize,
+ 'font-family': "'" + fontFamily + "'",
+ 'line-height': lineHeight,
+ 'text-align': 'justify'
+ }
});
+ if (!default_only) {
+ console.log('applying rendition themes...');
+
+ $.each(window.book.rendition.getContents(), function(i, c) {
+ c.css("font-size", fontSize);
+ c.css("font-family", "'" + fontFamily + "'");
+ c.css("line-height", lineHeight);
+ c.css("text-align", 'justify');
+ });
+ }
+
Reader.applyTheme();
});
@@ -926,7 +951,7 @@ const Reader = {
}
},
- openLastRead: function() {
+ openLastRead: function(local_only) {
localforage.getItem(Reader.cacheId("lastread")).then(function(item) {
console.log('lr local', item);
@@ -946,18 +971,18 @@ const Reader = {
console.warn(e);
}
- if (navigator.onLine) {
+ if (navigator.onLine && !local_only) {
$.post("backend.php", { op: "getlastread", id: $.urlParam("id") }, function(data) {
console.log('lr remote', data);
if (navigator.onLine && data) {
- localforage.setItem(Reader.cacheId("lastread"),
- {cfi: data.cfi, page: data.page, total: data.total});
-
try {
if (item.cfi != data.cfi && (!item.page || data.page >= item.page))
console.log('using remote lastread...');
+ localforage.setItem(Reader.cacheId("lastread"),
+ {cfi: data.cfi, page: data.page, total: data.total});
+
book.rendition.display(data.cfi).then(() => {
book.rendition.display(data.cfi);
});