-
Notifications
You must be signed in to change notification settings - Fork 0
/
repertoire.html
355 lines (316 loc) · 13.4 KB
/
repertoire.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<!--
Bug 0 - 30/11/2021 - Added a close button at the ends of Reportoire.
Bug 1 - 30/11/2021 - Changed data array to Object and Iterating over it. Removing need for ID's to be consecutive
Bug 2 - 30/11/2021 - Added id's to the footer
Bug 3 - 30/11/2021 - Added a Toggle button in the header of Reportoire to switch between the two Dark and Light view.
Bug 4 - 30/11/2021 - Removed favourite section from Reportoireas it is already present in the Index page
Bug 5 - 31/11/2021 - Added ids to booklist and refs to footer to direct at the correct place in the page.
Bug 12 - 04/12/2021 - Added Bootstrap and jquery dist files to the project.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<!-- <link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Raleway&display=swap"
rel="stylesheet"
/> -->
<!-- Bug 12 <link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
crossorigin="anonymous"
/> -->
<link
href="https://fonts.googleapis.com/css2?family=Raleway:wght@700&family=Oleo+Script:wght@700&family=Quicksand:wght@300;500&display=swap"
rel="stylesheet"
/>
<!-- Bug 12 <link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous"
/> -->
<!-- Bug 12 -->
<link rel="stylesheet" href="assets/bootstrap.min.css">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Travel Goals</title>
<link rel="stylesheet" href="shared.css" />
<link rel="stylesheet" href="repertoire.css" />
</head>
<body>
<header>
<div id="page-logo">
<a class="headerLink" href="/index.html">Bucket List</a>
</div>
<nav>
<ul>
<li>
<a class="headerLink" href="/">Home</a>
</li>
<li>
<a class="headerLink" href="/add-book.html">Add Book</a>
</li>
<li>
<a class="headerLink" href="https://contact-ekansh.herokuapp.com/">Contact Us</a>
</li>
<li><a class="headerLink" href="https://github.com/CAPTAINCOBRA">About</a></li>
<!-- <li><a id="toggle">Toggle Theme</a></li> --> <!-- Bug 3 -->
<li><button class="btn btn-warning" id="toggle" href="">Toggle Theme</button class="warning"></li> <!-- Bug 3 -->
</ul>
</nav>
</header>
<main>
<div id="rooty"></div>
</main>
<div id="root"></div>
<footer id="footer">
<ul id="footer-ul">
<li>
<a href="https://www.instagram.com">
<img src="images/icons/insta.png" alt="Instagram logo"
/></a>
</li>
<li>
<a href="https://www.facebook.com">
<img src="images/icons/facebook.png" alt="Facebook logo"
/></a>
</li>
</ul>
</footer>
<!-- <script src="jquery-3.5.1.min.js"></script> -->
<!--Bug 12 <script
src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
crossorigin="anonymous"
></script> -->
<!-- Bug 12 -->
<script src="./assets/jquery-3.5.1.min.js"></script>
<!-- <script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"
></script> -->
<script type="module">
//-----------------Firebase Config---------------------------------
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.5.0/firebase-app.js";
const firebaseConfig = {
apiKey: "AIzaSyAwumkhm8FXf9gqxJamWDfKB2810--fOxk",
authDomain: "library-83403.firebaseapp.com",
databaseURL:
"https://library-83403-default-rtdb.asia-southeast1.firebasedatabase.app",
projectId: "library-83403",
storageBucket: "library-83403.appspot.com",
messagingSenderId: "801479317930",
appId: "1:801479317930:web:4dcf61be9e2f45d44133d3",
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
import {
getDatabase,
ref,
set,
child,
update,
remove,
get,
} from "https://www.gstatic.com/firebasejs/9.5.0/firebase-database.js";
const db = getDatabase();
//------------------References---------------------------------------
const getData = () => {
const appl = document.getElementById("root");
const container = document.createElement("div");
container.setAttribute("class", "container");
appl.appendChild(container);
const app2 = document.getElementById("rooty");
// let loader = `<div class="boxLoading"><h1>Loading</h1></div>`;
let loader = `
<button class="btn btn-primary" type="button" disabled>
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
Loading...
</button>`;
const waiter = document.createElement("div");
waiter.setAttribute("class", "waiter");
waiter.innerHTML = loader;
// waiter.appendChild(loader); //Wont work because it is a string
app2.appendChild(waiter);
const containery = document.createElement("div");
containery.setAttribute("class", "container");
app2.appendChild(containery);
const cul = document.createElement("ul");
const dbref = ref(db);
get(child(dbref, "/books")).then(function (snapshot) {
if (snapshot.exists()) {
var data = snapshot.val(); //Bug 1
const dutta = data; //Bug 5
// const duta = snapshot.val();
// data = JSON.parse(data);
// const data = Object.entries(duta);
console.log("Data is - ", data);
//
const keys = Object.keys(data);
console.log("Keys are - ", keys);
//Bug 1
const values = Object.values(data);
console.log("Values are - ", values);
const entries = Object.entries(data);
console.log("Entries are - ", entries);
const books = [];
Object.entries(data).forEach(([key, value]) => books.push(value));
console.log("Books are - ", books);
// Bug 1 - Ends
//Bug 2 starts
const ul_footer = document.createElement("ul");
ul_footer.setAttribute("class", "footer-ul");
ul_footer.setAttribute("class", "list-group");
const footer = document.getElementById("footer");
footer.appendChild(ul_footer);
keys.forEach((key) => {
const ali = document.createElement("a");
ali.setAttribute("href", "#"+key); //Bug 5
const li = document.createElement("li");
li.setAttribute("class", "list-group-item");
li.innerHTML = key;
ali.appendChild(li);
// ul_footer.appendChild(li);
ul_footer.appendChild(ali);
});
//Bug 2 ends
data = books; //Bug 1
data.forEach((book) => {
//
const cli = document.createElement("li");
cli.setAttribute("class", "hook"); //Bug 3
// cli.setAttribute("id", data.indexOf(book)); //Bug 5
cli.setAttribute("id", Object.keys(dutta).find(key => dutta[key] === book)); //Bug 5
// cli.setAttribute("class", "list-group-item"); //Veryy Big Thing
const cimg = document.createElement("img");
const div1 = document.createElement("div");
div1.setAttribute("class", "item-content");
const div2 = document.createElement("div");
const div3 = document.createElement("div");
div3.setAttribute("class", "actions");
// const ca = document.createElement("a");
// div3.appendChild(ca);
const ca1 = document.createElement("a");
const cimg1 = document.createElement("img");
cimg1.setAttribute("src", "images/icons/amazon.png");
cimg1.setAttribute("alt", "amazon");
cimg1.setAttribute("class", "small-icon");
ca1.appendChild(cimg1);
var url = "https://www.amazon.com/s?k=" + book.name;
ca1.setAttribute("href", url);
ca1.setAttribute("target", "_blank");
const ca2 = document.createElement("a");
const cimg2 = document.createElement("img");
cimg2.setAttribute("src", "images/icons/wiki.png");
cimg2.setAttribute("alt", "wiki search");
cimg2.setAttribute("class", "small-icon");
ca2.appendChild(cimg2);
var url1 = "https://en.wikipedia.org/wiki/" + book.name;
ca2.setAttribute("href", url1);
ca2.setAttribute("target", "_blank");
div3.appendChild(ca2);
div3.appendChild(ca1);
const ch2 = document.createElement("h2");
ch2.textContent = book.name;
const ch4 = document.createElement("h4");
ch4.textContent = book.author;
// ca.textContent = "Buy";
// ca.setAttribute("href", book.link);
cimg.setAttribute("src", book.image);
cimg.setAttribute("alt", book.name);
cimg.setAttribute("id", "book-img");
cimg.setAttribute("class", "book-img");
const cp = document.createElement("p");
book.description = book.description.substring(0, 300);
cp.textContent = book.description;
div2.appendChild(ch2);
div2.appendChild(ch4);
div2.appendChild(cp);
div1.appendChild(div2);
div1.appendChild(div3);
cli.appendChild(cimg);
cli.appendChild(div1);
cul.appendChild(cli);
// containery.removeChild(loader);
// app2.removeChild(loader);
// app2.innerHTML = "";
containery.appendChild(cul);
//Bug 4
const card = document.createElement("div");
card.setAttribute("class", "card");
card.classList.add("hook"); //Bug 3
const h1 = document.createElement("h1");
h1.textContent = book.name;
const p = document.createElement("p");
p.textContent = `${book.description}...`;
const div = document.createElement("div");
div.setAttribute("class", "imgDiv");
const img = document.createElement("img");
img.src = book.image;
div.appendChild(img);
container.appendChild(card);
card.appendChild(h1);
// card.appendChild(img);
card.appendChild(div);
card.appendChild(p);
//Bug 4
});
//
app2.removeChild(waiter);
console.log(data);
} else {
console.log("No data found");
}
// console.log(snapshot.val());
});
};
$(document).ready(function () {
console.log("ready!");
getData();
});
// const changeTheme = () => {
// const theme = document.getElementById("theme");
// if (theme.classList.contains("dark")) {
// theme.classList.remove("dark");
// theme.classList.add("light");
// } else {
// theme.classList.remove("light");
// theme.classList.add("dark");
// }
// };
// Bug 3 - Starts
const changeTheme = (e) => {
// document.getElementsByClassName("theme")[0].classList.toggle("dark");
// document.getElementsByClassName("hook")[1].classList.toggle("list-group-item");
// document.getElementsByClassName("hook").map((item) => {
// item.classList.toggle("list-group-item");
// });
e.preventDefault();
var temp = document.getElementsByClassName("hook");
temp = Array.from(temp); //Conerting HTML collection to an Array
// console.log(temp); //Bug 3
temp.forEach((item) => {
item.classList.toggle("list-group-item");
});
// console.log(document.getElementsByClassName("hook"));
var headLink = document.getElementsByClassName("headerLink");
headLink = Array.from(headLink);
headLink.forEach((item) => {
item.classList.toggle("headerLinkDark");
});
};
// document.getElementById("show").addEventListener("click", getData);
document.getElementById("toggle").addEventListener("click", changeTheme);
// Bug 3 - Ends
// var instBtn = document.getElementById("instBtn");
//--------------------------------------------------------------------
//---------------Add Event Listener------------------------------------
// instBtn.addEventListener("click", InsertData);
</script>
</body>
</html>