From d73ed30d76a5abd7dbfc15202f432f83a79f99ac Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 8 Oct 2020 16:59:23 +0300 Subject: gulp stuff: themes --- dist/app.min.css | 2 +- dist/app.min.js | 2 +- dist/reader_iframe.min.css | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'dist') diff --git a/dist/app.min.css b/dist/app.min.css index ccf4711..61e4d60 100644 --- a/dist/app.min.css +++ b/dist/app.min.css @@ -1 +1 @@ -body.epube-index .caption div,body.epube-reader .footer .chapter_wrapper,body.epube-reader .header .title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}body.epube-index .display-flex{display:flex;flex-wrap:wrap}body.epube-index .separate-search{padding:8px}body.epube-index .row>div{padding-top:10px}body.epube-index .row .thumbnail{height:200px;width:140px;margin-bottom:0}@media (max-width:641px){body.epube-index .row .col-xxs-6{width:50%}}body.epube-index .row .thumbnail img{width:100%;height:100%;background-size:cover;background-position:center;background-repeat:no-repeat}body.epube-index .row .thumbnail.read img{opacity:.5;filter:grayscale(100%)}body.epube-index .epube-app-filler{height:60px;display:none}body.epube-index .in_progress{font-style:italic}body.epube-index ::selection{background:#007d71;color:#fff}body.epube-index ::-webkit-scrollbar{width:4px}body.epube-index ::-webkit-scrollbar-thumb{background-color:#007d71}body.epube-index ::-webkit-scrollbar-track{background-color:#eee}body.epube-reader .loading{position:absolute;color:#999;top:0;left:0;height:100%;width:100%;z-index:32;text-align:center;background:#fff;padding:16px;font-size:18px;display:table}body.epube-reader .loading>div{display:table-cell;vertical-align:middle}body.epube-reader .notice{width:120px;padding-left:5px}body.epube-reader .header{top:5px;left:0;width:100%;height:24px}body.epube-reader .footer{bottom:5px;left:0;width:100%;height:24px}body.epube-reader .footer,body.epube-reader .header{position:absolute;font-size:13px;display:flex;padding-left:10px;padding-right:10px;color:#999;align-items:center}body.epube-reader .header .title{margin-left:10px;flex-grow:2;text-align:center;font-weight:700}body.epube-reader .footer .chapter_wrapper{padding-right:10px;cursor:pointer}body.epube-reader .footer .spacer{flex-grow:2;position:relative;height:12px}body.epube-reader .footer .spacer .toc-bar-entry{position:absolute;background:#999;top:0;bottom:0;width:1px}body.epube-reader .footer .spacer .toc-bar-entry.current-position{background:#C33}body.epube-reader .footer .location{cursor:pointer;text-align:right}@media (max-width:539px){body.epube-reader .spacer>.toc-bar-entry{display:none}}@media (min-width:540px){body.epube-reader .footer .chapter_wrapper,body.epube-reader .footer .location{width:25%}}@media (min-width:800px){body.epube-reader .footer .chapter_wrapper,body.epube-reader .footer .location{width:20%}}body.epube-reader .toolbar{text-align:right;display:flex;flex-direction:row}body.epube-reader .toolbar>*{cursor:pointer;margin:0 4px;padding:0 2px}body.epube-reader .toolbar>:last-child{margin-right:0}body.epube-reader #reader{position:absolute;top:32px;bottom:32px;left:32px;right:32px}body.epube-reader #left,body.epube-reader #right{position:absolute;top:48px;bottom:48px;width:0;z-index:10}body.epube-reader #left{left:0}body.epube-reader #right{right:0}@media (max-width:576px){body.epube-reader #reader{left:24px;right:24px}}body.epube-reader .chapter{cursor:pointer}body.epube-reader .dict_result,body.epube-reader .search_results,body.epube-reader .toc_list{max-height:300px;height:auto;overflow:auto}body.epube-reader .dict_result h1,body.epube-reader .dict_result h2,body.epube-reader .dict_result h3{font-size:14px;margin-top:0}body.epube-reader .dict_result h2{font-weight:700}body.epube-reader .search_results b.pull-right,body.epube-reader .toc_list b.pull-right{margin-right:8px;margin-left:16px}body.epube-reader .toc_sublist{margin-left:16px}body.epube-reader ::-webkit-scrollbar{width:4px}body.epube-reader ::-webkit-scrollbar-thumb{background-color:rgba(0,0,0,.2)}body.epube-reader ::-webkit-scrollbar-track{background-color:rgba(0,0,0,.1)}body.is-epube-app.epube-reader .header .toolbar,body.is-epube-app.epube-reader .header a{display:none} \ No newline at end of file +body.epube-index .caption div,body.epube-reader .footer .chapter_wrapper,body.epube-reader .header .title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}body.epube-index .display-flex{display:flex;flex-wrap:wrap}body.epube-index .separate-search{padding:8px}body.epube-index .row>div{padding-top:10px}body.epube-index .row .thumbnail{height:200px;width:140px;margin-bottom:0}@media (max-width:641px){body.epube-index .row .col-xxs-6{width:50%}}body.epube-index .row .thumbnail img{width:100%;height:100%;background-size:cover;background-position:center;background-repeat:no-repeat}body.epube-index .row .thumbnail.read img{opacity:.5;filter:grayscale(100%)}body.epube-index .epube-app-filler{height:60px;display:none}body.epube-index .in_progress{font-style:italic}body.epube-index ::selection{background:#007d71;color:#fff}body.epube-index ::-webkit-scrollbar{width:4px}body.epube-index ::-webkit-scrollbar-thumb{background-color:#007d71}body.epube-index ::-webkit-scrollbar-track{background-color:#eee}body.epube-reader .loading{position:absolute;color:#999;top:0;left:0;height:100%;width:100%;z-index:32;text-align:center;background:#fff;padding:16px;font-size:18px;display:table}body.epube-reader .loading>div{display:table-cell;vertical-align:middle}body.epube-reader .notice{width:120px;padding-left:5px}body.epube-reader .header{top:5px;left:0;width:100%;height:24px}body.epube-reader .footer{bottom:5px;left:0;width:100%;height:24px}body.epube-reader .footer,body.epube-reader .header{position:absolute;font-size:13px;display:flex;padding-left:10px;padding-right:10px;color:#999;align-items:center}body.epube-reader .header .title{margin-left:10px;flex-grow:2;text-align:center;font-weight:700}body.epube-reader .footer .chapter_wrapper{padding-right:10px;cursor:pointer}body.epube-reader .footer .spacer{flex-grow:2;position:relative;height:12px}body.epube-reader .footer .spacer .toc-bar-entry{position:absolute;background:#999;top:0;bottom:0;width:1px}body.epube-reader .footer .spacer .toc-bar-entry.current-position{background:#C33}body.epube-reader .footer .location{cursor:pointer;text-align:right}@media (max-width:539px){body.epube-reader .spacer>.toc-bar-entry{display:none}}@media (min-width:540px){body.epube-reader .footer .chapter_wrapper,body.epube-reader .footer .location{width:25%}}@media (min-width:800px){body.epube-reader .footer .chapter_wrapper,body.epube-reader .footer .location{width:20%}}body.epube-reader .toolbar{text-align:right;display:flex;flex-direction:row}body.epube-reader .toolbar>*{cursor:pointer;margin:0 4px;padding:0 2px}body.epube-reader .toolbar>:last-child{margin-right:0}body.epube-reader #reader{position:absolute;top:32px;bottom:32px;left:32px;right:32px}body.epube-reader #left,body.epube-reader #right{position:absolute;top:48px;bottom:48px;width:0;z-index:10}body.epube-reader #left{left:0}body.epube-reader #right{right:0}@media (max-width:576px){body.epube-reader #reader{left:24px;right:24px}}body.epube-reader .chapter{cursor:pointer}body.epube-reader .dict_result,body.epube-reader .search_results,body.epube-reader .toc_list{max-height:300px;height:auto;overflow:auto}body.epube-reader .dict_result h1,body.epube-reader .dict_result h2,body.epube-reader .dict_result h3{font-size:14px;margin-top:0}body.epube-reader .dict_result h2{font-weight:700}body.epube-reader .search_results b.pull-right,body.epube-reader .toc_list b.pull-right{margin-right:8px;margin-left:16px}body.epube-reader .toc_sublist{margin-left:16px}body.epube-reader ::-webkit-scrollbar{width:4px}body.epube-reader ::-webkit-scrollbar-thumb{background-color:rgba(0,0,0,.2)}body.epube-reader ::-webkit-scrollbar-track{background-color:rgba(0,0,0,.1)}body.is-epube-app.epube-reader .header .toolbar,body.is-epube-app.epube-reader .header a{display:none}@media (prefers-color-scheme:dark){body.theme-default,body.theme-default .loading,body.theme-default html:-webkit-full-screen{background:#222;color:#ccc}body.theme-default .modal{color:#333}}body.theme-gray,body.theme-gray .loading,body.theme-gray html:-webkit-full-screen{background:#eee;color:#424242}body.theme-gray .footer,body.theme-gray .header{color:#B85C57}body.theme-gray .footer .spacer .toc-bar-entry.current-position{background:#B85C57}body.theme-light .no-op{color:#fff}body.theme-mocca,body.theme-mocca .loading,body.theme-mocca html:-webkit-full-screen{background:#3B3228;color:#D0C8C6}body.theme-mocca a{color:#8AB3B5}body.theme-mocca a:hover{color:#7BBDA4}body.theme-mocca .footer,body.theme-mocca .header{color:#F4BC87}body.theme-mocca .footer .location{color:#BEB55B}body.theme-mocca .header button.btn{background:#BB9584;color:#534636;text-shadow:#534636 0 0;border-color:#534636}body.theme-mocca .footer .spacer .toc-bar-entry.current-position{background:#F4BC87}body.theme-night,body.theme-night .loading,body.theme-night html:-webkit-full-screen{background:#222;color:#ccc}body.theme-night a,body.theme-night a:hover{color:#00bdaa}body.theme-night .modal{color:#333}body.theme-night .footer .spacer .toc-bar-entry.current-position{background:#8b0000}body.theme-plan9,body.theme-plan9 .loading,body.theme-plan9 html:-webkit-full-screen{background:#FFFFE8;color:#424242}body.theme-plan9 a{color:#22b9b2}body.theme-plan9 a:hover{color:#28d7cf}body.theme-plan9 .footer,body.theme-plan9 .header{color:#B85C57}body.theme-plan9 .footer .spacer .toc-bar-entry.current-position{background:#B85C57}body.theme-sepia,body.theme-sepia .loading,body.theme-sepia html:-webkit-full-screen{background:#FAEFDB;color:#4a422b}body.theme-sepia .footer,body.theme-sepia .header{color:#B85C57}body.theme-sepia .footer .spacer .toc-bar-entry.current-position{background:#B85C57} \ No newline at end of file diff --git a/dist/app.min.js b/dist/app.min.js index 352db5e..5b4b8f2 100644 --- a/dist/app.min.js +++ b/dist/app.min.js @@ -1 +1 @@ -"use strict";$.urlParam=function(e){try{const t=new RegExp("[?&]"+e+"=([^&#]*)").exec(window.location.href);return decodeURIComponent(t[1].replace(/\+/g," "))||0}catch(e){return 0}};const Cookie={set:function(e,t,o){const n=new Date;n.setTime(n.getTime()+1e3*o);const a="expires="+n.toUTCString();document.cookie=e+"="+encodeURIComponent(t)+"; "+a},get:function(e){e+="=";const t=document.cookie.split(";");for(let o=0;o{if((t=$(t)).attr("data-cover-link")){const e=$("").on("load",(function(){t.css("background-image","url("+t.attr("data-cover-link")+")").fadeIn(),e.attr("src",null)})).attr("src",t.attr("data-cover-link"))}else t.attr("src","holder.js/130x190?auto=yes").fadeIn()}),Holder.run()},toggleFavorite:function(e){const t=e.getAttribute("data-book-id");return("0"==e.getAttribute("data-is-fav")||confirm("Remove favorite?"))&&$.post("backend.php",{op:"togglefav",id:t},(function(o){if(o){let n="[Error]";0==o.status?n="Add to favorites":1==o.status&&(n="Remove from favorites"),$(e).html(n).attr("data-is-fav",o.status),"favorites"==App.index_mode&&0==o.status&&$("#cell-"+t).remove()}})),!1},refreshCache:function(e){"serviceWorker"in navigator?localforage.getItem("epube.cache-timestamp").then((function(t){(e||t!=App.last_mtime)&&(console.log("asking worker to refresh cache"),navigator.serviceWorker.controller?navigator.serviceWorker.controller.postMessage("refresh-cache"):localforage.getItem("epube.initial-load-done").then((function(e){console.log("initial load done",e),e?$(".dl-progress").show().addClass("alert-danger").html("Could not communicate with service worker. Try reloading the page."):localforage.setItem("epube.initial-load-done",!0).then((function(){$(".dl-progress").show().addClass("alert-info").html("Page will reload to activate service worker..."),window.setTimeout((function(){window.location.reload()}),3e3)}))})))})):$(".dl-progress").show().addClass("alert-danger").html("Could not communicate with service worker. Try reloading the page.")},appCheckOffline:function(){EpubeApp.setOffline(!navigator.onLine)},initOfflineEvents:function(){"undefined"!=typeof EpubeApp&&($(window).on("online",(function(){EpubeApp.setOffline(!1)})),$(window).on("offline",(function(){EpubeApp.setOffline(!0)})),EpubeApp.setOffline(!navigator.onLine))},initNightMode:function(){if("undefined"==typeof EpubeApp){if(window.matchMedia){const e=window.matchMedia("(prefers-color-scheme: dark)");e.addEventListener("change",()=>{App.applyNightMode(e.matches)}),App.applyNightMode(e.matches)}}else App.applyNightMode(EpubeApp.isNightMode())},applyNightMode:function(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"))},Offline:{init:function(){"undefined"!=typeof EpubeApp&&($(".navbar").hide(),$(".epube-app-filler").show(),EpubeApp.setPage("PAGE_OFFLINE")),App.initNightMode(),App.initOfflineEvents();const e=$.urlParam("query");e&&$(".search_query").val(e),App.Offline.populateList()},get:function(e,t){console.log("offline cache: "+e),$.post("backend.php",{op:"getinfo",id:e},(function(o){if(o){const n="epube-book."+e;localforage.setItem(n,o).then((function(o){console.log(n+" got data");const a=[];a.push(fetch("backend.php?op=download&id="+o.epub_id,{credentials:"same-origin"}).then((function(e){200==e.status&&(console.log(n+" got book"),t(),localforage.setItem(n+".book",e.blob()))}))),a.push(fetch("backend.php?op=getpagination&id="+o.epub_id,{credentials:"same-origin"}).then((function(e){200==e.status&&(console.log(n+" got pagination"),e.text().then((function(e){localforage.setItem(n+".locations",JSON.parse(e))})))}))),a.push(fetch("backend.php?op=getlastread&id="+o.epub_id,{credentials:"same-origin"}).then((function(e){200==e.status&&(console.log(n+" got lastread"),e.text().then((function(e){localforage.setItem(n+".lastread",JSON.parse(e))})))}))),o.has_cover&&a.push(fetch("backend.php?op=cover&id="+e,{credentials:"same-origin"}).then((function(e){200==e.status&&(console.log(n+" got cover"),localforage.setItem(n+".cover",e.blob()))}))),Promise.all(a).then((function(){$(".dl-progress").show().html("Finished downloading "+o.title+""),window.clearTimeout(App._dl_progress_timeout),App._dl_progress_timeout=window.setTimeout((function(){$(".dl-progress").fadeOut()}),5e3)}))}))}}))},getAll:function(){confirm("Download all books on this page?")&&$(".row > div").each((function(e,t){const o=$(t).attr("id").replace("cell-",""),n=$(t).find(".offline_dropitem")[0];if(o){const e="epube-book."+o;localforage.getItem(e).then((function(e){e||App.Offline.get(o,(function(){App.Offline.mark(n)}))}))}}))},markBooks:function(){const e=$(".offline_dropitem");$.each(e,(function(e,t){App.Offline.mark(t)}))},mark:function(e){const t=e.getAttribute("data-book-id"),o="epube-book."+t;localforage.getItem(o).then((function(o){o?(e.onclick=function(){return App.Offline.remove(t,(function(){App.Offline.mark(e)})),!1},e.innerHTML="Remove offline data"):(e.onclick=function(){return App.Offline.get(t,(function(){App.Offline.mark(e)})),!1},e.innerHTML="Make available offline")}))},removeFromList:function(e){const t=e.getAttribute("data-book-id");return App.Offline.remove(t,(function(){$("#cell-"+t).remove()}))},remove:function(e,t){if(confirm("Remove download?")){const o="epube-book."+e,n=[];console.log("offline remove: "+e),localforage.iterate((function(e,t){t.match(o)&&n.push(localforage.removeItem(t))})),Promise.all(n).then((function(){window.setTimeout((function(){t()}),500)}))}},search:function(){const e=$(".search_query").val();return localforage.setItem("epube.search-query",e).then((function(){App.Offline.populateList()})),!1},removeAll:function(){if(confirm("Remove all downloaded books?")){const e=[];localforage.iterate((function(t,o){o.match("epube-book")&&e.push(localforage.removeItem(o))})),Promise.all(e).then((function(){window.setTimeout((function(){App.Offline.populateList()}),500)}))}},showSummary:function(e){const t=e.getAttribute("data-book-id");return localforage.getItem("epube-book."+t).then((function(e){const t=e.comment?e.comment:"No description available";$("#summary-modal .modal-title").html(e.title),$("#summary-modal .book-summary").html(t),$("#summary-modal").modal()})),!1},populateList:function(){let e=$.urlParam("query");e&&(e=e.toLowerCase());const t=$("#books_container");t.html(""),localforage.iterate((function(o,n){n.match(/epube-book\.\d{1,}$/)&&Promise.all([localforage.getItem(n),localforage.getItem(n+".cover"),localforage.getItem(n+".lastread"),localforage.getItem(n+".book")]).then((function(o){if(o[0]&&o[3]){const n=o[0];if(e){if(!(n.series_name&&n.series_name.toLowerCase().match(e)||n.title&&n.title.toLowerCase().match(e)||n.author_sort&&n.author_sort.toLowerCase().match(e)))return}let a=!1;o&&o[1]&&(a=URL.createObjectURL(o[1]));let i=!1,r=!1;const l=o[2];l&&(i=l.page>0,r=l.total>0&&l.total-l.page<5);const c=r?"read":"",s=i?"in_progress":"",d=n.series_name?`
${n.series_name+" ["+n.series_index+"]"}
`:"",p=$(`
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
${n.title}
\n\t\t\t\t\t\t\t\t
${n.author_sort}
\n\t\t\t\t\t\t\t\t${d}\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
`);a?p.find("img").css("background-image","url("+a+")").fadeIn():p.find("img").attr("data-src","holder.js/130x190?auto=yes").fadeIn(),p.find(".series_link").attr("title",n.series_name+" ["+n.series_index+"]").attr("href","offline.html?query="+encodeURIComponent(n.series_name)),p.find(".author_link").attr("title",n.author_sort).attr("href","offline.html?query="+encodeURIComponent(n.author_sort)),t.append(p),Holder.run()}}))}))}}},DEFAULT_FONT_SIZE=16,DEFAULT_FONT_FAMILY="Georgia",DEFAULT_LINE_HEIGHT=140,MIN_LENGTH_TO_JUSTIFY=32,Reader={init:function(){$(document).on("keyup",(function(e){Reader.hotkeyHandler(e)})),$("#left").on("mouseup",(function(){Reader.Page.prev()})),$("#right").on("mouseup",(function(){Reader.Page.next()})),Reader.Loader.init()},initSecondStage:function(){"undefined"!=typeof EpubeApp&&EpubeApp.setPage("PAGE_READER"),Reader.applyTheme(),"true"==Cookie.get("is-epube-app")&&$("body").addClass("is-epube-app"),$(window).on("online",(function(){console.log("we're online, storing lastread");const t=e.rendition.currentLocation().start.cfi,o=parseInt(100*e.locations.percentageFromCfi(t));$.post("backend.php",{op:"storelastread",id:$.urlParam("id"),page:o,cfi:t},(function(e){e.cfi&&(Reader.Page._last_position_sync=(new Date).getTime()/1e3)})).fail((function(e){e&&401==e.status&&(window.location="index.php")}))})),localforage.getItem(Reader.cacheId("book")).then((function(t){if(/*!_is_ios &&*/t){console.log("loading from local storage");const o=new FileReader;o.onload=function(){try{e.open(this.result)}catch(e){$(".loading_message").html("Unable to load book (local)."),console.log(e)}},o.readAsArrayBuffer(t)}else if(console.log("loading from network"),navigator.onLine){const t="backend.php?op=download&id="+$.urlParam("id");$(".loading_message").html("Downloading..."),fetch(t,{credentials:"same-origin"}).then((function(t){if(200==t.status){const o=$.urlParam("b");t.blob().then((function(t){localforage.getItem(Reader.cacheId()).then((function(e){e||$.post("backend.php",{op:"getinfo",id:o},(function(e){e&&(localforage.setItem(Reader.cacheId(),e),e.has_cover&&fetch("backend.php?op=cover&id="+o,{credentials:"same-origin"}).then((function(e){200==e.status&&localforage.setItem(Reader.cacheId("cover"),e.blob())})))}))}));const n=new FileReader;n.onload=function(){e.open(this.result).then(()=>{localforage.setItem(Reader.cacheId("book"),t)}).catch(e=>{$(".loading_message").html("Unable to open book.
"+e+"")})},n.onerror=function(e){console.log("filereader error",e),$(".loading_message").html("Unable to open book.
"+e+"")},n.readAsArrayBuffer(t)})).catch(e=>{console.log("blob error",e),$(".loading_message").html("Unable to download book.
"+e+"")})}else $(".loading_message").html("Unable to download book: "+t.status+".")})).catch((function(e){console.warn(e),$(".loading").is(":visible")&&$(".loading_message").html("Unable to load book (remote).
"+e+"")}))}else $(".loading_message").html("This book is not available offline.")}));const e=ePub();window.book=e;const t=e.renderTo("reader",{width:"100%",height:"100%",minSpreadWidth:961});function o(t){try{const o=e.spine.get(t).cfiBase,n=e.locations._locations.find((function(e){return-1!=e.indexOf(o)}));return window.book.locations.locationFromCfi(n)}catch(e){console.warn(e)}return""}localforage.getItem("epube.enable-hyphens").then((function(e){e&&(Reader.hyphenateHTML=createHyphenator(hyphenationPatternsEnUs,{html:!0})),Reader.applyStyles(!0),t.display().then((function(){console.log("book displayed")}))})),t.hooks.content.register((function(t){t.on("linkClicked",(function(t){console.log("linkClicked",t),-1==t.indexOf("://")&&($(".prev_location_btn").attr("data-location-cfi",e.rendition.currentLocation().start.cfi).show(),window.setTimeout((function(){Reader.showUI(!0)}),50))}));const o=window.location.href.match(/^.*\//)[0],n=["dist/app-libs.min.js","js/reader_iframe.js"],a=t.document;for(let e=0;e").text(Reader.Loader._res_data[o+"dist/reader_iframe.min.css"])),localforage.getItem("epube.theme").then((function(e){e||(e="default");const n=o+"themes/"+e+".css";$(t.document.head).append($("