-
Notifications
You must be signed in to change notification settings - Fork 0
/
BookDescription.js
63 lines (48 loc) · 1.93 KB
/
BookDescription.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
let parms;
let bookId;
// window.addEventListener("load",() => {
// parms = (new URL(document.location)).searchParams
// id = parseInt(parms.get("id"))
// })
parms = (new URL(document.location)).searchParams
bookId = parseInt(parms.get("bookId"))
fetchData()
async function fetchData(){
try{
const data = await fetch("BookDescription.json")
const response = await data.json()
console.log(response[bookId].title,bookId)
document.getElementById("Title").innerHTML = response[bookId].title
document.getElementById("Image").src = response[bookId].image
document.getElementById("Description").innerHTML = response[bookId].description
document.getElementById("Download").href = "https://drive.google.com/uc?export=download&id=" + response[bookId].urlid
document.getElementById("WebView").href = "https://drive.google.com/viewerng/viewer?embedded=true&url=https://drive.google.com/uc?id=" + response[bookId].urlid
Heart()
}
catch(err){
// document.getElementById("Title").innerHTML = "response[bookId].title"
console.log("Error")
document.getElementById("NotFound").innerHTML = "<div style=\"top:50%;left: 50%;transform: translate3d(-50%,-50%, 0);position: absolute;\"><img src=\"https://cdn.dribbble.com/users/1278258/screenshots/4110477/error800600_4.jpg\"></img></div>"
}
}
function goBack(){
window.history.back();
}
function Heart(){
let heart = document.getElementById("Heart")
if(localStorage.getItem("bookId"+bookId) == null){
localStorage.setItem("bookId"+bookId,"🤍")
}
heart.innerHTML = localStorage.getItem("bookId"+bookId)
}
function HeartToggle(){
let heart = document.getElementById("Heart")
if(heart.innerHTML == "❤️"){
heart.innerHTML = "🤍"
localStorage.setItem("bookId"+bookId,"🤍")
}
else{
heart.innerHTML = "❤️"
localStorage.setItem("bookId"+bookId,"❤️")
}
}