fix(js reader): adjust height to dynamic viewport height, add amber theme

This commit is contained in:
IgorKurkov
2025-10-26 18:23:07 +01:00
parent 6b11d0b4f3
commit 1ce1aee35e
4 changed files with 462 additions and 268 deletions

2
.gitignore vendored
View File

@@ -35,3 +35,5 @@ gdrive_credentials
client_secrets.json
gmail.json
/.key
calibre-volume
calibre-web-env

View File

@@ -1,19 +1,24 @@
.lightTheme {
background: #fff;
color: #000;
background: #fff;
color: #000;
}
.darkTheme {
background: #202124;
color: #fff
background: #202124;
color: #fff;
}
.sepiaTheme {
background: #ece1ca;
color: #000;
background: #ece1ca;
color: #000;
}
.amberTheme {
background: #e8bf5e;
color: #000;
}
.blackTheme {
background: #000;
color: #fff;
}
background: #000;
color: #fff;
}

View File

@@ -1,11 +1,10 @@
@font-face {
font-family: 'fontello';
src: url('fonts/fontello.eot?60518104');
src:
url('fonts/fontello.eot?60518104#iefix') format('embedded-opentype'),
url('fonts/fontello.woff?60518104') format('woff'),
url('fonts/fontello.ttf?60518104') format('truetype'),
url('fonts/fontello.svg?60518104#fontello') format('svg');
font-family: "fontello";
src: url("fonts/fontello.eot?60518104");
src: url("fonts/fontello.eot?60518104#iefix") format("embedded-opentype"),
url("fonts/fontello.woff?60518104") format("woff"),
url("fonts/fontello.ttf?60518104") format("truetype"),
url("fonts/fontello.svg?60518104#fontello") format("svg");
font-weight: normal;
font-style: normal;
}
@@ -16,7 +15,7 @@ body {
}
.myselect {
overflow: visible !important;
overflow: visible !important;
}
#main {
@@ -48,7 +47,7 @@ body {
-webkit-transition: opacity 0.5s;
-moz-transition: opacity 0.5s;
transition: opacity 0.5s;
z-index: 10;
z-index: 100;
}
#titlebar:hover {
@@ -93,14 +92,18 @@ body {
box-shadow: inset 0 0 6px rgba(155, 155, 155, 0.8);
}
#book-title { font-weight: 600; }
#title-seperator { display: none; }
#book-title {
font-weight: 600;
}
#title-seperator {
display: none;
}
#viewer {
width: 80%;
height: 80%;
margin: 0 auto;
z-index: 2;
z-index: 0;
position: relative;
overflow: hidden;
}
@@ -136,6 +139,7 @@ body {
user-select: none;
padding-top: 160px;
padding-bottom: 160px;
z-index: 10;
}
.arrow:hover {
@@ -200,10 +204,16 @@ body {
max-width: 80%;
}
#title-controls { float: right; }
#title-controls {
float: right;
}
#panels a::before { visibility: visible; }
#panels a:hover { color: #aaa; }
#panels a::before {
visibility: visible;
}
#panels a:hover {
color: #aaa;
}
.list_item.currentChapter > a,
.list_item a:hover {
@@ -237,8 +247,12 @@ body {
margin-top: -1px;
}
input::-webkit-input-placeholder { color: #454545; }
input:-moz-placeholder { color: #454545; }
input::-webkit-input-placeholder {
color: #454545;
}
input:-moz-placeholder {
color: #454545;
}
#divider {
position: absolute;
@@ -378,14 +392,14 @@ input:-moz-placeholder { color: #454545; }
}
.toc_toggle::before {
content: '▸';
content: "▸";
color: #fff;
margin-right: -4px;
}
.currentChapter > .toc_toggle::before,
.openChapter > .toc_toggle::before {
content: '▾';
content: "▾";
}
.view {
@@ -499,13 +513,25 @@ input:-moz-placeholder { color: #454545; }
list-style-type: none;
}
#settingsPanel .xsmall { font-size: x-small; }
#settingsPanel .small { font-size: small; }
#settingsPanel .medium { font-size: medium; }
#settingsPanel .large { font-size: large; }
#settingsPanel .xlarge { font-size: x-large; }
#settingsPanel .xsmall {
font-size: x-small;
}
#settingsPanel .small {
font-size: small;
}
#settingsPanel .medium {
font-size: medium;
}
#settingsPanel .large {
font-size: large;
}
#settingsPanel .xlarge {
font-size: x-large;
}
.highlight { background-color: yellow; }
.highlight {
background-color: yellow;
}
.modal {
position: fixed;
@@ -581,6 +607,7 @@ input:-moz-placeholder { color: #454545; }
color: white;
}
.md-content .themes button.lightTheme,
.md-content .themes button.whiteTheme {
background-color: white;
color: black;
@@ -591,6 +618,11 @@ input:-moz-placeholder { color: #454545; }
color: black;
}
.md-content .themes button.amberTheme {
background-color: #e8bf5e;
color: black;
}
.md-content .themes button.blackTheme {
background-color: black;
color: white;
@@ -638,31 +670,47 @@ input:-moz-placeholder { color: #454545; }
@media only screen and (max-width: 900px) {
#viewer {
width: 60%;
margin-left: 20%;
width: 100%;
height: calc(100dvh - 99px);
margin-left: 0;
}
#viewer iframe {
width: 100%;
height: 100%;
}
#prev {
left: 20px;
z-index: 10;
}
#next {
right: 20px;
z-index: 10;
}
}
@media only screen and (max-width: 550px) {
#viewer {
width: 80%;
margin-left: 10%;
width: 100%;
height: calc(100dvh - 99px);
margin-left: 0;
}
#viewer iframe {
width: 100%;
height: 100%;
}
#prev {
left: 0;
z-index: 10;
}
#next {
right: 0;
z-index: 10;
}
.arrow {
@@ -712,11 +760,7 @@ input:-moz-placeholder { color: #454545; }
}
}
@media only screen
and (min-device-width: 768px)
and (max-device-width: 1024px)
and (orientation: landscape)
/* and (-webkit-min-device-pixel-ratio: 2)*/ {
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) /* and (-webkit-min-device-pixel-ratio: 2) */ {
#viewer {
width: 80%;
margin-left: 10%;
@@ -739,47 +783,52 @@ input:-moz-placeholder { color: #454545; }
/* For iPhone 6\6s portrait layouts only */
@media only screen and (min-device-width: 375px) and (max-device-width: 667px) and (orientation: portrait) {
#viewer {
width: 300px;
height: 480px;
width: 100%;
height: calc(100dvh - 99px);
}
#viewer iframe {
width: 300px;
height: 480px;
width: 100%;
height: 100%;
}
}
/* For iPhone 6\6s landscape layouts only */
@media only screen and (min-device-width: 375px) and (max-device-width: 667px) and (orientation: landscape) {
#viewer {
width: 450px;
height: 300px;
width: 100%;
height: calc(100dvh - 99px);
}
#viewer iframe {
width: 450px;
height: 300px;
width: 100%;
height: 100%;
}
}
/* For iPhone portrait layouts only */
@media only screen and (max-device-width: 374px) and (orientation: portrait) {
#viewer {
width: 256px;
height: 432px;
width: 100%;
height: calc(100dvh - 99px);
}
#viewer iframe {
width: 256px;
height: 432px;
width: 100%;
height: 100%;
}
}
/* For iPhone landscape layouts only */
@media only screen and (max-device-width: 374px) and (orientation: landscape) {
#viewer {
width: 100%;
height: calc(100dvh - 99px);
}
#viewer iframe {
width: 256px;
height: 124px;
width: 100%;
height: 100%;
}
}
@@ -803,32 +852,76 @@ input:-moz-placeholder { color: #454545; }
font-size: 112%;
}
.icon-search::before { content: '\e807'; } /* '' */
.icon-resize-full-1::before { content: '\e804'; } /* '' */
.icon-cancel-circled2::before { content: '\e80f'; } /* '' */
.icon-link::before { content: '\e80d'; } /* '' */
.icon-bookmark::before { content: '\e805'; } /* '' */
.icon-bookmark-empty::before { content: '\e806'; } /* '' */
.icon-download-cloud::before { content: '\e811'; } /* '' */
.icon-edit::before { content: '\e814'; } /* '' */
.icon-menu::before { content: '\e802'; } /* '' */
.icon-cog::before { content: '\e813'; } /* '' */
.icon-resize-full::before { content: '\e812'; } /* '' */
.icon-cancel-circled::before { content: '\e80e'; } /* '' */
.icon-up-dir::before { content: '\e80c'; } /* '' */
.icon-right-dir::before { content: '\e80b'; } /* '' */
.icon-angle-right::before { content: '\e809'; } /* '' */
.icon-angle-down::before { content: '\e80a'; } /* '' */
.icon-right::before { content: '\e815'; } /* '' */
.icon-list-1::before { content: '\e803'; } /* '' */
.icon-list-numbered::before { content: '\e801'; } /* '' */
.icon-columns::before { content: '\e810'; } /* '' */
.icon-list::before { content: '\e800'; } /* '' */
.icon-resize-small::before { content: '\e808'; } /* '' */
.icon-search::before {
content: "\e807";
} /* '' */
.icon-resize-full-1::before {
content: "\e804";
} /* '' */
.icon-cancel-circled2::before {
content: "\e80f";
} /* '' */
.icon-link::before {
content: "\e80d";
} /* '' */
.icon-bookmark::before {
content: "\e805";
} /* '' */
.icon-bookmark-empty::before {
content: "\e806";
} /* '' */
.icon-download-cloud::before {
content: "\e811";
} /* '' */
.icon-edit::before {
content: "\e814";
} /* '' */
.icon-menu::before {
content: "\e802";
} /* '' */
.icon-cog::before {
content: "\e813";
} /* '' */
.icon-resize-full::before {
content: "\e812";
} /* '' */
.icon-cancel-circled::before {
content: "\e80e";
} /* '' */
.icon-up-dir::before {
content: "\e80c";
} /* '' */
.icon-right-dir::before {
content: "\e80b";
} /* '' */
.icon-angle-right::before {
content: "\e809";
} /* '' */
.icon-angle-down::before {
content: "\e80a";
} /* '' */
.icon-right::before {
content: "\e815";
} /* '' */
.icon-list-1::before {
content: "\e803";
} /* '' */
.icon-list-numbered::before {
content: "\e801";
} /* '' */
.icon-columns::before {
content: "\e810";
} /* '' */
.icon-list::before {
content: "\e800";
} /* '' */
.icon-resize-small::before {
content: "\e808";
} /* '' */
#progress{
right: 4rem;
bottom: 4rem;
width: fit-content;
position: absolute;
#progress {
right: 4rem;
bottom: 2px;
width: fit-content;
position: absolute;
}

View File

@@ -1,46 +1,72 @@
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>{{_('epub Reader')}} | {{title}}</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
{% if g.google_site_verification|length > 0 %}
<meta name="google-site-verification" content="{{g.google_site_verification}}">
<meta
name="google-site-verification"
content="{{g.google_site_verification}}"
/>
{% endif %}
<link rel="apple-touch-icon" sizes="140x140" href="{{ url_for('static', filename='favicon.ico') }}">
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
<link
rel="apple-touch-icon"
sizes="140x140"
href="{{ url_for('static', filename='favicon.ico') }}"
/>
<link
rel="shortcut icon"
href="{{ url_for('static', filename='favicon.ico') }}"
/>
<link rel="stylesheet" href="{{ url_for('static', filename='css/libs/normalize.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/popup.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/reader.css') }}">
</head>
<link
rel="stylesheet"
href="{{ url_for('static', filename='css/libs/normalize.css') }}"
/>
<link
rel="stylesheet"
href="{{ url_for('static', filename='css/main.css') }}"
/>
<link
rel="stylesheet"
href="{{ url_for('static', filename='css/popup.css') }}"
/>
<link
rel="stylesheet"
href="{{ url_for('static', filename='css/reader.css') }}"
/>
</head>
<body>
<body>
<div id="sidebar">
<div id="panels">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<!--input id="searchBox" placeholder="search" type="search"-->
<div id="panels">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<!--input id="searchBox" placeholder="search" type="search"-->
<!--a id="show-Search" class="show_view icon-search" data-view="Search">Search</a-->
<a id="show-Toc" class="show_view icon-list-1 active" data-view="Toc">TOC</a>
<a id="show-Bookmarks" class="show_view icon-bookmark" data-view="Bookmarks">Bookmarks</a>
<!--a id="show-Notes" class="show_view icon-edit" data-view="Notes">Notes</a-->
</div>
<div id="tocView" class="view">
</div>
<!--div id="searchView" class="view">
<!--a id="show-Search" class="show_view icon-search" data-view="Search">Search</a-->
<a id="show-Toc" class="show_view icon-list-1 active" data-view="Toc"
>TOC</a
>
<a
id="show-Bookmarks"
class="show_view icon-bookmark"
data-view="Bookmarks"
>Bookmarks</a
>
<!--a id="show-Notes" class="show_view icon-edit" data-view="Notes">Notes</a-->
</div>
<div id="tocView" class="view"></div>
<!--div id="searchView" class="view">
<ul id="searchResults"></ul>
</div-->
<div id="bookmarksView" class="view">
<ul id="bookmarks"></ul>
</div>
<!--div id="notesView" class="view">
<div id="bookmarksView" class="view">
<ul id="bookmarks"></ul>
</div>
<!--div id="notesView" class="view">
<div id="new-note">
<textarea id="note-text"></textarea>
<button id="note-anchor">Anchor</button>
@@ -49,172 +75,240 @@
</div-->
</div>
<div id="main">
<div id="titlebar">
<div id="opener">
<a id="slider" class="icon-menu">Menu</a>
</div>
<div id="metainfo">
<span id="book-title"></span>
<span id="title-seperator">&nbsp;&nbsp;&nbsp;&nbsp;</span>
<span id="chapter-title"></span>
</div>
<div id="title-controls">
<a id="bookmark" class="icon-bookmark-empty">Bookmark</a>
<a id="setting" class="icon-cog">Settings</a>
<a id="fullscreen" class="icon-resize-full">Fullscreen</a>
</div>
</div>
<div id="divider"></div>
<div id="prev" class="arrow"></div>
<div id="viewer"></div>
<div id="next" class="arrow"></div>
<div id="progress">0%</div>
<div id="loader"><img src="{{ url_for('static', filename='img/loader.gif') }}"></div>
</div>
<div class="modal md-effect-1" id="settings-modal">
<div class="md-content">
<h3>{{_('Settings')}}</h3>
<div class="form-group themes" id="themes">
{{_('Choose a theme below:')}}}<br />
<!-- Hardcoded a tick in the light theme button because it is the "default" theme. Need to find a way to do this dynamically on startup-->
<button type="button" id="lightTheme" class="lightTheme" onclick="selectTheme(this.id)"><span
id="lightSelected"></span>{{_('Light')}}</button>
<button type="button" id="darkTheme" class="darkTheme" onclick="selectTheme(this.id)"><span
id="darkSelected"> </span>{{_('Dark')}}</button>
<button type="button" id="sepiaTheme" class="sepiaTheme" onclick="selectTheme(this.id)"><span
id="sepiaSelected"> </span>{{_('Sepia')}}</button>
<button type="button" id="blackTheme" class="blackTheme" onclick="selectTheme(this.id)"><span
id="blackSelected"> </span>{{_('Black')}}</button>
</div>
<div class="form-group">
<p>
<input type="checkbox" id="sidebarReflow"
name="sidebarReflow">{{_('Reflow text when sidebars are open.')}}
</p>
</div>
<div class="form-group fontSizeWrapper">
<div class="slider">
<label for="fader">{{ _('Font Sizes') }}</label>
<input type="range" min="75" max="200" value="100" id="fontSizeFader" step="25">
</div>
</div>
<div class="font" id="font">
<label class="item">{{_('Font')}}:</label>
<button type="button" id="default" onclick="selectFont(this.id)"><span></span>{{_('Default')}}</button>
<button type="button" id="Yahei" onclick="selectFont(this.id)"><span></span>{{_('Yahei')}}</button>
<button type="button" id="SimSun" onclick="selectFont(this.id)"><span></span>{{_('SimSun')}}</button>
<button type="button" id="KaiTi" onclick="selectFont(this.id)"><span></span>{{_('KaiTi')}}</button>
<button type="button" id="Arial" onclick="selectFont(this.id)"><span></span>{{_('Arial')}}</button>
</div>
<div class="layou" id="layout">
<label class="item">{{ _('Spread') }}:</label>
<button type="button" id="spread" onclick="spread(this.id)"><span></span>{{_('Two columns')}}</button>
<button type="button" id="nonespread" onclick="spread(this.id)"><span></span>{{_('One column')}}</button>
</div>
<div class="closer icon-cancel-circled"></div>
<div id="titlebar">
<div id="opener">
<a id="slider" class="icon-menu">Menu</a>
</div>
<div id="metainfo">
<span id="book-title"></span>
<span id="title-seperator">&nbsp;&nbsp;&nbsp;&nbsp;</span>
<span id="chapter-title"></span>
</div>
<div id="title-controls">
<a id="bookmark" class="icon-bookmark-empty">Bookmark</a>
<a id="setting" class="icon-cog">Settings</a>
<a id="fullscreen" class="icon-resize-full">Fullscreen</a>
</div>
</div>
<div id="divider"></div>
<div id="prev" class="arrow"></div>
<div id="viewer"></div>
<div id="next" class="arrow"></div>
<div id="progress">0%</div>
<div id="loader">
<img src="{{ url_for('static', filename='img/loader.gif') }}" />
</div>
</div>
<div class="modal md-effect-1" id="settings-modal">
<div class="md-content">
<h3>{{_('Settings')}}</h3>
<div class="form-group themes" id="themes">
{{_('Choose a theme below:')}}}<br />
<!-- Hardcoded a tick in the light theme button because it is the "default" theme. Need to find a way to do this dynamically on startup-->
<button
type="button"
id="lightTheme"
class="lightTheme"
onclick="selectTheme(this.id)"
>
<span id="lightSelected"></span>{{_('Light')}}
</button>
<button
type="button"
id="darkTheme"
class="darkTheme"
onclick="selectTheme(this.id)"
>
<span id="darkSelected"> </span>{{_('Dark')}}
</button>
<button
type="button"
id="sepiaTheme"
class="sepiaTheme"
onclick="selectTheme(this.id)"
>
<span id="sepiaSelected"> </span>{{_('Sepia')}}
</button>
<button
type="button"
id="amberTheme"
class="amberTheme"
onclick="selectTheme(this.id)"
>
<span id="amberSelected"> </span>{{_('Amber')}}
</button>
<button
type="button"
id="blackTheme"
class="blackTheme"
onclick="selectTheme(this.id)"
>
<span id="blackSelected"> </span>{{_('Black')}}
</button>
</div>
<div class="form-group">
<p>
<input
type="checkbox"
id="sidebarReflow"
name="sidebarReflow"
/>{{_('Reflow text when sidebars are open.')}}
</p>
</div>
<div class="form-group fontSizeWrapper">
<div class="slider">
<label for="fader">{{ _('Font Sizes') }}</label>
<input
type="range"
min="75"
max="200"
value="100"
id="fontSizeFader"
step="25"
/>
</div>
</div>
<div class="font" id="font">
<label class="item">{{_('Font')}}:</label>
<button type="button" id="default" onclick="selectFont(this.id)">
<span></span>{{_('Default')}}
</button>
<button type="button" id="Yahei" onclick="selectFont(this.id)">
<span></span>{{_('Yahei')}}
</button>
<button type="button" id="SimSun" onclick="selectFont(this.id)">
<span></span>{{_('SimSun')}}
</button>
<button type="button" id="KaiTi" onclick="selectFont(this.id)">
<span></span>{{_('KaiTi')}}
</button>
<button type="button" id="Arial" onclick="selectFont(this.id)">
<span></span>{{_('Arial')}}
</button>
</div>
<div class="layou" id="layout">
<label class="item">{{ _('Spread') }}:</label>
<button type="button" id="spread" onclick="spread(this.id)">
<span></span>{{_('Two columns')}}
</button>
<button type="button" id="nonespread" onclick="spread(this.id)">
<span></span>{{_('One column')}}
</button>
</div>
<div class="closer icon-cancel-circled"></div>
</div>
</div>
<div class="overlay"></div>
<script src="{{ url_for('static', filename='js/libs/jquery.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/compress/jszip_epub.min.js') }}">
</script>
<script src="{{ url_for('static', filename='js/compress/jszip_epub.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/epub.min.js') }}"></script>
<script type="text/javascript">
window.calibre = {
filePath: "{{ url_for('static', filename='js/libs/') }}",
cssPath: "{{ url_for('static', filename='css/') }}",
bookmarkUrl: "{{ url_for('web.set_bookmark', book_id=bookid, book_format=book_format) }}",
bookUrl: "{{ url_for('web.serve_book', book_id=bookid, book_format=book_format, anyname='file.epub') }}",
bookmark: "{{ bookmark.bookmark_key if bookmark != None }}",
useBookmarks: "{{ current_user.is_authenticated | tojson }}"
};
window.calibre = {
filePath: "{{ url_for('static', filename='js/libs/') }}",
cssPath: "{{ url_for('static', filename='css/') }}",
bookmarkUrl:
"{{ url_for('web.set_bookmark', book_id=bookid, book_format=book_format) }}",
bookUrl:
"{{ url_for('web.serve_book', book_id=bookid, book_format=book_format, anyname='file.epub') }}",
bookmark: "{{ bookmark.bookmark_key if bookmark != None }}",
useBookmarks: "{{ current_user.is_authenticated | tojson }}",
};
window.themes = {
"darkTheme": {
"bgColor": "#202124",
"css_path": "{{ url_for('static', filename='css/epub_themes.css') }}",
"title-color": "#fff"
},
"lightTheme": {
"bgColor": "white",
"css_path": "{{ url_for('static', filename='css/epub_themes.css') }}",
"title-color": "#4f4f4f"
},
"sepiaTheme": {
"bgColor": "#ece1ca",
"css_path": "{{ url_for('static', filename='css/epub_themes.css') }}",
"title-color": "#4f4f4f"
},
"blackTheme": {
"bgColor": "black",
"css_path": "{{ url_for('static', filename='css/epub_themes.css') }}",
"title-color": "#fff"
},
};
window.themes = {
darkTheme: {
bgColor: "#202124",
css_path: "{{ url_for('static', filename='css/epub_themes.css') }}",
"title-color": "#fff",
},
lightTheme: {
bgColor: "white",
css_path: "{{ url_for('static', filename='css/epub_themes.css') }}",
"title-color": "#4f4f4f",
},
sepiaTheme: {
bgColor: "#ece1ca",
css_path: "{{ url_for('static', filename='css/epub_themes.css') }}",
"title-color": "#4f4f4f",
},
amberTheme: {
bgColor: "#e8bf5e",
css_path: "{{ url_for('static', filename='css/epub_themes.css') }}",
"title-color": "#4f4f4f",
},
blackTheme: {
bgColor: "black",
css_path: "{{ url_for('static', filename='css/epub_themes.css') }}",
"title-color": "#fff",
},
};
function selectTheme (id) {
let tickSpans = document.getElementById("themes").querySelectorAll("span");
function selectTheme(id) {
let tickSpans = document
.getElementById("themes")
.querySelectorAll("span");
// Remove tick mark from all theme buttons
tickSpans.forEach(function (tickSpan) {
document.getElementById(tickSpan.id).textContent = "";
});
// Add tick mark to the button corresponding to the currently selected theme
document.getElementById(id).querySelector("span").textContent = "✓";
// Saving theme to local storage
localStorage.setItem("calibre.reader.theme", id);
// Apply theme to epubjs iframe
reader.rendition.themes.select(id);
// Apply theme to rest of the page.
document.getElementById("main").style.backgroundColor = themes[id]["bgColor"];
document.getElementById("titlebar").style.color = themes[id]["title-color"] || "#fff";
document.getElementById("progress").style.color = themes[id]["title-color"] || "#fff";
}
// font size settings logic
let fontSizeFader = document.getElementById('fontSizeFader');
fontSizeFader.addEventListener("change", function () {
reader.rendition.themes.fontSize(`${this.value}%`);
// Remove tick mark from all theme buttons
tickSpans.forEach(function (tickSpan) {
document.getElementById(tickSpan.id).textContent = "";
});
let defaultFont;
// Add tick mark to the button corresponding to the currently selected theme
document.getElementById(id).querySelector("span").textContent = "✓";
function selectFont(id) {
if (!defaultFont) {
defaultFont = reader.rendition.getContents()[0]?.css('font-family');
}
// Saving theme to local storage
localStorage.setItem("calibre.reader.theme", id);
spans = document.getElementById("font").querySelectorAll("span");
for(var i = 0; i < spans.length; i++) {
spans[i].textContent = "";
}
document.getElementById(id).querySelector("span").textContent = "✓";
if (id == 'default') {
reader.rendition.themes.font(defaultFont);
return;
}
reader.rendition.themes.font(id);
// Apply theme to epubjs iframe
reader.rendition.themes.select(id);
// Apply theme to rest of the page.
document.getElementById("main").style.backgroundColor =
themes[id]["bgColor"];
document.getElementById("titlebar").style.color =
themes[id]["title-color"] || "#fff";
document.getElementById("progress").style.color =
themes[id]["title-color"] || "#fff";
}
// font size settings logic
let fontSizeFader = document.getElementById("fontSizeFader");
fontSizeFader.addEventListener("change", function () {
reader.rendition.themes.fontSize(`${this.value}%`);
});
let defaultFont;
function selectFont(id) {
if (!defaultFont) {
defaultFont = reader.rendition.getContents()[0]?.css("font-family");
}
function spread(id) {
spans = document.getElementById("layout").querySelectorAll("span");
for(var i = 0; i < spans.length; i++) {
spans[i].textContent = "";
}
document.getElementById(id).querySelector("span").textContent = "✓";
reader.rendition.spread(id==='spread'?true:'none');
spans = document.getElementById("font").querySelectorAll("span");
for (var i = 0; i < spans.length; i++) {
spans[i].textContent = "";
}
</script>
<script src="{{ url_for('static', filename='js/libs/screenfull.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/reader.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/reading/epub.js') }}"></script>
</body>
document.getElementById(id).querySelector("span").textContent = "✓";
if (id == "default") {
reader.rendition.themes.font(defaultFont);
return;
}
reader.rendition.themes.font(id);
}
function spread(id) {
spans = document.getElementById("layout").querySelectorAll("span");
for (var i = 0; i < spans.length; i++) {
spans[i].textContent = "";
}
document.getElementById(id).querySelector("span").textContent = "✓";
reader.rendition.spread(id === "spread" ? true : "none");
}
</script>
<script src="{{ url_for('static', filename='js/libs/screenfull.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/reader.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/reading/epub.js') }}"></script>
</body>
</html>