Skip to content

Commit d79dd8f

Browse files
committed
Make progress div independent from new/completed emojis in thumbnail view
1 parent 052f215 commit d79dd8f

File tree

2 files changed

+36
-15
lines changed

2 files changed

+36
-15
lines changed

public/js/common.js

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ LRR.buildThumbnailDiv = function (data, tagTooltip = true) {
301301
// Don't enforce no_fallback=true here, we don't want those divs to trigger Minion jobs
302302
return `<div class="id1 context-menu swiper-slide" id="${id}">
303303
<div class="id2">
304-
${LRR.buildProgressDiv(data)}
304+
${LRR.buildStatusDiv(data)}
305305
<a href="${reader_url}" title="${LRR.encodeHTML(data.title)}">${LRR.encodeHTML(data.title)}</a>
306306
</div>
307307
<div class="${thumbCss}">
@@ -315,20 +315,49 @@ LRR.buildThumbnailDiv = function (data, tagTooltip = true) {
315315
${bookmarkIcon}
316316
</div>
317317
<div class="id4">
318+
${LRR.buildPageCountDiv(data)}
318319
<span class="tags tag-tooltip" ${tagTooltip === true ? "onmouseover=\"IndexTable.buildTagTooltip(this)\"" : ""}>${LRR.colorCodeTags(data.tags)}</span>
319320
${tagTooltip === true ? `<div class="caption caption-tags" style="display: none;" >${LRR.buildTagsDiv(data.tags)}</div>` : ""}
320321
</div>
321322
</div>`;
322323
};
323324

324325
/**
325-
* Show an emoji or a progress number for the given archive data.
326+
* Show an emoji for the given archive data.
326327
* @param {*} arcdata The archive data object
327328
* @returns HTML string
328329
*/
329-
LRR.buildProgressDiv = function (arcdata) {
330-
const id = arcdata.arcid;
330+
LRR.buildStatusDiv = function (arcdata) {
331331
const { isnew } = arcdata;
332+
let { progress, pagecount } = LRR.getProgress(arcdata);
333+
334+
if (isnew === "true") {
335+
return "<div class='isnew'>🆕</div>";
336+
} else if (pagecount > 0 && (progress / pagecount) > 0.85) { // Consider an archive read if progress is past 85% of total
337+
return "<div class='isnew'>👑</div>";
338+
}
339+
// If there wasn't sufficient data, return an empty string
340+
return "";
341+
};
342+
343+
LRR.buildPageCountDiv = function (arcdata) {
344+
345+
// TODO - This might evolve with Tanks to show the amount of IDs in the tank with total pagecount on hover
346+
let { progress, pagecount } = LRR.getProgress(arcdata);
347+
if (pagecount > 0) {
348+
return `<div class='isnew'><sup>${progress}/${pagecount}</sup></div>`;
349+
}
350+
return "";
351+
};
352+
353+
/**
354+
* Get the progress and pagecount for the given archive data, considering localStorage if needed.
355+
* @param {*} arcdata The archive data object
356+
* @returns progress and pagecount
357+
*/
358+
LRR.getProgress = function (arcdata) {
359+
const id = arcdata.arcid;
360+
332361
const pagecount = parseInt(arcdata.pagecount || 0, 10);
333362
let progress = -1;
334363

@@ -338,16 +367,8 @@ LRR.buildProgressDiv = function (arcdata) {
338367
progress = parseInt(arcdata.progress || 0, 10);
339368
}
340369

341-
if (isnew === "true") {
342-
return "<div class=\"isnew\">🆕</div>";
343-
} else if (pagecount > 0) {
344-
// Consider an archive read if progress is past 85% of total
345-
if ((progress / pagecount) > 0.85) return "<div class='isnew'>👑</div>";
346-
else return `<div class='isnew'><sup>${progress}/${pagecount}</sup></div>`;
347-
}
348-
// If there wasn't sufficient data, return an empty string
349-
return "";
350-
};
370+
return { progress, pagecount };
371+
}
351372

352373
/**
353374
* Show a generic error toast with a given header and message.

public/js/index_datatables.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ IndexTable.renderTitle = function (data, type) {
179179
// For compact mode, the thumbnail API call enforces no_fallback=true in order to queue Minion jobs for missing thumbnails.
180180
// (Since compact mode is the "base", it's always loaded first even if you're in table mode)
181181
const bookmarkIcon = LRR.buildBookmarkIconElement(data.arcid, "title-bookmark-icon");
182-
return `${LRR.buildProgressDiv(data)}${bookmarkIcon}<a id="${data.arcid}" onmouseover="IndexTable.buildImageTooltip(this)" href="${new LRR.apiURL(`/reader?id=${data.arcid}`)}">
182+
return `${LRR.buildPageCountDiv(data)}${bookmarkIcon}<a id="${data.arcid}" onmouseover="IndexTable.buildImageTooltip(this)" href="${new LRR.apiURL(`/reader?id=${data.arcid}`)}">
183183
${LRR.encodeHTML(data.title)}
184184
</a>
185185
<div class="caption" style="display: none;">

0 commit comments

Comments
 (0)