-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbook.html
64 lines (61 loc) · 1.94 KB
/
book.html
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
62
63
64
<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Google Books Embedded Viewer API Example</title>
<link rel="stylesheet" href="./book.css" />
<link rel="icon" href="logo.png">
<script
type="text/javascript"
src="https://www.google.com/books/jsapi.js"
></script>
<script type="text/javascript">
google.books.load();
function initialize() {
var viewer = new google.books.DefaultViewer(
document.getElementById("viewerCanvas")
);
var index = document.URL.indexOf("?");
if (index > 0) {
var bookIsbn = document.URL.substring(
index,
document.URL.length
).split("=")[1];
console.log(bookIsbn);
}
//viewer.load("ISBN:0738531367"); //for test purpose
viewer.load("ISBN:" + bookIsbn);
}
google.books.setOnLoadCallback(initialize);
</script>
</head>
<body>
<div class="toggle-container">
<input type="checkbox" id="switch" name="theme" /><label for="switch">Toggle</label>
<div class="container">
<div
class="text-center"
id="viewerCanvas"
style="width: 800px; height: 600px"
></div>
</div>
<script>
var checkbox = document.querySelector('input[name=theme]');
checkbox.addEventListener('change', function() {
if(this.checked) {
trans()
document.documentElement.setAttribute('data-theme', 'dark')
} else {
trans()
document.documentElement.setAttribute('data-theme', 'light')
}
})
let trans = () => {
document.documentElement.classList.add('transition');
window.setTimeout(() => {
document.documentElement.classList.remove('transition')
}, 1000)
}
</script>
</body>
</html>