-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (43 loc) · 1.48 KB
/
index.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
// imports
import initializeBarcodeScanner from "./scripts/barcode/barcode-scanning.js";
import showSearch from "./scripts/showSearch.js";
import showScanner from "./scripts/barcode/showScanner.js";
import showFavorite from "./scripts/favorite/showFavorite.js";
import toHome from "./scripts/switch-content/ToHome.js";
import toFavorites from "./scripts/switch-content/ToFavorites.js";
//VARIABLES
const barcodeEl = document.getElementById("barcode-scanner");
const scannerBtn = document.getElementById("scanner");
const stopScannerButton = document.getElementById("stop-scanner-btn")
const scannerContainer = document.querySelector(".scanner-container");
const favoriteBtn = document.getElementById("favorite");
const homeBtn = document.getElementById("home");
// --------- EVENT LISTENER ------------
window.onload = function() {
showSearch(false);
}
// Show Favorite
favoriteBtn.addEventListener('click', ()=>{
console.log("clicked")
showSearch(true);
toFavorites();
})
// Show Home
homeBtn.addEventListener('click', ()=>{
toHome();
showSearch(false);
})
// scanner
scannerBtn.addEventListener('click', ()=>{
// const display = barcodeEl.style.display;
// if (display === "none" || display === "") {
initializeBarcodeScanner();
showScanner(true)
// }else{
// showScanner(false)
// }
})
stopScannerButton.addEventListener(('click'), ()=>{
Quagga.stop()
showScanner(false)
})