1
0
mirror of https://github.com/janeczku/calibre-web synced 2025-01-30 02:44:47 +00:00

added function to get bytelength of book text

This commit is contained in:
quarz12 2023-05-14 18:01:02 +02:00
parent c7e1736ade
commit c29b1696f7

View File

@ -78,14 +78,19 @@
Choose a theme below: <br/> 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--> <!-- 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="lightTheme" class="lightTheme" onclick="selectTheme(this.id)"><span
<button type="button" id="darkTheme" class="darkTheme" onclick="selectTheme(this.id)"><span id="darkSelected"> </span>{{_('Dark')}}</button> id="lightSelected">✓</span>{{ _('Light') }}</button>
<button type="button" id="sepiaTheme" class="sepiaTheme" onclick="selectTheme(this.id)"><span id="sepiaSelected"> </span>{{_('Sepia')}}</button> <button type="button" id="darkTheme" class="darkTheme" onclick="selectTheme(this.id)"><span
<button type="button" id="blackTheme" class="blackTheme" onclick="selectTheme(this.id)"><span id="blackSelected"> </span>{{_('Black')}}</button> 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>
<div> <div>
<p> <p>
<input type="checkbox" id="sidebarReflow" name="sidebarReflow">{{_('Reflow text when sidebars are open.')}} <input type="checkbox" id="sidebarReflow"
name="sidebarReflow">{{ _('Reflow text when sidebars are open.') }}
</p> </p>
</div> </div>
<div class="fontSizeWrapper"> <div class="fontSizeWrapper">
@ -100,7 +105,8 @@
<div class="overlay"></div> <div class="overlay"></div>
<script src="{{ url_for('static', filename='js/libs/jquery.min.js') }}"></script> <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 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>
<script src="{{ url_for('static', filename='js/libs/epub.min.js') }}"></script>
<script type="text/javascript"> <script type="text/javascript">
window.calibre = { window.calibre = {
filePath: "{{ url_for('static', filename='js/libs/') }}", filePath: "{{ url_for('static', filename='js/libs/') }}",
@ -128,14 +134,11 @@
// Apply theme to rest of the page. TODO - Do this smarter // Apply theme to rest of the page. TODO - Do this smarter
if (id == "darkTheme") { if (id == "darkTheme") {
document.getElementById("main").style.backgroundColor = "#202124"; document.getElementById("main").style.backgroundColor = "#202124";
} } else if (id == "lightTheme") {
else if (id == "lightTheme") {
document.getElementById("main").style.backgroundColor = "white"; document.getElementById("main").style.backgroundColor = "white";
} } else if (id == "sepiaTheme") {
else if (id == "sepiaTheme") {
document.getElementById("main").style.backgroundColor = "#ece1ca"; document.getElementById("main").style.backgroundColor = "#ece1ca";
} } else if (id == "blackTheme") {
else if (id == "blackTheme") {
document.getElementById("main").style.backgroundColor = "black"; document.getElementById("main").style.backgroundColor = "black";
} }
@ -150,5 +153,18 @@
<script src="{{ url_for('static', filename='js/libs/screenfull.min.js') }}"></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/libs/reader.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/reading/epub.js') }}"></script> <script src="{{ url_for('static', filename='js/reading/epub.js') }}"></script>
<script>
function getTextByteLength() {
let size = 0;
const files = reader.rendition.book.archive.zip.files;
for (let key in y = Object.keys(files)) {
let file = files[y[key]];
if (file.name.endsWith(".html")) {
size += file._data.uncompressedSize;
}
}
return size;
}
</script>
</body> </body>
</html> </html>