This commit is contained in:
Ozzieisaacs 2020-04-04 08:53:22 +02:00
parent ec6b346ca1
commit 587174b771

View File

@ -29,15 +29,15 @@ $(function () {
var msg = i18nMsg;
var douban = "https://api.douban.com";
var dbSearch = "/v2/book/search";
var dbDone = true;
var dbDone = 0;
var google = "https://www.googleapis.com";
var ggSearch = "/books/v1/volumes";
var ggDone = false;
var ggDone = 0;
var comicvine = "https://comicvine.gamespot.com";
var cvSearch = "/api/search/";
var cvDone = false;
var cvDone = 0;
var showFlag = 0;
@ -73,7 +73,9 @@ $(function () {
if (showFlag === 1) {
$("#meta-info").html("<ul id=\"book-list\" class=\"media-list\"></ul>");
}
if (!ggDone && !dbDone) {
if ((ggDone == 3 || (ggDone == 1 && ggResults.length === 0)) &&
(dbDone == 3 || (ggDone == 1 && dbResults.length === 0)) &&
(cvDone == 3 || (ggDone == 1 && cvResults.length === 0))) {
$("#meta-info").html("<p class=\"text-danger\">" + msg.no_result + "</p>");
return;
}
@ -93,7 +95,8 @@ $(function () {
return [year, month, day].join("-");
}
if (ggDone && ggResults.length > 0) {
if (ggResults.length > 0) {
if (ggDone < 2) {
ggResults.forEach(function(result) {
var book = {
id: result.id,
@ -121,9 +124,14 @@ $(function () {
$("#book-list").append($book);
});
ggDone = false;
ggDone = 2;
} else {
ggDone = 3;
}
if (dbDone && dbResults.length > 0) {
}
if (dbResults.length > 0) {
if (dbDone < 2) {
dbResults.forEach(function(result) {
var seriesTitle = "";
if (result.series) {
@ -168,9 +176,13 @@ $(function () {
$("#book-list").append($book);
});
dbDone = false;
dbDone = 2;
} else {
dbDone = 3;
}
if (cvDone && cvResults.length > 0) {
}
if (cvResults.length > 0) {
if (cvDone < 2) {
cvResults.forEach(function(result) {
var seriesTitle = "";
if (result.volume.name) {
@ -214,7 +226,10 @@ $(function () {
$("#book-list").append($book);
});
cvDone = false;
cvDone = 2;
} else {
cvDone = 3;
}
}
}
@ -227,11 +242,10 @@ $(function () {
success: function success(data) {
if ("items" in data) {
ggResults = data.items;
ggDone = true;
}
},
complete: function complete() {
ggDone = true;
ggDone = 1;
showResult();
$("#show-google").trigger("change");
}
@ -252,7 +266,7 @@ $(function () {
$("#meta-info").html("<p class=\"text-danger\">" + msg.search_error + "!</p>" + $("#meta-info")[0].innerHTML);
},
complete: function complete() {
dbDone = true;
dbDone = 1;
showResult();
$("#show-douban").trigger("change");
}
@ -274,7 +288,7 @@ $(function () {
$("#meta-info").html("<p class=\"text-danger\">" + msg.search_error + "!</p>" + $("#meta-info")[0].innerHTML);
},
complete: function complete() {
cvDone = true;
cvDone = 1;
showResult();
$("#show-comics").trigger("change");
}
@ -283,6 +297,10 @@ $(function () {
function doSearch (keyword) {
showFlag = 0;
dbDone = ggDone = cvDone = 0;
dbResults = [];
ggResults = [];
cvResults = [];
$("#meta-info").text(msg.loading);
if (keyword) {
dbSearchBook(keyword);