Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Commit

Permalink
Implement progress lookup via the bookmark API
Browse files Browse the repository at this point in the history
Big thanks to DarkShadowSwE for his example implementation!
  • Loading branch information
scooterpsu committed Mar 25, 2019
1 parent 35797cf commit 0881bea
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 7 deletions.
31 changes: 25 additions & 6 deletions comixology2/comixology.css
Original file line number Diff line number Diff line change
Expand Up @@ -1514,23 +1514,42 @@ footer a {
margin-top: 10px;
}

.lv2-item-progress[value] {
.bookmarks .lv2-item-progress[value] {
position: absolute;
z-index: 3;
display: none;
width: 175px;
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;
Expand Down Expand Up @@ -1931,8 +1950,8 @@ strong, b {

#buttonBox {
position: absolute;
right: 15px;
top: 16px;
right: 19px;
top: 18px;
display: block;
}

Expand Down
47 changes: 46 additions & 1 deletion comixology2/themeScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 += '<a class="action-button read-action primary-action" href="#" onclick="readBook('+readLink[0]+', \''+proxyPrefix+'/\', \''+readLink[1]+'\')"><div class="title-container"><span class="action-title">Read</span></div></a>'
}
Expand Down Expand Up @@ -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){
$('<div>').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('/');
Expand Down

0 comments on commit 0881bea

Please sign in to comment.