pull/938/head
Ozzieisaacs 6 years ago
parent f736a15c12
commit c81d4edb7d

@ -20,16 +20,16 @@
* Douban Books api document: https://developers.douban.com/wiki/?title=book_v2 (Chinese Only) * Douban Books api document: https://developers.douban.com/wiki/?title=book_v2 (Chinese Only)
*/ */
/* global _, i18nMsg, tinymce */ /* global _, i18nMsg, tinymce */
var dbResults = []; // var dbResults = [];
var ggResults = []; var ggResults = [];
$(function () { $(function () {
var msg = i18nMsg; var msg = i18nMsg;
/*var douban = "https://api.douban.com"; /*var douban = "https://api.douban.com";
var dbSearch = "/v2/book/search";*/ var dbSearch = "/v2/book/search";*/
var dbDone = true; // var dbDone = true;
var google = "https://www.googleapis.com/"; var google = "https://www.googleapis.com";
var ggSearch = "/books/v1/volumes"; var ggSearch = "/books/v1/volumes";
var ggDone = false; var ggDone = false;
@ -56,11 +56,9 @@ $(function () {
if (showFlag === 1) { if (showFlag === 1) {
$("#meta-info").html("<ul id=\"book-list\" class=\"media-list\"></ul>"); $("#meta-info").html("<ul id=\"book-list\" class=\"media-list\"></ul>");
} }
if (ggDone && dbDone) { if (!ggDone) {
if (!ggResults && !dbResults) { $("#meta-info").html("<p class=\"text-danger\">" + msg.no_result + "</p>");
$("#meta-info").html("<p class=\"text-danger\">" + msg.no_result + "</p>"); return;
return;
}
} }
if (ggDone && ggResults.length > 0) { if (ggDone && ggResults.length > 0) {
ggResults.forEach(function(result) { ggResults.forEach(function(result) {
@ -137,10 +135,12 @@ $(function () {
dataType: "jsonp", dataType: "jsonp",
jsonp: "callback", jsonp: "callback",
success: function success(data) { success: function success(data) {
ggResults = data.items; if ("items" in data) {
ggResults = data.items;
ggDone = true;
}
}, },
complete: function complete() { complete: function complete() {
ggDone = true;
showResult(); showResult();
$("#show-google").trigger("change"); $("#show-google").trigger("change");
} }

Loading…
Cancel
Save