" + msg.no_result + "
"); - return; - } - function formatDate (date) { - var d = new Date(date), - month = "" + (d.getMonth() + 1), - day = "" + d.getDate(), - year = d.getFullYear(); - - if (month.length < 2) { - month = "0" + month; - } - if (day.length < 2) { - day = "0" + day; - } - - return [year, month, day].join("-"); - } - function generateID (title) { - return title.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0).toString().substr(0,12); - } - - if (ggResults.length > 0) { - if (ggDone < 2) { - ggResults.forEach(function(result) { - var book = { - id: result.id, - title: result.volumeInfo.title, - authors: result.volumeInfo.authors || [], - description: result.volumeInfo.description || "", - publisher: result.volumeInfo.publisher || "", - publishedDate: result.volumeInfo.publishedDate || "", - tags: result.volumeInfo.categories || [], - rating: result.volumeInfo.averageRating || 0, - cover: result.volumeInfo.imageLinks ? - result.volumeInfo.imageLinks.thumbnail : location + "/../../../static/generic_cover.jpg", - url: "https://books.google.com/books?id=" + result.id, - source: { - id: "google", - description: "Google Books", - url: "https://books.google.com/" - } - }; - - var $book = $(templates.bookResult(book)); - $book.find("img").on("click", function () { - populateForm(book); - }); - - $("#book-list").append($book); + function populateForm (book) { + tinymce.get("description").setContent(book.description); + var uniqueTags = []; + $.each(book.tags, function(i, el) { + if ($.inArray(el, uniqueTags) === -1) uniqueTags.push(el); }); - ggDone = 2; - } else { - ggDone = 3; - } - } - - if (gsResults.length > 0) { - if (gsDone < 2) { - gsResults.forEach(function(result) { - var book = { - id: generateID(result.bib.title), - title: result.bib.title, - authors: result.bib.author || [], - description: result.bib.abstract || "", - publisher: result.bib.venue || "", - publishedDate: result.bib.pub_year ? result.bib.pub_year+"-01-01" : "", - tags: [], - rating: 0, - series: "", - cover: null, - url: result.pub_url || result.eprint_url || "", - source: { - id: "googlescholar", - description: "Google Scholar", - link: "https://scholar.google.com/" - } - } - var $book = $(templates.bookResult(book)); - $book.find("img").on("click", function () { - populateForm(book); - }); - - $("#book-list").append($book); - - }); - gsDone = 2; - } - else { - gsDone = 3; - } - } - - if (dbResults.length > 0) { - if (dbDone < 2) { - dbResults.forEach(function(result) { - var seriesTitle = ""; - if (result.series) { - seriesTitle = result.series.title; - } - var dateFomers = result.pubdate.split("-"); - var publishedYear = parseInt(dateFomers[0], 10); - var publishedMonth = parseInt(dateFomers[1], 10); - var publishedDate = new Date(publishedYear, publishedMonth - 1, 1); - - publishedDate = formatDate(publishedDate); - - var book = { - id: result.id, - title: result.title, - authors: result.author || [], - description: result.summary, - publisher: result.publisher || "", - publishedDate: publishedDate || "", - tags: result.tags.map(function(tag) { - return tag.title.toLowerCase().replace(/,/g, "_"); - }), - rating: result.rating.average || 0, - series: seriesTitle || "", - cover: result.image, - url: "https://book.douban.com/subject/" + result.id, - source: { - id: "douban", - description: "Douban Books", - url: "https://book.douban.com/" - } - }; - - if (book.rating > 0) { - book.rating /= 2; - } - - var $book = $(templates.bookResult(book)); - $book.find("img").on("click", function () { - populateForm(book); - }); - - $("#book-list").append($book); - }); - dbDone = 2; - } else { - dbDone = 3; - } - } - if (cvResults.length > 0) { - if (cvDone < 2) { - cvResults.forEach(function(result) { - var seriesTitle = ""; - if (result.volume.name) { - seriesTitle = result.volume.name; - } - var dateFomers = ""; - if (result.store_date) { - dateFomers = result.store_date.split("-"); - } else { - dateFomers = result.date_added.split("-"); - } - var publishedYear = parseInt(dateFomers[0], 10); - var publishedMonth = parseInt(dateFomers[1], 10); - var publishedDate = new Date(publishedYear, publishedMonth - 1, 1); - - publishedDate = formatDate(publishedDate); - - var book = { - id: result.id, - title: seriesTitle + " #" + ("00" + result.issue_number).slice(-3) + " - " + result.name, - authors: result.author || [], - description: result.description, - publisher: "", - publishedDate: publishedDate || "", - tags: ["Comics", seriesTitle], - rating: 0, - series: seriesTitle || "", - cover: result.image.original_url, - url: result.site_detail_url, - source: { - id: "comicvine", - description: "ComicVine Books", - url: "https://comicvine.gamespot.com/" - } - }; - - var $book = $(templates.bookResult(book)); - $book.find("img").on("click", function () { - populateForm(book); - }); - - $("#book-list").append($book); - }); - cvDone = 2; - } else { - cvDone = 3; - } - } - } - - function ggSearchBook (title) { - $.ajax({ - url: google + ggSearch + "?q=" + title.replace(/\s+/gm, "+"), - type: "GET", - dataType: "jsonp", - jsonp: "callback", - success: function success(data) { - if ("items" in data) { - ggResults = data.items; + var ampSeparatedAuthors = (book.authors || []).join(" & "); + $("#bookAuthor").val(ampSeparatedAuthors); + $("#book_title").val(book.title); + $("#tags").val(uniqueTags.join(",")); + $("#rating").data("rating").setValue(Math.round(book.rating)); + if(book.cover !== null){ + $(".cover img").attr("src", book.cover); + $("#cover_url").val(book.cover); + } + $("#pubdate").val(book.publishedDate); + $("#publisher").val(book.publisher); + if (typeof book.series !== "undefined") { + $("#series").val(book.series); } - }, - complete: function complete() { - ggDone = 1; - showResult(); - $("#show-google").trigger("change"); - } - }); - } - - function dbSearchBook (title) { - var apikey = "054022eaeae0b00e0fc068c0c0a2102a"; - $.ajax({ - url: douban + dbSearch + "?apikey=" + apikey + "&q=" + title + "&fields=all&count=10", - type: "GET", - dataType: "jsonp", - jsonp: "callback", - success: function success(data) { - dbResults = data.books; - }, - error: function error() { - $("#meta-info").html("" + msg.search_error + "!
" + $("#meta-info")[0].innerHTML); - }, - complete: function complete() { - dbDone = 1; - showResult(); - $("#show-douban").trigger("change"); - } - }); - } - - function cvSearchBook (title) { - var apikey = "57558043c53943d5d1e96a9ad425b0eb85532ee6"; - title = encodeURIComponent(title); - $.ajax({ - url: comicvine + cvSearch + "?api_key=" + apikey + "&resources=issue&query=" + title + "&sort=name:desc&format=jsonp", - type: "GET", - dataType: "jsonp", - jsonp: "json_callback", - success: function success(data) { - cvResults = data.results; - }, - error: function error() { - $("#meta-info").html("" + msg.search_error + "!
" + $("#meta-info")[0].innerHTML); - }, - complete: function complete() { - cvDone = 1; - showResult(); - $("#show-comics").trigger("change"); - } - }); - } - - function gsSearchBook (title) { - $.ajax({ - url: googlescholar + gsSearch + title.replace(/\s+/gm,'+'), - type: "GET", - dataType: "json", - success: function success(data) { - gsResults = data; - }, - complete: function complete() { - gsDone = 1; - showResult(); - $("#show-googlescholar").trigger("change"); - } - }) - } - - function doSearch (keyword) { - showFlag = 0; - dbDone = ggDone = cvDone = 0; - dbResults = []; - ggResults = []; - cvResults = []; - gsResults = []; - $("#meta-info").text(msg.loading); - if (keyword) { - dbSearchBook(keyword); - ggSearchBook(keyword); - cvSearchBook(keyword); - gsSearchBook(keyword); } - } - $("#meta-search").on("submit", function (e) { - e.preventDefault(); - var keyword = $("#keyword").val(); - if (keyword) { - doSearch(keyword); + function doSearch (keyword) { + if (keyword) { + $("#meta-info").text(msg.loading); + $.ajax({ + url: getPath() + "/metadata/search", + type: "POST", + data: {"query": keyword}, + dataType: "json", + success: function success(data) { + $("#meta-info").html("" + msg.search_error + "!
" + $("#meta-info")[0].innerHTML); + }, + }); + } } - }); - $("#get_meta").click(function () { - var bookTitle = $("#book_title").val(); - if (bookTitle) { - $("#keyword").val(bookTitle); - doSearch(bookTitle); + function populate_provider() { + $("#metadata_provider").empty(); + $.ajax({ + url: getPath() + "/metadata/provider", + type: "get", + dataType: "json", + success: function success(data) { + data.forEach(function(provider) { + var checked = ""; + if (provider.active) { + checked = "checked"; + } + var $provider_button = '' + $("#metadata_provider").append($provider_button); + }); + }, + }); } - }); + $(document).on("change", ".pill", function () { + var element = $(this); + var id = element.data("control"); + var initial = element.data("initial"); + var val = element.prop('checked'); + var params = {id : id, value: val}; + if (!initial) { + params['initial'] = initial; + params['query'] = keyword; + } + $.ajax({ + method:"post", + contentType: "application/json; charset=utf-8", + dataType: "json", + url: getPath() + "/metadata/provider/" + id, + data: JSON.stringify(params), + success: function success(data) { + element.data("initial", "true"); + data.forEach(function(book) { + var $book = $(templates.bookResult(book)); + $book.find("img").on("click", function () { + populateForm(book); + }); + $("#book-list").append($book); + }); + } + }); + }); + + $("#meta-search").on("submit", function (e) { + e.preventDefault(); + keyword = $("#keyword").val(); + $('.pill').each(function(){ + // console.log($(this).data('control')); + $(this).data("initial", $(this).prop('checked')); + // console.log($(this).data('initial')); + }); + doSearch(keyword); + }); + + $("#get_meta").click(function () { + populate_provider(); + var bookTitle = $("#book_title").val(); + $("#keyword").val(bookTitle); + keyword = bookTitle; + doSearch(bookTitle); + }); + $("#metaModal").on("show.bs.modal", function(e) { + $(e.relatedTarget).one('focus', function (e) { + $(this).blur(); + }); + }); }); diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-af-ZA.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-af.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-af-ZA.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-af.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ar-SA.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ar.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ar-SA.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ar.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-bg-BG.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-bg.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-bg-BG.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-bg.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ca-ES.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ca.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ca-ES.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ca.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-cs-CZ.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-cs.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-cs-CZ.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-cs.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-da-DK.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-da.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-da-DK.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-da.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-de-DE.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-de.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-de-DE.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-de.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-el-GR.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-el.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-el-GR.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-el.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-es-ES.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-es.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-es-ES.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-es.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-et-EE.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-et.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-et-EE.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-et.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-eu-EU.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-eu.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-eu-EU.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-eu.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fa-IR.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fa.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fa-IR.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fa.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fi-FI.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fi.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fi-FI.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fi.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fr-FR.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fr.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fr-FR.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-fr.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-he-IL.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-he.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-he-IL.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-he.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-hr-HR.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-hr.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-hr-HR.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-hr.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-hu-HU.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-hu.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-hu-HU.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-hu.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-id-ID.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-id.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-id-ID.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-id.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-it-IT.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-it.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-it-IT.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-it.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ja-JP.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ja.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ja-JP.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ja.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ka-GE.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ka.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ka-GE.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ka.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ko-KR.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ko.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ko-KR.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ko.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-nl-NL.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-nl.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-nl-NL.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-nl.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-pl-PL.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-pl.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-pl-PL.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-pl.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-pt-BR.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-pt_BR.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-pt-BR.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-pt_BR.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ro-RO.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ro.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ro-RO.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ro.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ru-RU.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ru.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ru-RU.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-ru.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-sk-SK.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-sk.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-sk-SK.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-sk.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-sv-SE.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-sv.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-sv-SE.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-sv.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-tr-TR.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-tr.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-tr-TR.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-tr.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-uk-UA.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-uk.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-uk-UA.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-uk.min.js diff --git a/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js b/cps/static/js/libs/bootstrap-table/locale/bootstrap-table-zh_Hans_CN.min.js similarity index 100% rename from cps/static/js/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js rename to cps/static/js/libs/bootstrap-table/locale/bootstrap-table-zh_Hans_CN.min.js diff --git a/cps/static/js/main.js b/cps/static/js/main.js index d8641c3e..988e3b9f 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -181,7 +181,7 @@ $("#delete_confirm").click(function() { if (item.format != "") { $("button[data-delete-format='"+item.format+"']").addClass('hidden'); } - $( ".navbar" ).after( '