From: Radek Czajka Date: Mon, 5 Feb 2024 08:22:59 +0000 (+0100) Subject: fix X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/6db272cdb367187394dbb01e93e2e03dab14f9ab?ds=inline;hp=c36c3891e56611e2ad4c518daa46b8cc3f28188e fix --- diff --git a/src/wolnelektury/static/js/book_text/progress.js b/src/wolnelektury/static/js/book_text/progress.js new file mode 100644 index 000000000..8175de666 --- /dev/null +++ b/src/wolnelektury/static/js/book_text/progress.js @@ -0,0 +1,33 @@ +(function($){$(function(){ + + t = $('#global-progress').data('t'); + function upd_t() { + $text = $('#main-text #book-text'); + texttop = $text.offset().top; + + $footnotes = $('#footnotes', $text); + if ($footnotes.length) { + textbottom = $footnotes.offset().top; + } else { + textbottom = texttop + $text.height(); + } + + textlen = textbottom - texttop; + progress = (window.scrollY - texttop) / textlen; + progress = Math.max(0, Math.min(progress, 1)) + console.log('SCROLL BODY', progress); + + $('#global-progress .filled').css('right', (1 - progress) * 100 + '%'); + tleft = Math.round((1 - progress) * t / 60); + tt = ''; + if (tleft > 60) { + h = Math.floor(tleft / 60); + tt = h + ' h '; + tleft -= h * 60; + } + tt += tleft + ' min'; + $('#global-progress .progress-text-value').text(tt); + } + upd_t(); + $(window).scroll(upd_t); +})})(jQuery);