about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--.env-dist99
-rw-r--r--dist/app.min.js4
-rw-r--r--docker-compose.yml2
-rw-r--r--worker.js2
4 files changed, 83 insertions, 24 deletions
diff --git a/.env-dist b/.env-dist
index a03cf7a..c2dcd96 100644
--- a/.env-dist
+++ b/.env-dist
@@ -1,31 +1,90 @@
-# Copy to .env
-# Put any local modifications here.
+# Copy this file to .env and adjust values for your setup.
+# All EPUBE_* variables are read by the PHP application at runtime.
+# Non-prefixed variables are consumed by Docker / Docker Compose.
+# =============================================================================
 
+# ---------------------------------------------------------------------------
+# Docker / Registry
+# ---------------------------------------------------------------------------
+# PostgreSQL image used for the db service
 DB_IMAGE=postgres:15-alpine
 
-# Calibre library base directory (mounts to /books)
-BOOKS_DIR=/home/user/calibre/Books
+# Docker registry prefix (e.g. for a mirror or private registry)
+# PROXY_REGISTRY=
 
-EPUBE_ADMIN_USER=admin
-EPUBE_ADMIN_PASS=password
+# ---------------------------------------------------------------------------
+# Network
+# ---------------------------------------------------------------------------
+# Host port mapping for the web server.
+# Bind to 127.0.0.1 when behind a reverse proxy; omit for direct access.
+HTTP_PORT=127.0.0.1:8480
+# HTTP_PORT=8280
+
+# ---------------------------------------------------------------------------
+# Paths
+# ---------------------------------------------------------------------------
+# Local calibre library directory — mounted read-only as /books inside the app container
+BOOKS_DIR=/home/user/calibre/Books
 
+# Nginx document root (default: /var/www/html)
+# Change to /var/www/html/books when APP_BASE is empty
 # APP_WEB_ROOT=/var/www/html/books
-# APP_BASE=
 
-# bind exposed port to 127.0.0.1 by default in case reverse proxy is used.
-# if you plan to run the container standalone and need origin port exposed
-# use next HTTP_PORT definition (or remove "127.0.0.1:").
-HTTP_PORT=127.0.0.1:8480
-#HTTP_PORT=8280
+# URL base path for the epube application (default: /books)
+# Set to empty string to serve from the web root
+# APP_BASE=/books
 
-# Optional OAuth
-# EPUBE_OIDC_URL=
-# EPUBE_OIDC_NAME=
-# EPUBE_OIDC_CLIENT_ID=
-# EPUBE_OIDC_CLIENT_SECRET=
+# ---------------------------------------------------------------------------
+# Database
+# ---------------------------------------------------------------------------
+# Database type: sqlite (default) or pgsql
+# EPUBE_DB_TYPE=sqlite
 
-# PostgreSQL is optional, default is SQLite
-# EPUBE_DB_TYPE=pgsql
+# PostgreSQL settings (used when EPUBE_DB_TYPE=pgsql)
+# EPUBE_DB_HOST=db
+# EPUBE_DB_PORT=5432
 # EPUBE_DB_USER=postgres
-# EPUBE_DB_PASS=password
 # EPUBE_DB_NAME=postgres
+# EPUBE_DB_PASS=password
+
+# SQLite scratch database path (relative to app root)
+# EPUBE_SCRATCH_DB=db/scratch.db
+
+# Calibre metadata.db path (optional — defaults to /books/metadata.db inside container)
+# EPUBE_CALIBRE_DB=/books/metadata.db
+
+# ---------------------------------------------------------------------------
+# Application
+# ---------------------------------------------------------------------------
+# Session lifetime in seconds (default: 2592000 = 30 days)
+# EPUBE_SESSION_LIFETIME=2592000
+
+# Session cookie name (default: epube_sid)
+# EPUBE_SESSION_NAME=epube_sid
+
+# Dict server hostname (for online dictionary lookups)
+# EPUBE_DICT_SERVER=dict
+
+# ---------------------------------------------------------------------------
+# Authentication — Default Admin Account
+# ---------------------------------------------------------------------------
+# Created on first startup if the user does not already exist.
+EPUBE_ADMIN_USER=admin
+EPUBE_ADMIN_PASS=password
+
+# ---------------------------------------------------------------------------
+# Authentication — OpenID Connect (OIDC)
+# ---------------------------------------------------------------------------
+# Uncomment and fill in to enable OIDC login.
+# EPUBE_OIDC_URL=https://auth.example.org/application/o/epube/
+# EPUBE_OIDC_NAME=My Identity Provider
+# EPUBE_OIDC_CLIENT_ID=your-client-id
+# EPUBE_OIDC_CLIENT_SECRET=your-client-secret
+
+# ---------------------------------------------------------------------------
+# Debugging
+# ---------------------------------------------------------------------------
+# Enable Xdebug (requires xdebug PHP extension installed)
+# EPUBE_XDEBUG_ENABLED=1
+# EPUBE_XDEBUG_HOST=172.17.0.1
+# EPUBE_XDEBUG_PORT=9000
diff --git a/dist/app.min.js b/dist/app.min.js
index 5e87eb3..c708de9 100644
--- a/dist/app.min.js
+++ b/dist/app.min.js
@@ -1,4 +1,4 @@
-"use strict";function setupCsrfPrefilter(p){console.log("setting prefilter for token",p),$.ajaxPrefilter((e,a,o)=>{if(a.type!=="post"||e.type!=="post")return;const t=typeof a.data;t=="object"?e.data=$.param($.extend(a.data,{csrf_token:p})):t=="string"&&(e.data=a.data+"&csrf_token="+encodeURIComponent(p)),console.log(">>>",e)})}class Cookie{static set(e,a,o){const t=new Date;t.setTime(t.getTime()+o*1e3);const i="expires="+t.toUTCString();document.cookie=e+"="+encodeURIComponent(a)+"; "+i}static get(e){e=e+"=";const a=document.cookie.split(";");for(let o=0;o<a.length;o++){let t=a[o];for(;t.charAt(0)==" ";)t=t.substring(1);if(t.indexOf(e)==0)return decodeURIComponent(t.substring(e.length,t.length))}return""}static delete(e){const a="expires=Thu, 01-Jan-1970 00:00:01 GMT";document.cookie=e+"=; "+a}}class AppCommon{urlParam(e){try{const a=new RegExp("[?&]"+e+"=([^&#]*)").exec(window.location.href);return a&&decodeURIComponent(a[1].replace(/\+/g," "))||0}catch{return 0}}isOnline(){return typeof EpubeApp<"u"&&typeof EpubeApp.isOnline<"u"?EpubeApp.isOnline():navigator.onLine}async getActiveCacheName(){const a=(await navigator.serviceWorker.ready).active;return a?new Promise(o=>{const t=new MessageChannel;t.port1.onmessage=i=>{o(i.data.cacheName)},a.postMessage({type:"GET_CACHE_NAME"},[t.port2])}):null}async getActiveCacheVersion(){const a=(await navigator.serviceWorker.ready).active;return a?new Promise(o=>{const t=new MessageChannel;t.port1.onmessage=i=>{o(i.data.cacheName)},a.postMessage({type:"GET_CACHE_VERSION"},[t.port2])}):null}initNightMode(){if(typeof EpubeApp<"u"){this.applyNightMode(EpubeApp.isNightMode());return}if(window.matchMedia){const e=window.matchMedia("(prefers-color-scheme: dark)");e.addEventListener("change",()=>{this.applyNightMode(e.matches)}),this.applyNightMode(e.matches)}}applyNightMode(e){console.log("night mode changed to",e),$("#theme_css").attr("href","lib/bootstrap/v3/css/"+(e?"theme-dark.min.css":"bootstrap-theme.min.css"))}}class AppClass extends AppCommon{_dl_progress_timeout;index_mode="";index_query="";index_offset=0;cached_urls=[];version="v1781200872189";cosmeticVersion="v26.06-24187f2";csrf_token="";async init(){console.log("version",this.version,"current, worker",await this.getActiveCacheVersion()),this.csrf_token=Cookie.get("epube_csrf_token"),setupCsrfPrefilter(this.csrf_token),typeof EpubeApp<"u"&&($(".navbar").hide(),$(".epube-app-filler").show(),$(".separate-search").show(),$("body").addClass("is-epube-app"),this.urlParam("mode")=="favorites"?EpubeApp.setPage("PAGE_FAVORITES"):EpubeApp.setPage("PAGE_LIBRARY")),this.initNightMode(),this.initCommonEventHandlers(),this.populateList(),"serviceWorker"in navigator?(navigator.serviceWorker.addEventListener("message",()=>{}),this.showCovers(),this.updateOfflinePrompts()):$(".container-main").addClass("alert alert-danger").html("Service worker support missing in browser (are you using plain HTTP?).")}initCommonEventHandlers(){$(".remove_all_downloads").on("click",()=>{this.removeAll()}),$(".logout_link").on("click",()=>{this.logout()}),$(".download_all_link").on("click",e=>{e.preventDefault(),this.getAll()}),$(".cosmetic_version").attr("title",this.cosmeticVersion)}logout(){$.post("backend.php",{op:"logout"}).then(()=>{window.location.reload()})}async showSummary(e){const a=e.getAttribute("data-book-id");if(this.isOnline()){const o=await $.post("backend.php",{op:"getinfo",id:a}),t=o.comment?o.comment:"No description available";$("#summary-modal .modal-title").text(o.title),$("#summary-modal .book-summary").html(t),$("#summary-modal").modal()}else{const o=await localforage.getItem("epube-book."+a),t=o.comment?o.comment:"No description available";$("#summary-modal .modal-title").text(o.title),$("#summary-modal .book-summary").html(t),$("#summary-modal").modal()}return!1}showCovers(){$("img[data-book-id]").each((e,a)=>{const o=$(a);if(o.attr("data-cover-link")){const t=$("<img>").on("load",()=>{o.css("background-image","url("+o.attr("data-cover-link")+")").fadeIn(),t.attr("src",null)}).attr("src",o.attr("data-cover-link")??"")}})}toggleFavorite(e){const a=e.getAttribute("data-book-id");return(e.getAttribute("data-is-fav")=="0"||confirm("Remove favorite?"))&&$.post("backend.php",{op:"togglefav",id:a},o=>{if(o){let t="[Error]";o.status==0?t="Add to favorites":o.status==1&&(t="Remove from favorites"),$(e).html(t).attr("data-is-fav",o.status),this.index_mode=="favorites"&&o.status==0&&$("#cell-"+a).remove()}}),!1}updateOfflinePrompts(){const e=$(".offline_dropitem");$.each(e,(a,o)=>{this.updateOfflinePrompt(o)})}async updateOfflinePrompt(e){const a=e.getAttribute("data-book-id"),o="epube-book."+a;await localforage.getItem(o)?(e.onclick=()=>(this.remove(a,()=>{this.updateOfflinePrompt(e)}),!1),e.innerHTML="Remove offline data"):(e.onclick=()=>(this.get(a,()=>{this.updateOfflinePrompt(e)}),!1),e.innerHTML="Make available offline")}async offlineInit(){console.log("version",this.version,"current, worker",await this.getActiveCacheVersion()),typeof EpubeApp<"u"&&($(".navbar").hide(),$(".epube-app-filler").show(),$("body").addClass("is-epube-app"),EpubeApp.setPage("PAGE_OFFLINE")),this.initNightMode(),this.initCommonEventHandlers();const e=this.urlParam("query");e&&$(".search_query").val(e),this.populateOfflineList()}get(e,a){console.log("offline cache: "+e),$.post("backend.php",{op:"getinfo",id:e},o=>{if(o){const t="epube-book."+e;localforage.setItem(t,o).then(i=>{console.log(t+" got data");const s=[];s.push(fetch("backend.php?op=download&id="+i.epub_id,{credentials:"same-origin"}).then(function(n){n.status==200&&(console.log(t+" got book"),localforage.setItem(t+".book",n.blob()))})),s.push(fetch("backend.php?op=getpagination&id="+i.epub_id,{credentials:"same-origin"}).then(function(n){n.status==200&&(console.log(t+" got pagination"),n.text().then(function(l){localforage.setItem(t+".locations",JSON.parse(l))}))})),s.push(fetch("backend.php?op=getlastread&id="+i.epub_id,{credentials:"same-origin"}).then(function(n){n.status==200&&(console.log(t+" got lastread"),n.text().then(function(l){localforage.setItem(t+".lastread",JSON.parse(l))}))})),i.has_cover&&s.push(fetch("backend.php?op=cover&id="+e,{credentials:"same-origin"}).then(function(n){n.status==200&&(console.log(t+" got cover"),localforage.setItem(t+".cover",n.blob()))})),Promise.all(s).then(()=>{console.log("download done, running callback",a),a(),$(".dl-progress").show().html("Finished downloading <b>"+i.title+"</b>"),window.clearTimeout(this._dl_progress_timeout),this._dl_progress_timeout=window.setTimeout(function(){$(".dl-progress").fadeOut()},5*1e3)})})}})}getAll(){confirm("Download all books on this page?")&&$(".row > div").each((e,a)=>{const o=($(a).attr("id")??"").replace("cell-",""),t=$(a).find(".offline_dropitem")[0]??null;if(o){const i="epube-book."+o;localforage.getItem(i).then(s=>{s||this.get(o,()=>{this.updateOfflinePrompt(t)})})}})}removeFromList(e){const a=e.getAttribute("data-book-id");this.remove(a,()=>{$("#cell-"+a).remove()})}remove(e,a){if(confirm("Remove download?")){const o="epube-book."+e,t=[];console.log("offline remove: "+e),localforage.iterate(function(i,s){s.match(o)&&t.push(localforage.removeItem(s))}),Promise.all(t).then(()=>{console.log("remove done, running callback",a),window.setTimeout(()=>{a()},250)})}}populateList(){const e=new URLSearchParams({op:"list",mode:this.index_mode,query:this.index_query,offset:String(this.index_offset),limit:String(60)});$.get("backend.php?"+e.toString()).done(a=>{const o=$("#books_container");o.html(""),a.books&&a.books.length>0&&(a.books.forEach(t=>{const i=t.is_read?"read":"",s=t.in_progress?"in_progress":"",n=t.is_fav?"1":"0",l=t.is_fav?"Remove from favorites":"Add to favorites",r=t.series_name?`<div><a title="${this.escapeHtml(t.series_full)}" href="${this.escapeHtml(t.series_link)}">${this.escapeHtml(t.series_full)}</a></div>`:"",c=t.author_sort?`?${new URLSearchParams({query:t.author_sort}).toString()}`:"",d=t.download_formats.map(u=>{const h=u.format==="EPUB"?"label-success":"label-primary";return`<li><a target="_blank" href="backend.php?op=download&id=${u.id}">Download: <span class="label ${h}">${u.format}</span></a></li>`}).join(""),f=$(`<div class="col-xxs-6 col-xs-3 col-sm-3 col-md-2" id="cell-${t.id}">
+"use strict";function setupCsrfPrefilter(p){console.log("setting prefilter for token",p),$.ajaxPrefilter((e,a,o)=>{if(a.type!=="post"||e.type!=="post")return;const t=typeof a.data;t=="object"?e.data=$.param($.extend(a.data,{csrf_token:p})):t=="string"&&(e.data=a.data+"&csrf_token="+encodeURIComponent(p)),console.log(">>>",e)})}class Cookie{static set(e,a,o){const t=new Date;t.setTime(t.getTime()+o*1e3);const i="expires="+t.toUTCString();document.cookie=e+"="+encodeURIComponent(a)+"; "+i}static get(e){e=e+"=";const a=document.cookie.split(";");for(let o=0;o<a.length;o++){let t=a[o];for(;t.charAt(0)==" ";)t=t.substring(1);if(t.indexOf(e)==0)return decodeURIComponent(t.substring(e.length,t.length))}return""}static delete(e){const a="expires=Thu, 01-Jan-1970 00:00:01 GMT";document.cookie=e+"=; "+a}}class AppCommon{urlParam(e){try{const a=new RegExp("[?&]"+e+"=([^&#]*)").exec(window.location.href);return a&&decodeURIComponent(a[1].replace(/\+/g," "))||0}catch{return 0}}isOnline(){return typeof EpubeApp<"u"&&typeof EpubeApp.isOnline<"u"?EpubeApp.isOnline():navigator.onLine}async getActiveCacheName(){const a=(await navigator.serviceWorker.ready).active;return a?new Promise(o=>{const t=new MessageChannel;t.port1.onmessage=i=>{o(i.data.cacheName)},a.postMessage({type:"GET_CACHE_NAME"},[t.port2])}):null}async getActiveCacheVersion(){const a=(await navigator.serviceWorker.ready).active;return a?new Promise(o=>{const t=new MessageChannel;t.port1.onmessage=i=>{o(i.data.cacheName)},a.postMessage({type:"GET_CACHE_VERSION"},[t.port2])}):null}initNightMode(){if(typeof EpubeApp<"u"){this.applyNightMode(EpubeApp.isNightMode());return}if(window.matchMedia){const e=window.matchMedia("(prefers-color-scheme: dark)");e.addEventListener("change",()=>{this.applyNightMode(e.matches)}),this.applyNightMode(e.matches)}}applyNightMode(e){console.log("night mode changed to",e),$("#theme_css").attr("href","lib/bootstrap/v3/css/"+(e?"theme-dark.min.css":"bootstrap-theme.min.css"))}}class AppClass extends AppCommon{_dl_progress_timeout;index_mode="";index_query="";index_offset=0;cached_urls=[];version="v1781201265950";cosmeticVersion="v26.06-7f3cb1f";csrf_token="";async init(){console.log("version",this.version,"current, worker",await this.getActiveCacheVersion()),this.csrf_token=Cookie.get("epube_csrf_token"),setupCsrfPrefilter(this.csrf_token),typeof EpubeApp<"u"&&($(".navbar").hide(),$(".epube-app-filler").show(),$(".separate-search").show(),$("body").addClass("is-epube-app"),this.urlParam("mode")=="favorites"?EpubeApp.setPage("PAGE_FAVORITES"):EpubeApp.setPage("PAGE_LIBRARY")),this.initNightMode(),this.initCommonEventHandlers(),this.populateList(),"serviceWorker"in navigator?(navigator.serviceWorker.addEventListener("message",()=>{}),this.showCovers(),this.updateOfflinePrompts()):$(".container-main").addClass("alert alert-danger").html("Service worker support missing in browser (are you using plain HTTP?).")}initCommonEventHandlers(){$(".remove_all_downloads").on("click",()=>{this.removeAll()}),$(".logout_link").on("click",()=>{this.logout()}),$(".download_all_link").on("click",e=>{e.preventDefault(),this.getAll()}),$(".cosmetic_version").attr("title",this.cosmeticVersion)}logout(){$.post("backend.php",{op:"logout"}).then(()=>{window.location.reload()})}async showSummary(e){const a=e.getAttribute("data-book-id");if(this.isOnline()){const o=await $.post("backend.php",{op:"getinfo",id:a}),t=o.comment?o.comment:"No description available";$("#summary-modal .modal-title").text(o.title),$("#summary-modal .book-summary").html(t),$("#summary-modal").modal()}else{const o=await localforage.getItem("epube-book."+a),t=o.comment?o.comment:"No description available";$("#summary-modal .modal-title").text(o.title),$("#summary-modal .book-summary").html(t),$("#summary-modal").modal()}return!1}showCovers(){$("img[data-book-id]").each((e,a)=>{const o=$(a);if(o.attr("data-cover-link")){const t=$("<img>").on("load",()=>{o.css("background-image","url("+o.attr("data-cover-link")+")").fadeIn(),t.attr("src",null)}).attr("src",o.attr("data-cover-link")??"")}})}toggleFavorite(e){const a=e.getAttribute("data-book-id");return(e.getAttribute("data-is-fav")=="0"||confirm("Remove favorite?"))&&$.post("backend.php",{op:"togglefav",id:a},o=>{if(o){let t="[Error]";o.status==0?t="Add to favorites":o.status==1&&(t="Remove from favorites"),$(e).html(t).attr("data-is-fav",o.status),this.index_mode=="favorites"&&o.status==0&&$("#cell-"+a).remove()}}),!1}updateOfflinePrompts(){const e=$(".offline_dropitem");$.each(e,(a,o)=>{this.updateOfflinePrompt(o)})}async updateOfflinePrompt(e){const a=e.getAttribute("data-book-id"),o="epube-book."+a;await localforage.getItem(o)?(e.onclick=()=>(this.remove(a,()=>{this.updateOfflinePrompt(e)}),!1),e.innerHTML="Remove offline data"):(e.onclick=()=>(this.get(a,()=>{this.updateOfflinePrompt(e)}),!1),e.innerHTML="Make available offline")}async offlineInit(){console.log("version",this.version,"current, worker",await this.getActiveCacheVersion()),typeof EpubeApp<"u"&&($(".navbar").hide(),$(".epube-app-filler").show(),$("body").addClass("is-epube-app"),EpubeApp.setPage("PAGE_OFFLINE")),this.initNightMode(),this.initCommonEventHandlers();const e=this.urlParam("query");e&&$(".search_query").val(e),this.populateOfflineList()}get(e,a){console.log("offline cache: "+e),$.post("backend.php",{op:"getinfo",id:e},o=>{if(o){const t="epube-book."+e;localforage.setItem(t,o).then(i=>{console.log(t+" got data");const s=[];s.push(fetch("backend.php?op=download&id="+i.epub_id,{credentials:"same-origin"}).then(function(n){n.status==200&&(console.log(t+" got book"),localforage.setItem(t+".book",n.blob()))})),s.push(fetch("backend.php?op=getpagination&id="+i.epub_id,{credentials:"same-origin"}).then(function(n){n.status==200&&(console.log(t+" got pagination"),n.text().then(function(l){localforage.setItem(t+".locations",JSON.parse(l))}))})),s.push(fetch("backend.php?op=getlastread&id="+i.epub_id,{credentials:"same-origin"}).then(function(n){n.status==200&&(console.log(t+" got lastread"),n.text().then(function(l){localforage.setItem(t+".lastread",JSON.parse(l))}))})),i.has_cover&&s.push(fetch("backend.php?op=cover&id="+e,{credentials:"same-origin"}).then(function(n){n.status==200&&(console.log(t+" got cover"),localforage.setItem(t+".cover",n.blob()))})),Promise.all(s).then(()=>{console.log("download done, running callback",a),a(),$(".dl-progress").show().html("Finished downloading <b>"+i.title+"</b>"),window.clearTimeout(this._dl_progress_timeout),this._dl_progress_timeout=window.setTimeout(function(){$(".dl-progress").fadeOut()},5*1e3)})})}})}getAll(){confirm("Download all books on this page?")&&$(".row > div").each((e,a)=>{const o=($(a).attr("id")??"").replace("cell-",""),t=$(a).find(".offline_dropitem")[0]??null;if(o){const i="epube-book."+o;localforage.getItem(i).then(s=>{s||this.get(o,()=>{this.updateOfflinePrompt(t)})})}})}removeFromList(e){const a=e.getAttribute("data-book-id");this.remove(a,()=>{$("#cell-"+a).remove()})}remove(e,a){if(confirm("Remove download?")){const o="epube-book."+e,t=[];console.log("offline remove: "+e),localforage.iterate(function(i,s){s.match(o)&&t.push(localforage.removeItem(s))}),Promise.all(t).then(()=>{console.log("remove done, running callback",a),window.setTimeout(()=>{a()},250)})}}populateList(){const e=new URLSearchParams({op:"list",mode:this.index_mode,query:this.index_query,offset:String(this.index_offset),limit:String(60)});$.get("backend.php?"+e.toString()).done(a=>{const o=$("#books_container");o.html(""),a.books&&a.books.length>0&&(a.books.forEach(t=>{const i=t.is_read?"read":"",s=t.in_progress?"in_progress":"",n=t.is_fav?"1":"0",l=t.is_fav?"Remove from favorites":"Add to favorites",r=t.series_name?`<div><a title="${this.escapeHtml(t.series_full)}" href="${this.escapeHtml(t.series_link)}">${this.escapeHtml(t.series_full)}</a></div>`:"",c=t.author_sort?`?${new URLSearchParams({query:t.author_sort}).toString()}`:"",d=t.download_formats.map(u=>{const h=u.format==="EPUB"?"label-success":"label-primary";return`<li><a target="_blank" href="backend.php?op=download&id=${u.id}">Download: <span class="label ${h}">${u.format}</span></a></li>`}).join(""),f=$(`<div class="col-xxs-6 col-xs-3 col-sm-3 col-md-2" id="cell-${t.id}">
                         ${t.read_link?`<a class="thumbnail ${i}" href="${t.read_link}">`:`<span class="thumbnail ${i}">`}
                             <img style="display : none" data-book-id="${t.id}" data-cover-link="${t.cover_link}">
                         ${t.read_link?"</a>":"</span>"}
@@ -34,7 +34,7 @@
                                     <li><a href="#" class="remove_offline_data" data-book-id="${s.id}">Remove offline data</a></li>
                                 </ul>
                             </div>
-                        </div>`);$(h).find(".offline_summary").on("click",m=>{m.preventDefault(),this.showSummary(m.currentTarget)}),$(h).find(".remove_offline_data").on("click",m=>{m.preventDefault(),this.removeFromList(m.currentTarget)}),n?h.find("img").css("background-image","url("+n+")").fadeIn():h.fadeIn(),h.find(".series_link").attr("title",s.series_name+" ["+s.series_index+"]").attr("href","offline.html?query="+encodeURIComponent(s.series_name)),h.find(".author_link").attr("title",s.author_sort).attr("href","offline.html?query="+encodeURIComponent(s.author_sort)),a.append(h)}})})}}const DEFAULT_FONT_SIZE=16,DEFAULT_FONT_FAMILY="Arial",DEFAULT_LINE_HEIGHT=140,MIN_LENGTH_TO_JUSTIFY=32,LOCATION_DIVISOR=10,PAGE_RESET_PROGRESS=-1;class ReaderClass extends AppCommon{csrf_token="";last_stored_cfi="";startup_finished=!1;open_last_read_when_displayed=!0;hyphenate={};_prevent_lastread_timeout;_prevent_lastread;version="v1781200872189";cosmeticVersion="v26.06-24187f2";book;_swipeState={active:!1,startX:0,startY:0,startTime:0,direction:null};_swipeConfig={minDistance:50,velocityThreshold:.3,verticalDistanceThreshold:80};constructor(){super(),this.book=new ePub.Book,this.loader=new ReaderLoader}onTouchStart(e){const a=e.touches[0]||e.changedTouches[0];this._swipeState={active:!0,startX:a.clientX,startY:a.clientY,startTime:Date.now(),direction:e.target.id=="right"?"left":"right"}}onTouchEnd(e){if(!this._swipeState.active)return;const o=(e.changedTouches[0]||e.changedTouches[e.changedTouches.length-1]).clientX-this._swipeState.startX,t=Date.now()-this._swipeState.startTime,i=t>0?Math.abs(o)/t:0,s=Math.abs(o)>=this._swipeConfig.minDistance&&i>=this._swipeConfig.velocityThreshold,n=this._swipeState.direction=="left",l=n?o<0:o>0;s&&l&&(e.preventDefault(),e.stopPropagation(),n?this.nextPage():this.prevPage())}onTouchMove(e){if(!this._swipeState.active)return;const a=e.touches[0]||e.changedTouches[0];if(Math.abs(a.clientY-this._swipeState.startY)>this._swipeConfig.verticalDistanceThreshold){this._swipeState.active=!1;return}}async init(){console.log("version",this.version,"current, worker",await this.getActiveCacheVersion()),this.csrf_token=Cookie.get("epube_csrf_token"),setupCsrfPrefilter(this.csrf_token),$(document).on("keyup",a=>{this.hotkeyHandler(a)}),$(".close_book").on("click",()=>{this.close()}),$("#left").on("mouseup",()=>{this.prevPage()}),$(".search_input").on("change",()=>{this.search()}),$(".prev_location_btn").on("click",a=>{this.openPrevious(a.target)}),$("#right").on("mouseup",()=>{this.nextPage()}),$("#left, #right").on("touchstart",a=>{this.onTouchStart(a)}),$("#left, #right").on("touchmove",a=>{this.onTouchMove(a)}),$("#left, #right").on("touchend",a=>{this.onTouchEnd(a)});const e=await this.loader.init(this);console.log("[init] load failed",e),e?(this.applyTheme(),$(".loading-message").text("Resource loader failed to initialize.")):this.initSecondStage()}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0}onOfflineModeChanged(e){if(console.log("onOfflineModeChanged",e),!e&&this.book){console.log("we're online, storing lastread");const a=this.book.rendition.currentLocation().start.cfi,o=Math.round(this.book.locations.percentageFromCfi(a)*100);$.post("backend.php",{op:"storelastread",id:this.urlParam("id"),page:o,cfi:a,timestamp:new Date().getTime()},function(){}).fail(function(t){t&&t.status==401&&(window.location.href="index.php")})}}async initSecondStage(){if(typeof EpubeApp<"u"?EpubeApp.setPage("PAGE_READER"):($(window).on("online",()=>{this.onOfflineModeChanged(!1)}),$(window).on("offline",()=>{this.onOfflineModeChanged(!0)})),this.applyTheme(),!await localforage.getItem(this.cacheId())){const i=this.urlParam("b");console.log("requesting bookinfo for book",i);try{const s=await $.post("backend.php",{op:"getinfo",id:i});if(s.has_cover){const n=await fetch("backend.php?op=cover&id="+i);n.ok&&await localforage.setItem(this.cacheId("cover"),n.blob())}await localforage.setItem(this.cacheId(),s),console.log("bookinfo saved")}catch(s){const n=s;console.error(n),$(".loading-message").html(`Unable to load book info.<br/><small>${n.responseText}</small>`);return}}console.log("trying to load book...");let a=await localforage.getItem(this.cacheId("book"));if(!a){console.log("local data not found, loading from network..."),$(".loading-message").html("Downloading book\u2026");const i=await fetch("backend.php?op=download&id="+this.urlParam("id"));if(i.ok)if(a=await i.blob(),a)await localforage.setItem(this.cacheId("book"),a),console.log("saved local data for book");else{$(".loading-message").html("Unable to get book blob data.");return}else{$(".loading-message").html(`Unable to download book: ${i.status}`);return}}const o=new FileReader,t=this;o.onload=function(){try{t.openBookData(this.result)}catch(i){console.error(i),$(".loading-message").html("Unable to load book blob: "+i)}},o.onerror=i=>{console.log("filereader error",i),$(".loading-message").html("Unable to open book.<br/><small>"+i+"</small>")},o.readAsArrayBuffer(a)}async openBookData(e){try{await this.book.open(e)}catch(t){console.error(t),$(".loading-message").html(`Unable to open book.<br/><small>${t instanceof Error?t.message:t}</small>`);return}await this.book.ready,console.log("book is ready"),await this.showBookInfo(this.book),await this.loadLocations(this.book);const a=this.book.renderTo("reader",{width:"100%",height:"100%",allowScriptedContent:!1,minSpreadWidth:961});$(".location").on("click",async()=>{const t=Math.floor(a.currentLocation().start.location/LOCATION_DIVISOR),i=Math.floor(this.book.locations.length()/LOCATION_DIVISOR),s=prompt("Jump to location [1-"+i+"]",String(t));s&&await a.display(this.book.locations._locations[parseInt(s)*LOCATION_DIVISOR])}),await localforage.getItem("epube.enable-hyphens")&&(this.hyphenate.en=createHyphenator(hyphenationPatternsEnUs,{html:!0}),this.hyphenate.ru=createHyphenator(hyphenationPatternsRu,{html:!0})),this.initRenditionHooks(this.book,a),this.initModals(),this.initToc(this.book),this.blockLastReadUpdate(),await a.display(),console.log("startup finished"),this.startup_finished=!0}async showBookInfo(e){const a=await localforage.getItem(this.cacheId());let o,t;if(a)o=a.title,t=a.author_sort;else{const i=e.packaging.metadata;o=i.title,t=i.creator}document.title=o+" \u2013 "+t+" \u2013 The Epube",$(".title").text(o).attr("title",o+" \u2013 "+t),typeof EpubeApp<"u"&&(EpubeApp.setTitle(o),EpubeApp.showActionBar(!1))}async loadLocations(e){let a=await localforage.getItem(this.cacheId("locations"));if(a&&typeof a[0]=="string"){console.log("loading local locations...");try{await e.locations.load(a);return}catch(t){console.warn(t)}}if(this.isOnline()){console.log("downloading locations..."),$(".loading-message").html("Downloading locations\u2026");const t=await fetch("backend.php?op=getpagination&id="+this.urlParam("id"));if(t.ok){console.log("got locations from server");try{a=await t.json()}catch(i){console.warn(i)}if(a&&typeof a[0]=="string"){console.log("saving locations locally..."),await localforage.setItem(this.cacheId("locations"),a);try{e.locations.load(a);return}catch(i){console.warn(i)}}}}$(".loading-message").html("Preparing locations\u2026");let o=0;a=await e.locations.generate(100,t=>{if(o||(o=t.length()),o>0){const i=Math.round((1-t.length()/o)*100);$(".loading-message").html(`Preparing locations (${i}%)\u2026`)}}),$.post("backend.php",{op:"storepagination",id:this.urlParam("id"),payload:JSON.stringify(a),total:100}),await localforage.setItem(this.cacheId("locations"),a)}initRenditionHooks(e,a){console.log("initRenditionHooks"),e.spine.hooks.content.register(o=>{this.cleanupEmbeddedStyles(o)}),a.hooks.content.register(async o=>{o.on("linkClicked",n=>{console.log("linkClicked",n),this.blockLastReadUpdate(),n.indexOf("://")==-1&&($(".prev_location_btn").attr("data-location-cfi",a.currentLocation().start.cfi).show(),window.requestAnimationFrame(()=>{this.showUI(!0)}))}),o.on("selected",async n=>{if(this.isOnline()){const l=await e.getRange(n),r=l.endContainer.data.substring(l.startOffset,l.endOffset);console.log("selected",n,r),r.match(/^[\w­]+$/)&&this.lookupWord(r,()=>{typeof EpubeApp<"u"&&EpubeApp.showActionBar(!1),o.window.requestAnimationFrame(()=>{o.window.getSelection().removeAllRanges()})})}});const t=window.location.href.match(/^.*\//),i=t?t[0]:window.location.href;$(o.document.head).append($("<style type='text/css'>").text(this.generateFontsCss(i))),$(o.document.head).append($("<style type='text/css'>").text(this.loader._res_data[i+"dist/reader_iframe.min.css"]));const s=await localforage.getItem("epube.theme")||"default";$(o.document).find("body").attr("class",typeof EpubeApp<"u"?"is-epube-app":"").addClass("theme-"+s),console.log("contents",o),$(o.window).on("click tap",n=>{if(n.button==0){if($(".modal").is(":visible"))return;typeof EpubeApp<"u"?EpubeApp.toggleActionBar():this.showUI(!0)}}),$(o.window).on("wheel",async n=>{await localforage.getItem("epube.enable-wheel")&&((n.originalEvent?.deltaY??0)>0?this.nextPage():(n.originalEvent?.deltaY??0)<0&&this.prevPage())})}),a.on("keyup",o=>{this.hotkeyHandler(o)}),a.on("resized",()=>{console.log("rendition resized"),this.blockLastReadUpdate(),this.open_last_read_when_displayed=!0}),a.on("rendered",async()=>{console.log("rendition rendered"),this.applyTheme(),this.resizeSideColumns();try{const o=a.currentLocation();if(o.start){const t=e.canonical(o.start.href);let i={};$.each(this.flattenToc(e),function(s,n){if(e.spine.get(n.href).canonical==t){i=n;return}}),i&&i.label&&$(".chapter_title").html(i.label.trim()+" | "),this.generateTocBar(e,this.flattenToc(e))}}catch(o){console.warn(o)}this.open_last_read_when_displayed&&(this.open_last_read_when_displayed=!1,await this.openLastRead())}),a.on("displayed",function(){console.log("rendition displayed")}),a.on("relocated",o=>this.onRelocated(e,o))}initModals(){$("#settings-modal").on("shown.bs.modal",async()=>{const e=await localforage.getItem(this.cacheId("lastread"));e&&e.cfi&&$(".lastread_input").val(e.page+"%").attr("title",`[local] ${e.cfi}`),$(".clear_last_read").off("click").on("click",()=>{this.clearLastRead()}),$(".open_last_read").off("click").on("click",()=>{this.openLastRead()}),$(".mark_as_read").off("click").on("click",()=>{this.markAsRead()}),$(".reset_locations").off("click").on("click",()=>{this.resetLocations()}),navigator.onLine&&$.post("backend.php",{op:"getlastread",id:this.urlParam("id")},t=>{$(".lastread_input").val(t.page+"%").attr("title",`[remote] ${t.cfi}`)}),$(".font_family").off("change").on("change",t=>{this.onFontChanged(t.target)}),$(".font_size").off("change").on("change",t=>{this.onTextSizeChanged(t.target)}),$(".line_height").off("change").on("change",t=>{this.onLineHeightChanged(t.target)}),$(".theme_name").off("change").on("change",t=>{this.onThemeChanged(t.target)}),$(".enable_hyphens_checkbox").attr("checked",await localforage.getItem("epube.enable-hyphens")).off("click").on("click",t=>{localforage.setItem("epube.enable-hyphens",t.target.checked),confirm("Toggling hyphens requires page reload. Reload now?")&&window.location.reload()}),$(".enable_wheel_checkbox").attr("checked",await localforage.getItem("epube.enable-wheel")).off("click").on("click",t=>{localforage.setItem("epube.enable-wheel",t.target.checked)}),typeof EpubeApp<"u"?$(".keep_ui_checkbox").parent().parent().hide():$(".keep_ui_checkbox").attr("checked",await localforage.getItem("epube.keep-ui-visible")).off("click").on("click",t=>{localforage.setItem("epube.keep-ui-visible",t.target.checked)}),$(".last-mod-timestamp").html(`${this.cosmeticVersion} &mdash; ${this.version}
+                        </div>`);$(h).find(".offline_summary").on("click",m=>{m.preventDefault(),this.showSummary(m.currentTarget)}),$(h).find(".remove_offline_data").on("click",m=>{m.preventDefault(),this.removeFromList(m.currentTarget)}),n?h.find("img").css("background-image","url("+n+")").fadeIn():h.fadeIn(),h.find(".series_link").attr("title",s.series_name+" ["+s.series_index+"]").attr("href","offline.html?query="+encodeURIComponent(s.series_name)),h.find(".author_link").attr("title",s.author_sort).attr("href","offline.html?query="+encodeURIComponent(s.author_sort)),a.append(h)}})})}}const DEFAULT_FONT_SIZE=16,DEFAULT_FONT_FAMILY="Arial",DEFAULT_LINE_HEIGHT=140,MIN_LENGTH_TO_JUSTIFY=32,LOCATION_DIVISOR=10,PAGE_RESET_PROGRESS=-1;class ReaderClass extends AppCommon{csrf_token="";last_stored_cfi="";startup_finished=!1;open_last_read_when_displayed=!0;hyphenate={};_prevent_lastread_timeout;_prevent_lastread;version="v1781201265950";cosmeticVersion="v26.06-7f3cb1f";book;_swipeState={active:!1,startX:0,startY:0,startTime:0,direction:null};_swipeConfig={minDistance:50,velocityThreshold:.3,verticalDistanceThreshold:80};constructor(){super(),this.book=new ePub.Book,this.loader=new ReaderLoader}onTouchStart(e){const a=e.touches[0]||e.changedTouches[0];this._swipeState={active:!0,startX:a.clientX,startY:a.clientY,startTime:Date.now(),direction:e.target.id=="right"?"left":"right"}}onTouchEnd(e){if(!this._swipeState.active)return;const o=(e.changedTouches[0]||e.changedTouches[e.changedTouches.length-1]).clientX-this._swipeState.startX,t=Date.now()-this._swipeState.startTime,i=t>0?Math.abs(o)/t:0,s=Math.abs(o)>=this._swipeConfig.minDistance&&i>=this._swipeConfig.velocityThreshold,n=this._swipeState.direction=="left",l=n?o<0:o>0;s&&l&&(e.preventDefault(),e.stopPropagation(),n?this.nextPage():this.prevPage())}onTouchMove(e){if(!this._swipeState.active)return;const a=e.touches[0]||e.changedTouches[0];if(Math.abs(a.clientY-this._swipeState.startY)>this._swipeConfig.verticalDistanceThreshold){this._swipeState.active=!1;return}}async init(){console.log("version",this.version,"current, worker",await this.getActiveCacheVersion()),this.csrf_token=Cookie.get("epube_csrf_token"),setupCsrfPrefilter(this.csrf_token),$(document).on("keyup",a=>{this.hotkeyHandler(a)}),$(".close_book").on("click",()=>{this.close()}),$("#left").on("mouseup",()=>{this.prevPage()}),$(".search_input").on("change",()=>{this.search()}),$(".prev_location_btn").on("click",a=>{this.openPrevious(a.target)}),$("#right").on("mouseup",()=>{this.nextPage()}),$("#left, #right").on("touchstart",a=>{this.onTouchStart(a)}),$("#left, #right").on("touchmove",a=>{this.onTouchMove(a)}),$("#left, #right").on("touchend",a=>{this.onTouchEnd(a)});const e=await this.loader.init(this);console.log("[init] load failed",e),e?(this.applyTheme(),$(".loading-message").text("Resource loader failed to initialize.")):this.initSecondStage()}isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0}onOfflineModeChanged(e){if(console.log("onOfflineModeChanged",e),!e&&this.book){console.log("we're online, storing lastread");const a=this.book.rendition.currentLocation().start.cfi,o=Math.round(this.book.locations.percentageFromCfi(a)*100);$.post("backend.php",{op:"storelastread",id:this.urlParam("id"),page:o,cfi:a,timestamp:new Date().getTime()},function(){}).fail(function(t){t&&t.status==401&&(window.location.href="index.php")})}}async initSecondStage(){if(typeof EpubeApp<"u"?EpubeApp.setPage("PAGE_READER"):($(window).on("online",()=>{this.onOfflineModeChanged(!1)}),$(window).on("offline",()=>{this.onOfflineModeChanged(!0)})),this.applyTheme(),!await localforage.getItem(this.cacheId())){const i=this.urlParam("b");console.log("requesting bookinfo for book",i);try{const s=await $.post("backend.php",{op:"getinfo",id:i});if(s.has_cover){const n=await fetch("backend.php?op=cover&id="+i);n.ok&&await localforage.setItem(this.cacheId("cover"),n.blob())}await localforage.setItem(this.cacheId(),s),console.log("bookinfo saved")}catch(s){const n=s;console.error(n),$(".loading-message").html(`Unable to load book info.<br/><small>${n.responseText}</small>`);return}}console.log("trying to load book...");let a=await localforage.getItem(this.cacheId("book"));if(!a){console.log("local data not found, loading from network..."),$(".loading-message").html("Downloading book\u2026");const i=await fetch("backend.php?op=download&id="+this.urlParam("id"));if(i.ok)if(a=await i.blob(),a)await localforage.setItem(this.cacheId("book"),a),console.log("saved local data for book");else{$(".loading-message").html("Unable to get book blob data.");return}else{$(".loading-message").html(`Unable to download book: ${i.status}`);return}}const o=new FileReader,t=this;o.onload=function(){try{t.openBookData(this.result)}catch(i){console.error(i),$(".loading-message").html("Unable to load book blob: "+i)}},o.onerror=i=>{console.log("filereader error",i),$(".loading-message").html("Unable to open book.<br/><small>"+i+"</small>")},o.readAsArrayBuffer(a)}async openBookData(e){try{await this.book.open(e)}catch(t){console.error(t),$(".loading-message").html(`Unable to open book.<br/><small>${t instanceof Error?t.message:t}</small>`);return}await this.book.ready,console.log("book is ready"),await this.showBookInfo(this.book),await this.loadLocations(this.book);const a=this.book.renderTo("reader",{width:"100%",height:"100%",allowScriptedContent:!1,minSpreadWidth:961});$(".location").on("click",async()=>{const t=Math.floor(a.currentLocation().start.location/LOCATION_DIVISOR),i=Math.floor(this.book.locations.length()/LOCATION_DIVISOR),s=prompt("Jump to location [1-"+i+"]",String(t));s&&await a.display(this.book.locations._locations[parseInt(s)*LOCATION_DIVISOR])}),await localforage.getItem("epube.enable-hyphens")&&(this.hyphenate.en=createHyphenator(hyphenationPatternsEnUs,{html:!0}),this.hyphenate.ru=createHyphenator(hyphenationPatternsRu,{html:!0})),this.initRenditionHooks(this.book,a),this.initModals(),this.initToc(this.book),this.blockLastReadUpdate(),await a.display(),console.log("startup finished"),this.startup_finished=!0}async showBookInfo(e){const a=await localforage.getItem(this.cacheId());let o,t;if(a)o=a.title,t=a.author_sort;else{const i=e.packaging.metadata;o=i.title,t=i.creator}document.title=o+" \u2013 "+t+" \u2013 The Epube",$(".title").text(o).attr("title",o+" \u2013 "+t),typeof EpubeApp<"u"&&(EpubeApp.setTitle(o),EpubeApp.showActionBar(!1))}async loadLocations(e){let a=await localforage.getItem(this.cacheId("locations"));if(a&&typeof a[0]=="string"){console.log("loading local locations...");try{await e.locations.load(a);return}catch(t){console.warn(t)}}if(this.isOnline()){console.log("downloading locations..."),$(".loading-message").html("Downloading locations\u2026");const t=await fetch("backend.php?op=getpagination&id="+this.urlParam("id"));if(t.ok){console.log("got locations from server");try{a=await t.json()}catch(i){console.warn(i)}if(a&&typeof a[0]=="string"){console.log("saving locations locally..."),await localforage.setItem(this.cacheId("locations"),a);try{e.locations.load(a);return}catch(i){console.warn(i)}}}}$(".loading-message").html("Preparing locations\u2026");let o=0;a=await e.locations.generate(100,t=>{if(o||(o=t.length()),o>0){const i=Math.round((1-t.length()/o)*100);$(".loading-message").html(`Preparing locations (${i}%)\u2026`)}}),$.post("backend.php",{op:"storepagination",id:this.urlParam("id"),payload:JSON.stringify(a),total:100}),await localforage.setItem(this.cacheId("locations"),a)}initRenditionHooks(e,a){console.log("initRenditionHooks"),e.spine.hooks.content.register(o=>{this.cleanupEmbeddedStyles(o)}),a.hooks.content.register(async o=>{o.on("linkClicked",n=>{console.log("linkClicked",n),this.blockLastReadUpdate(),n.indexOf("://")==-1&&($(".prev_location_btn").attr("data-location-cfi",a.currentLocation().start.cfi).show(),window.requestAnimationFrame(()=>{this.showUI(!0)}))}),o.on("selected",async n=>{if(this.isOnline()){const l=await e.getRange(n),r=l.endContainer.data.substring(l.startOffset,l.endOffset);console.log("selected",n,r),r.match(/^[\w­]+$/)&&this.lookupWord(r,()=>{typeof EpubeApp<"u"&&EpubeApp.showActionBar(!1),o.window.requestAnimationFrame(()=>{o.window.getSelection().removeAllRanges()})})}});const t=window.location.href.match(/^.*\//),i=t?t[0]:window.location.href;$(o.document.head).append($("<style type='text/css'>").text(this.generateFontsCss(i))),$(o.document.head).append($("<style type='text/css'>").text(this.loader._res_data[i+"dist/reader_iframe.min.css"]));const s=await localforage.getItem("epube.theme")||"default";$(o.document).find("body").attr("class",typeof EpubeApp<"u"?"is-epube-app":"").addClass("theme-"+s),console.log("contents",o),$(o.window).on("click tap",n=>{if(n.button==0){if($(".modal").is(":visible"))return;typeof EpubeApp<"u"?EpubeApp.toggleActionBar():this.showUI(!0)}}),$(o.window).on("wheel",async n=>{await localforage.getItem("epube.enable-wheel")&&((n.originalEvent?.deltaY??0)>0?this.nextPage():(n.originalEvent?.deltaY??0)<0&&this.prevPage())})}),a.on("keyup",o=>{this.hotkeyHandler(o)}),a.on("resized",()=>{console.log("rendition resized"),this.blockLastReadUpdate(),this.open_last_read_when_displayed=!0}),a.on("rendered",async()=>{console.log("rendition rendered"),this.applyTheme(),this.resizeSideColumns();try{const o=a.currentLocation();if(o.start){const t=e.canonical(o.start.href);let i={};$.each(this.flattenToc(e),function(s,n){if(e.spine.get(n.href).canonical==t){i=n;return}}),i&&i.label&&$(".chapter_title").html(i.label.trim()+" | "),this.generateTocBar(e,this.flattenToc(e))}}catch(o){console.warn(o)}this.open_last_read_when_displayed&&(this.open_last_read_when_displayed=!1,await this.openLastRead())}),a.on("displayed",function(){console.log("rendition displayed")}),a.on("relocated",o=>this.onRelocated(e,o))}initModals(){$("#settings-modal").on("shown.bs.modal",async()=>{const e=await localforage.getItem(this.cacheId("lastread"));e&&e.cfi&&$(".lastread_input").val(e.page+"%").attr("title",`[local] ${e.cfi}`),$(".clear_last_read").off("click").on("click",()=>{this.clearLastRead()}),$(".open_last_read").off("click").on("click",()=>{this.openLastRead()}),$(".mark_as_read").off("click").on("click",()=>{this.markAsRead()}),$(".reset_locations").off("click").on("click",()=>{this.resetLocations()}),navigator.onLine&&$.post("backend.php",{op:"getlastread",id:this.urlParam("id")},t=>{$(".lastread_input").val(t.page+"%").attr("title",`[remote] ${t.cfi}`)}),$(".font_family").off("change").on("change",t=>{this.onFontChanged(t.target)}),$(".font_size").off("change").on("change",t=>{this.onTextSizeChanged(t.target)}),$(".line_height").off("change").on("change",t=>{this.onLineHeightChanged(t.target)}),$(".theme_name").off("change").on("change",t=>{this.onThemeChanged(t.target)}),$(".enable_hyphens_checkbox").attr("checked",await localforage.getItem("epube.enable-hyphens")).off("click").on("click",t=>{localforage.setItem("epube.enable-hyphens",t.target.checked),confirm("Toggling hyphens requires page reload. Reload now?")&&window.location.reload()}),$(".enable_wheel_checkbox").attr("checked",await localforage.getItem("epube.enable-wheel")).off("click").on("click",t=>{localforage.setItem("epube.enable-wheel",t.target.checked)}),typeof EpubeApp<"u"?$(".keep_ui_checkbox").parent().parent().hide():$(".keep_ui_checkbox").attr("checked",await localforage.getItem("epube.keep-ui-visible")).off("click").on("click",t=>{localforage.setItem("epube.keep-ui-visible",t.target.checked)}),$(".last-mod-timestamp").html(`${this.cosmeticVersion} &mdash; ${this.version}
                 (${this.isOnline()?"<span class='text-success'>Online</span>":"<span class='text-danger'>Offline</span>"})
                 `),$(".font_family").val(await localforage.getItem("epube.fontFamily")||DEFAULT_FONT_FAMILY),$(".theme_name").val(await localforage.getItem("epube.theme")||"default");const a=$(".font_size").html("");for(let t=10;t<=32;t++){const i=$("<option>").val(t).html(t+" px");a.append(i)}a.val(await localforage.getItem("epube.fontSize")||DEFAULT_FONT_SIZE);const o=$(".line_height").html("");for(let t=100;t<=220;t+=10){const i=$("<option>").val(t).html(t+"%");o.append(i)}o.val(await localforage.getItem("epube.lineHeight")||DEFAULT_LINE_HEIGHT)}),$("#dict-modal").on("shown.bs.modal",()=>{$(".dict_query").off("change").on("change",()=>{this.lookupWord(null,null,".dict_query")}),$(".dict_result").scrollTop(0)}),$(".dict_search_btn").on("click",function(){$("#dict-modal").modal("hide"),window.open("https://duckduckgo.com/?q="+$(".dict_query").val())})}initToc(e){const a=this;function o(i){try{const s=e.spine.get(i).cfiBase,n=e.locations._locations.find(function(l){return l.indexOf(s)!=-1});return Math.round(a.book.locations.locationFromCfi(n)/LOCATION_DIVISOR)}catch(s){console.warn(s)}return""}function t(i,s,n){if(n==3)return!1;if(i.subitems){const l=$("<ul class='toc_sublist list-unstyled'>");$.each(i.subitems,function(r,c){const d=$("<a>").attr("href","#").html("<b class='pull-right'>"+o(c.href)+"</b>"+c.label).attr("data-href",c.href).click(function(){e.rendition.display(d.attr("data-href"))});l.append($("<li>").append(d)),t(c,l,n+1)}),s.append(l)}}$("#toc-modal").on("shown.bs.modal",function(){const i=e.navigation.toc,s=$(".toc_list");s.html(""),$.each(i,function(n,l){try{const r=$("<a>").attr("href","#").html("<b class='pull-right'>"+o(l.href)+"</b>"+l.label).attr("data-href",l.href).click(function(){e.rendition.display(r.attr("data-href"))});s.append($("<li>").append(r)),t(l,s,0)}catch(r){console.warn(r)}}),s.children().length<=1&&(s.html(""),$.each(e.spine.items,function(n,l){const r=$("<a>").attr("href","#").attr("title",l.url).html(`Section ${n+1}`).attr("data-href",l.href).on("click",()=>{e.rendition.display(r.attr("data-href"))});s.append($("<li>").append(r))}))})}cleanupEmbeddedStyles(e){$(e).find("p").filter((a,o)=>$(o).text().length>=MIN_LENGTH_TO_JUSTIFY?o:null).css("text-align","justify"),$(e).find("html").attr("class",""),$(e).find("pre").css("white-space","pre-wrap"),$(e).find("a, p, span, em, i, strong, b, body, header, section, div, big, small, table, tr, td, th, ul, ol, li").attr("class","").css("font-family","inherit").css("font-size","inherit").css("line-height","inherit").css("color","").css("border","none ! important").css("background","").css("background-color","").attr("width","").attr("height",""),$(e).find("h1, h2, h3, h4, h5").attr("class","").css("font-family","inherit").css("color","").css("border","none ! important").css("background","").css("background-color",""),typeof this.hyphenate.en<"u"&&$(e).find("p, div").each((a,o)=>{const t=$(o);t.html(this.hyphenate.en(t.html())),t.html(this.hyphenate.ru(t.html()))})}generateFontsCss(e){return`
             /** Calibri */
diff --git a/docker-compose.yml b/docker-compose.yml
index 694eeac..71f23c5 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,6 +1,6 @@
 services:
   db:
-    image: ${DB_IMAGE}
+    image: ${PROXY_REGISTRY}${DB_IMAGE}
     restart: unless-stopped
     env_file:
       - .env
diff --git a/worker.js b/worker.js
index d4572af..8811cb9 100644
--- a/worker.js
+++ b/worker.js
@@ -1 +1 @@
-var i=["dist/app-libs.min.js","dist/app.min.js","dist/app.min.css","dist/reader_iframe.min.css","manifest.json","worker.js","offline.html","read.html","lib/fonts/palai.ttf","lib/fonts/palabi.ttf","lib/fonts/palab.ttf","lib/fonts/pala.ttf","lib/fonts/consolaz.ttf","lib/fonts/consolai.ttf","lib/fonts/consolab.ttf","lib/fonts/consola.ttf","lib/fonts/cambriaz.ttf","lib/fonts/cambriai.ttf","lib/fonts/cambriab.ttf","lib/fonts/cambria.ttf","lib/fonts/calibriz.ttf","lib/fonts/calibrii.ttf","lib/fonts/calibrib.ttf","lib/fonts/calibri.ttf","lib/fonts/caeciliai.ttf","lib/fonts/caeciliab.ttf","lib/fonts/caecilia.ttf","lib/fonts/IBMPlexMono-TextItalic.otf","lib/fonts/IBMPlexMono-Text.otf","lib/fonts/IBMPlexMono-BoldItalic.otf","lib/fonts/IBMPlexMono-Bold.otf","img/ic_launcher_web.png","img/favicon.png"];const sw=self,CACHE_PREFIX="epube",CACHE_VERSION="v1781200872189",CACHE_NAME=CACHE_PREFIX+"-"+CACHE_VERSION,MANIFEST_ASSETS=i;sw.addEventListener("install",t=>{t.waitUntil((async()=>{console.log("[worker] install started",CACHE_NAME);const s=await caches.open(CACHE_NAME),a=MANIFEST_ASSETS.map(e=>new Request(e,{cache:"reload"}));try{await s.addAll(a),console.log("[worker] all assets cached successfully"),sw.skipWaiting()}catch(e){console.error("[worker] Critical precache failed! Critical asset missing:",e)}})())}),sw.addEventListener("message",t=>{t.data&&t.data.type==="GET_CACHE_NAME"?t.ports[0].postMessage({cacheName:CACHE_NAME}):t.data&&t.data.type==="GET_CACHE_VERSION"&&t.ports[0].postMessage({cacheName:CACHE_VERSION})}),sw.addEventListener("activate",t=>{console.log("[worker] activate");const s=async()=>{const a=await caches.keys();for(const e of a)e.includes(CACHE_PREFIX)&&e!==CACHE_NAME&&await caches.delete(e);await sw.clients.claim()};t.waitUntil(s())}),sw.addEventListener("fetch",t=>{const s=new URL(t.request.url);if(!s.pathname.startsWith("/assets/")){if(s.pathname.match("backend.php\\?op=(cover|getinfo)")){t.respondWith((async()=>{try{const a=await fetch(t.request);return a.ok&&await(await caches.open(CACHE_NAME)).put(a.url,a.clone()),a}catch{const e=await caches.match(t.request);if(e)return e}})());return}if(s.pathname=="/"||s.pathname.match("index.php|offline.html|read.html")){t.respondWith((async()=>{try{const a=await fetch(t.request);return a.ok&&await(await caches.open(CACHE_NAME)).put(a.url,a.clone()),a}catch{return s.pathname.includes("read.html")?caches.match("read.html"):caches.match("/offline.html")}})());return}t.respondWith((async()=>{const a=await caches.open(CACHE_NAME),e=await a.match(t.request);return e?(fetch(t.request).then(c=>{c.ok&&a.put(t.request,c.clone())}).catch(c=>console.warn("[worker] Background update failed:",c)),e):await fetch(t.request)})())}});
+var i=["dist/app-libs.min.js","dist/app.min.js","dist/app.min.css","dist/reader_iframe.min.css","manifest.json","worker.js","offline.html","read.html","lib/fonts/palai.ttf","lib/fonts/palabi.ttf","lib/fonts/palab.ttf","lib/fonts/pala.ttf","lib/fonts/consolaz.ttf","lib/fonts/consolai.ttf","lib/fonts/consolab.ttf","lib/fonts/consola.ttf","lib/fonts/cambriaz.ttf","lib/fonts/cambriai.ttf","lib/fonts/cambriab.ttf","lib/fonts/cambria.ttf","lib/fonts/calibriz.ttf","lib/fonts/calibrii.ttf","lib/fonts/calibrib.ttf","lib/fonts/calibri.ttf","lib/fonts/caeciliai.ttf","lib/fonts/caeciliab.ttf","lib/fonts/caecilia.ttf","lib/fonts/IBMPlexMono-TextItalic.otf","lib/fonts/IBMPlexMono-Text.otf","lib/fonts/IBMPlexMono-BoldItalic.otf","lib/fonts/IBMPlexMono-Bold.otf","img/ic_launcher_web.png","img/favicon.png"];const sw=self,CACHE_PREFIX="epube",CACHE_VERSION="v1781201265950",CACHE_NAME=CACHE_PREFIX+"-"+CACHE_VERSION,MANIFEST_ASSETS=i;sw.addEventListener("install",t=>{t.waitUntil((async()=>{console.log("[worker] install started",CACHE_NAME);const s=await caches.open(CACHE_NAME),a=MANIFEST_ASSETS.map(e=>new Request(e,{cache:"reload"}));try{await s.addAll(a),console.log("[worker] all assets cached successfully"),sw.skipWaiting()}catch(e){console.error("[worker] Critical precache failed! Critical asset missing:",e)}})())}),sw.addEventListener("message",t=>{t.data&&t.data.type==="GET_CACHE_NAME"?t.ports[0].postMessage({cacheName:CACHE_NAME}):t.data&&t.data.type==="GET_CACHE_VERSION"&&t.ports[0].postMessage({cacheName:CACHE_VERSION})}),sw.addEventListener("activate",t=>{console.log("[worker] activate");const s=async()=>{const a=await caches.keys();for(const e of a)e.includes(CACHE_PREFIX)&&e!==CACHE_NAME&&await caches.delete(e);await sw.clients.claim()};t.waitUntil(s())}),sw.addEventListener("fetch",t=>{const s=new URL(t.request.url);if(!s.pathname.startsWith("/assets/")){if(s.pathname.match("backend.php\\?op=(cover|getinfo)")){t.respondWith((async()=>{try{const a=await fetch(t.request);return a.ok&&await(await caches.open(CACHE_NAME)).put(a.url,a.clone()),a}catch{const e=await caches.match(t.request);if(e)return e}})());return}if(s.pathname=="/"||s.pathname.match("index.php|offline.html|read.html")){t.respondWith((async()=>{try{const a=await fetch(t.request);return a.ok&&await(await caches.open(CACHE_NAME)).put(a.url,a.clone()),a}catch{return s.pathname.includes("read.html")?caches.match("read.html"):caches.match("/offline.html")}})());return}t.respondWith((async()=>{const a=await caches.open(CACHE_NAME),e=await a.match(t.request);return e?(fetch(t.request).then(c=>{c.ok&&a.put(t.request,c.clone())}).catch(c=>console.warn("[worker] Background update failed:",c)),e):await fetch(t.request)})())}});