From 0881beab6cca35f0cee579e6d00251574ae9754f Mon Sep 17 00:00:00 2001 From: scooterpsu <3433982+scooterpsu@users.noreply.github.com> Date: Mon, 25 Mar 2019 09:03:25 -0400 Subject: [PATCH] Implement progress lookup via the bookmark API Big thanks to DarkShadowSwE for his example implementation! --- comixology2/comixology.css | 31 ++++++++++++++++++++----- comixology2/themeScript.js | 47 +++++++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 7 deletions(-) diff --git a/comixology2/comixology.css b/comixology2/comixology.css index 9ac98d6..83f0e49 100644 --- a/comixology2/comixology.css +++ b/comixology2/comixology.css @@ -1514,7 +1514,7 @@ footer a { margin-top: 10px; } -.lv2-item-progress[value] { +.bookmarks .lv2-item-progress[value] { position: absolute; z-index: 3; display: none; @@ -1522,15 +1522,34 @@ footer a { height: 4px; margin-top: 6px; margin-left: 13px; - cursor: pointer; vertical-align: middle; border: none; background-color: #ccc; -webkit-appearance: none; - -moz-appearance: none; - appearance: none; + -moz-appearance: none; + appearance: none; } +#group:not(.bookmarks) .lv2-item-progress[value] { + position: relative; + z-index: 3; + display: none; + width: 156px; + height: 4px; + vertical-align: middle; + border: none; + background-color: #ccc; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; +} + +#group:not(.bookmarks) .lv2-item-progress{ + display: block; + margin: 3px 0; +} + + #dimoverlay { position: fixed; z-index: 6; @@ -1931,8 +1950,8 @@ strong, b { #buttonBox { position: absolute; - right: 15px; - top: 16px; + right: 19px; + top: 18px; display: block; } diff --git a/comixology2/themeScript.js b/comixology2/themeScript.js index fa2d8ab..267a318 100644 --- a/comixology2/themeScript.js +++ b/comixology2/themeScript.js @@ -854,11 +854,16 @@ function fixPaths(parent, attr, extraPath){ function containerWrap(type){ if(!$('#group').hasClass('wrapped')){ $('#group').addClass('wrapped'); - $(".cellcontainer .label").each(function(){ + $(".cellcontainer .label").each(function(index){ if($(this).text() == "json"){ $(this).parent().parent().hide(); return } + if($(this).parent().parent().is('[id]')){ + //console.log($(this).parent().parent().attr('ID')); + }else{ + $(this).parent().parent().attr('ID', index); + } var fullLabel = $(this).text(); if(!displayTitleInsteadOfFileName){ var labelParts = parseLabel(fullLabel); @@ -877,6 +882,9 @@ function containerWrap(type){ var menuBlock = ''; var bookPath = $(this).parent().find('img').attr('src').split('?cover=true')[0]; var readLink = parseImgPath(bookPath); + if(readLink[1] == 'comicdetails'){ + checkBookmarkAPI(readLink, $(this).parent().parent().attr('ID')); + } if($(this).parent().find('a').attr('onclick') != ""){ menuBlock += '
Read
' } @@ -947,6 +955,43 @@ function containerWrap(type){ } } +function checkBookmarkAPI(returnval, containerID){ + var bookID = returnval[0]; + if(returnval[1]=='comicdetails'){ + var isBook = false; + }else{ + var isBook = true; + } + var markPage; + var pageCount; + $.ajax({ + type: "GET", + url: proxyPrefix+"/user-api/bookmark?isBook="+isBook+"&docId="+bookID, + }).done(function(data){ + if(data != undefined){ + if(data.mark != "0"){ + if(data.mark.indexOf('#') > -1){ + data.mark = data.mark.split('#')[0]; + } + markPage = +data.mark + 1; + $('#'+containerID).find('progress').attr('value',markPage); + $.ajax({ + type: "GET", + url: proxyPrefix+"/"+returnval[1]+"/"+bookID, + }).done(function(bookData){ + $('
').html(bookData).promise().done(function (ajaxReturn){ + var sizeReturn = $(ajaxReturn).find('#details_size')[0]; + pageCount = $(sizeReturn).text().split(' pages')[0]; + $('#'+containerID).find('progress').attr('max',pageCount); + $('#'+containerID).find('progress').attr('title', 'Page ' +markPage + ' of ' + pageCount); + $('#'+containerID).find('progress').css('display', 'block'); + }); + }); + } + } + }); +} + function cacheID(srcURL, labelText, parentURL){ var srcParts = srcURL.split('/'); var parentParts = parentURL.split('/');