get page number dynamically

main
BuildTools 4 years ago
parent af3c3e6623
commit ce6db9fdbc
  1. 6
      zhetic-poc/db.json
  2. 11
      zhetic-poc/js/reader.js

@ -1,5 +1,5 @@
[ [
{ "id" : "0", "title" : "Boku no Kokoro no Yabai Yatsu", "cid" : "bafybeihnoou2av5w2bzmwkl6hi25scyzz6sjwdfqp4cwq2ikf6dfmev3ta", "pageNo" : "18" }, { "id" : "0", "title" : "Boku no Kokoro no Yabai Yatsu", "cid" : "bafybeihnoou2av5w2bzmwkl6hi25scyzz6sjwdfqp4cwq2ikf6dfmev3ta"},
{ "id" : "1", "title" : "Otoyomegatari", "cid" : "bafybeigfivshobq4h5x5qwmttgqimaufmcjl6hpjcrsedj7wxxduphp7g4", "pageNo" : "39" }, { "id" : "1", "title" : "Otoyomegatari", "cid" : "bafybeigfivshobq4h5x5qwmttgqimaufmcjl6hpjcrsedj7wxxduphp7g4"},
{ "id" : "2", "title" : "Spy X Family", "cid" : "bafybeibgnpbredeofwp364qomqpth55a6ui3oiy2ucm35fo3eimquoeob4", "pageNo" : "71" } { "id" : "2", "title" : "Spy X Family", "cid" : "bafybeibgnpbredeofwp364qomqpth55a6ui3oiy2ucm35fo3eimquoeob4"}
] ]

@ -103,14 +103,13 @@ $(document).ready(function () {
url: "/db.json", url: "/db.json",
headers: { "Accept": "application/json"}, headers: { "Accept": "application/json"},
success: function (res) { success: function (res) {
pageNo = 0;
$.ajax({ $.ajax({
dataType: "json", dataType: "json",
url: "https://"+domain+"/db.json", url: "http://ipfs.io/api/v0/ls/"+res[id]["cid"],
headers: { "Accept": "application/json"}, headers: { "Accept": "application/json"},
success: function (res) { success: function (r) {
} pageNo = r["Objects"][0]["Links"].length;
});
pageNo = res[id]["pageNo"];
title = res[id]["title"]; title = res[id]["title"];
cid = res[id]["cid"]; cid = res[id]["cid"];
$("#pageCounter").html(`${pageCurrent}/${pageNo}`); $("#pageCounter").html(`${pageCurrent}/${pageNo}`);
@ -123,6 +122,8 @@ $(document).ready(function () {
loadPage(); loadPage();
} }
}); });
}
});
fitHeight(); fitHeight();
layoutSingle(); layoutSingle();

Loading…
Cancel
Save