Skip to content

Commit fd3a162

Browse files
committed
sync LRR frontend v0.9.0
1 parent 7bd6f17 commit fd3a162

25 files changed

Lines changed: 157 additions & 644 deletions

comiclib/LANraragi/public/js/common.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ LRR.getImgSize = function (target) {
312312
$.ajax({
313313
async: false,
314314
url: target,
315+
cache: true,
315316
type: "HEAD",
316317
success: (data, textStatus, request) => {
317318
imgSize = parseInt(request.getResponseHeader("Content-Length") / 1024, 10);

comiclib/LANraragi/public/js/index_datatables.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ IndexTable.initializeAll = function () {
5050
IndexTable.dataTable = $(".datatables").DataTable({
5151
serverSide: true,
5252
processing: true,
53-
ajax: "search",
53+
ajax: {
54+
url: "search",
55+
cache: true,
56+
},
5457
deferRender: true,
5558
lengthChange: false,
5659
pageLength: Index.pageSize,

comiclib/LANraragi/public/js/reader.js

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,39 @@ Reader.initializeAll = function () {
4343
window.location.href = `./reader?id=${Reader.id}&force_reload`;
4444
});
4545
$(document).on("click.edit-metadata", "#edit-archive", () => LRR.openInNewTab(`./edit?id=${Reader.id}`));
46-
$(document).on("click.add-category", "#add-category", () => Server.addArchiveToCategory(Reader.id, $("#category").val()));
46+
$(document).on("click.delete-archive", "#delete-archive", () => {
47+
LRR.closeOverlay();
48+
LRR.showPopUp({
49+
text: "Are you sure you want to delete this archive?",
50+
icon: "warning",
51+
showCancelButton: true,
52+
focusConfirm: false,
53+
confirmButtonText: "Yes, delete it!",
54+
reverseButtons: true,
55+
confirmButtonColor: "#d33",
56+
}).then((result) => {
57+
if (result.isConfirmed) {
58+
Server.deleteArchive(Reader.id, () => { document.location.href = "./"; });
59+
}
60+
});
61+
});
62+
$(document).on("click.add-category", "#add-category", () => {
63+
if ($("#category").val() === "" || $(`#archive-categories a[data-id="${$("#category").val()}"]`).length !== 0) { return; }
64+
Server.addArchiveToCategory(Reader.id, $("#category").val());
65+
66+
const html = `<div class="gt" style="font-size:14px; padding:4px">
67+
<a href="/?c=${$("#category").val()}">
68+
<span class="label">${$("#category option:selected").text()}</span>
69+
<a href="#" class="remove-category" data-id="${$("#category").val()}"
70+
style="margin-left:4px; margin-right:2px">×</a>
71+
</a>`;
72+
73+
$("#archive-categories").append(html);
74+
});
75+
$(document).on("click.remove-category", ".remove-category", (e) => {
76+
Server.removeArchiveFromCategory(Reader.id, $(e.target).attr("data-id"));
77+
$(e.target).parent().remove();
78+
});
4779
$(document).on("click.set-thumbnail", "#set-thumbnail", () => Server.callAPI(`/api/archives/${Reader.id}/thumbnail?page=${Reader.currentPage + 1}`,
4880
"PUT", `Successfully set page ${Reader.currentPage + 1} as the thumbnail!`, "Error updating thumbnail!", null));
4981

@@ -84,6 +116,7 @@ Reader.initializeAll = function () {
84116
}
85117

86118
$("#archive-title").html(title);
119+
$("#archive-title-overlay").html(title);
87120
if (data.pagecount) { $(".max-page").html(data.pagecount); }
88121
document.title = title;
89122

@@ -240,7 +273,6 @@ Reader.initInfiniteScrollView = function () {
240273
Reader.pages.slice(1).forEach((source) => {
241274
const img = new Image();
242275
img.id = `page-${Reader.pages.indexOf(source)}`;
243-
img.loading = "lazy";
244276
img.height = 800;
245277
img.width = 600;
246278
img.src = source;
@@ -353,7 +385,7 @@ Reader.checkFiletypeSupport = function (extension) {
353385
localStorage.epubWarningShown = true;
354386
LRR.toast({
355387
heading: "EPUB support in LANraragi is minimal",
356-
text: "EPUB books will only show images in the Web Reader. If you want text support, consider pairing LANraragi with an <a href='https://sugoi.gitbook.io/lanraragi/advanced-usage/external-readers#generic-opds-readers'>OPDS reader.</a>",
388+
text: "EPUB books will only show images in the Web Reader, and potentially out of order. If you want text support, consider pairing LANraragi with an <a href='https://sugoi.gitbook.io/lanraragi/advanced-usage/external-readers#generic-opds-readers'>OPDS reader.</a>",
357389
icon: "warning",
358390
hideAfter: 20000,
359391
closeOnClick: false,
@@ -439,7 +471,7 @@ Reader.goToPage = function (page) {
439471
Reader.showingSinglePage = false;
440472

441473
if (Reader.infiniteScroll) {
442-
$("#display img").get(page).scrollIntoView({ behavior: "smooth" });
474+
$("#display img").get(Reader.currentPage).scrollIntoView({ behavior: "smooth" });
443475
} else {
444476
$("#img_doublepage").attr("src", "");
445477
$("#display").removeClass("double-mode");

comiclib/LANraragi/public/js/server.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,33 @@ Server.callAPI = function (endpoint, method, successMessage, errorMessage, succe
4242
.catch((error) => LRR.showErrorToast(errorMessage, error));
4343
};
4444

45+
Server.callAPIBody = function (endpoint, method, body, successMessage, errorMessage, successCallback) {
46+
return fetch(endpoint, { method, body })
47+
.then((response) => (response.ok ? response.json() : { success: 0, error: "Response was not OK" }))
48+
.then((data) => {
49+
if (Object.prototype.hasOwnProperty.call(data, "success") && !data.success) {
50+
throw new Error(data.error);
51+
} else {
52+
let message = successMessage;
53+
if ("successMessage" in data && data.successMessage !== null) {
54+
message = data.successMessage;
55+
}
56+
if (message !== null) {
57+
LRR.toast({
58+
heading: message,
59+
icon: "success",
60+
hideAfter: 7000,
61+
});
62+
}
63+
64+
if (successCallback !== null) return successCallback(data);
65+
66+
return null;
67+
}
68+
})
69+
.catch((error) => LRR.showErrorToast(errorMessage, error));
70+
};
71+
4572
/**
4673
* Check the status of a Minion job until it's completed.
4774
* @param {*} jobId Job ID to check

comiclib/LANraragi/public/themes/ex.css

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,22 +544,26 @@ div.id1 {
544544
display: inline-block;
545545
margin: 3px 2px 2px 3px;
546546
padding-top: 3px;
547-
height: 335px;
547+
vertical-align: top;
548+
min-height: 335px;
548549
}
549550

550551
div.id2 {
551552
height: 30px;
552553
margin: auto;
553-
overflow: hidden;
554554
text-align: center;
555-
vertical-align: middle;
556-
line-height: 15px;
557555
width: 97%;
558556
}
559557

560558
div.id2 a {
561559
font-weight: bold;
562560
text-decoration: none;
561+
overflow: hidden;
562+
563+
/* Multi-line title support */
564+
display: -webkit-box;
565+
-webkit-line-clamp: 2;
566+
-webkit-box-orient: vertical;
563567
}
564568

565569
div.id3 {

comiclib/LANraragi/public/themes/g.css

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,22 +545,26 @@ div.id1 {
545545
display: inline-block;
546546
margin: 3px 2px 2px 3px;
547547
padding-top: 3px;
548-
height: 335px;
548+
vertical-align: top;
549+
min-height: 335px;
549550
}
550551

551552
div.id2 {
552553
height: 30px;
553554
margin: auto;
554-
overflow: hidden;
555555
text-align: center;
556-
vertical-align: middle;
557-
line-height: 15px;
558556
width: 97%;
559557
}
560558

561559
div.id2 a {
562560
font-weight: bold;
563561
text-decoration: none;
562+
overflow: hidden;
563+
564+
/* Multi-line title support */
565+
display: -webkit-box;
566+
-webkit-line-clamp: 2;
567+
-webkit-box-orient: vertical;
564568
}
565569

566570
div.id3 {

comiclib/LANraragi/public/themes/modern.css

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -538,23 +538,26 @@ div.id1 {
538538
display: inline-block;
539539
margin: 3px 2px 2px 3px;
540540
padding-top: 3px;
541-
height: 335px;
541+
vertical-align: top;
542+
min-height: 335px;
542543
}
543544

544545
div.id2 {
545-
height: 30px;
546+
min-height: 32px;
546547
margin: auto;
547-
overflow: hidden;
548548
text-align: center;
549-
text-overflow: ellipsis;
550-
vertical-align: middle;
551-
white-space: nowrap;
552549
width: 97%;
553550
}
554551

555552
div.id2 a {
556553
font-weight: bold;
557554
text-decoration: none;
555+
overflow: hidden;
556+
557+
/* Multi-line title support */
558+
display: -webkit-box;
559+
-webkit-line-clamp: 2;
560+
-webkit-box-orient: vertical;
558561
}
559562

560563
div.id3 {

comiclib/LANraragi/public/themes/modern_clear.css

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,18 @@ table.itg th {
201201
color: #34495E !important;
202202
}
203203

204+
.caption-tags>*>*>span {
205+
color: #34495E !important;
206+
}
207+
208+
#archive-categories .gt a {
209+
color: #E1E7E9;
210+
}
211+
212+
#archive-categories .gt a:hover {
213+
color: #ed2553;
214+
}
215+
204216
.tippy-arrow {
205217
color: #E1E7E9;
206218
}
@@ -651,20 +663,22 @@ div.id1 {
651663
}
652664

653665
div.id2 {
654-
height: 20px;
655-
overflow: hidden;
666+
min-height: 32px;
656667
text-align: center;
657-
text-overflow: ellipsis;
658-
vertical-align: middle;
659-
white-space: nowrap;
660668
width: 97%;
661669
}
662670

663671
div.id2 a {
664672
font-weight: bold;
665673
text-decoration: none;
674+
overflow: hidden;
666675
color: #FCFCFC;
667676
font-size: 12px;
677+
678+
/* Multi-line title support */
679+
display: -webkit-box;
680+
-webkit-line-clamp: 2;
681+
-webkit-box-orient: vertical;
668682
}
669683

670684
div.id2 a:hover {

comiclib/LANraragi/public/themes/modern_red.css

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -603,26 +603,29 @@ div.id1 {
603603
display: inline-block;
604604
margin: 3px 5px 5px 3px;
605605
padding-top: 3px;
606-
height: 335px;
606+
vertical-align: top;
607+
min-height: 335px;
607608
}
608609

609610
div.id2 {
610611
border-bottom: 2px dotted #414135;
611-
height: 20px;
612+
min-height: 20px;
612613
margin: auto auto 10px;
613-
overflow: hidden;
614614
text-align: center;
615-
text-overflow: ellipsis;
616-
vertical-align: middle;
617-
white-space: nowrap;
618615
width: 97%;
619616
}
620617

621618
div.id2 a {
622619
font-weight: bold;
623620
text-decoration: none;
621+
overflow: hidden;
624622
color: #414135;
625623
font-size: 12px;
624+
625+
/* Multi-line title support */
626+
display: -webkit-box;
627+
-webkit-line-clamp: 1;
628+
-webkit-box-orient: vertical;
626629
}
627630

628631
div.id2 a:hover {

comiclib/LANraragi/templates/category

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<meta name="viewport" content="width=device-width" />
99
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
1010

11-
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>📚</text></svg>">
11+
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>📚</text></svg>">
1212
<link rel="stylesheet" type="text/css" href="/css/lrr.css?[% version%]" />
1313
<link rel="stylesheet" type="text/css" href="/css/vendor/fontawesome-all.min.css" />
1414
<link rel="stylesheet" type="text/css" href="/css/vendor/ReactToastify.min.css" />

0 commit comments

Comments
 (0)