switch frontend to use new api endpoint instead of google sheet
This commit is contained in:
parent
39fd64ace7
commit
fbcd59c7f0
@ -5,7 +5,6 @@
|
|||||||
<script type="text/javascript" src="js/jquery.js"></script>
|
<script type="text/javascript" src="js/jquery.js"></script>
|
||||||
<script type="text/javascript" src="js/mustache.js"></script>
|
<script type="text/javascript" src="js/mustache.js"></script>
|
||||||
<script type="text/javascript" src="js/lodash.min.js"></script>
|
<script type="text/javascript" src="js/lodash.min.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/tabletop.js/1.5.1/tabletop.min.js"></script>
|
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
|
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
|
||||||
@ -18,22 +17,18 @@
|
|||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
/>
|
/>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var publicSpreadsheetUrl =
|
|
||||||
"https://docs.google.com/spreadsheets/d/1w5Dc57wV0_rrKFsG7KM-qdPWEpqYk6lFu3JzAA0cSv0/pubhtml";
|
|
||||||
var sortState = {
|
var sortState = {
|
||||||
sortBy: "authorLast",
|
sortBy: "sortAuthor",
|
||||||
sortOrder: "asc",
|
sortOrder: "asc",
|
||||||
};
|
};
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
Tabletop.init({
|
fetch("/api")
|
||||||
key: publicSpreadsheetUrl,
|
.then((response) => response.json())
|
||||||
callback: showInfo,
|
.then(showInfo);
|
||||||
simpleSheet: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showInfo(data, tabletop) {
|
function showInfo(data) {
|
||||||
$("#reloadLink").unbind("click");
|
$("#reloadLink").unbind("click");
|
||||||
$("#reloadLink").on("click", function () {
|
$("#reloadLink").on("click", function () {
|
||||||
init();
|
init();
|
||||||
@ -66,7 +61,7 @@
|
|||||||
.replace(" ", "");
|
.replace(" ", "");
|
||||||
relevantFields = [
|
relevantFields = [
|
||||||
"title",
|
"title",
|
||||||
"author",
|
"authors",
|
||||||
"genre",
|
"genre",
|
||||||
"publisher",
|
"publisher",
|
||||||
"series",
|
"series",
|
||||||
@ -81,6 +76,9 @@
|
|||||||
renderTable(
|
renderTable(
|
||||||
_.filter(data, function (book) {
|
_.filter(data, function (book) {
|
||||||
return _.find(_.pick(book, relevantFields), function (field) {
|
return _.find(_.pick(book, relevantFields), function (field) {
|
||||||
|
if (_.isArray(field)) {
|
||||||
|
field = field.join(" ");
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
field
|
field
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
@ -201,7 +199,7 @@
|
|||||||
<table class="bookTable">
|
<table class="bookTable">
|
||||||
<tr>
|
<tr>
|
||||||
<th data-sort-by="sortTitle" class="tHeader title">Title</th>
|
<th data-sort-by="sortTitle" class="tHeader title">Title</th>
|
||||||
<th data-sort-by="authorLast" class="tHeader author">Author</th>
|
<th data-sort-by="sortAuthor" class="tHeader author">Author</th>
|
||||||
<th data-sort-by="publisher" class="tHeader publisher">Publisher</th>
|
<th data-sort-by="publisher" class="tHeader publisher">Publisher</th>
|
||||||
<th data-sort-by="year" class="tHeader year">Year</th>
|
<th data-sort-by="year" class="tHeader year">Year</th>
|
||||||
<th class="tHeader isbn">ISBN</th>
|
<th class="tHeader isbn">ISBN</th>
|
||||||
@ -215,7 +213,7 @@
|
|||||||
>✒</span
|
>✒</span
|
||||||
>︎{{/signed}}
|
>︎{{/signed}}
|
||||||
</td>
|
</td>
|
||||||
<td class="author">{{author}}</td>
|
<td class="author">{{authors}}</td>
|
||||||
<td class="publisher">{{publisher}}</td>
|
<td class="publisher">{{publisher}}</td>
|
||||||
<td class="year">{{year}}</td>
|
<td class="year">{{year}}</td>
|
||||||
<td class="isbn">{{isbn-13}}</td>
|
<td class="isbn">{{isbn-13}}</td>
|
||||||
@ -230,7 +228,7 @@
|
|||||||
<img src="{{coverurl}}"/>
|
<img src="{{coverurl}}"/>
|
||||||
{{/coverurl}}
|
{{/coverurl}}
|
||||||
<h1 {{#onLoan}}class="onLoan" {{/onLoan}}>{{title}}</h1>
|
<h1 {{#onLoan}}class="onLoan" {{/onLoan}}>{{title}}</h1>
|
||||||
<h2>{{author}}</h2>
|
<h2>{{authors}}</h2>
|
||||||
<span>{{isbn-13}}</span><br/>
|
<span>{{isbn-13}}</span><br/>
|
||||||
<span>{{publisher}}, {{year}}</span><br/>
|
<span>{{publisher}}, {{year}}</span><br/>
|
||||||
{{#series}}
|
{{#series}}
|
||||||
|
Loading…
Reference in New Issue
Block a user