Repository navigation
Expand file tree
/
Copy pathmain.html
More file actions
116 lines (101 loc) · 5.13 KB
/
Copy pathmain.html
File metadata and controls
116 lines (101 loc) · 5.13 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My BCIT Project</title>
<meta name="comp1800 boilerplate code" content="my bcit project">
<meta name="author" content="BCIT">
<!-- Bootstrap, firebase-auth-ui -->
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/4.6.1/firebase-ui-auth.css" />
<!-- Optional styles and scripts of your own -->
<link type="text/css" href="styles/my_style.css">
</head>
<body>
<!-------------------------------------->
<!-- The following is HTML for layout -->
<!-------------------------------------->
<!-- Header Navigation Bar -->
<nav class="navbar navbar-expand-lg navbar-light bg-info">
<div class="container-fluid">
<a class="navbar-brand" href="#">Carly's Team99</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="login.html">Login/Signup</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<h1 class="display-4"> Hello, <span id="username">CST!</span> </h1>
<h1> You are now logged in. </h1>
<h1> This is a collection of web cams in Vancouver. </h1>
<div id="cities-go-here"> </div>
<div id="webcams-go-here"></div>
</div>
<!----------------------------------------------->
<!-- JS: Boostrap, Firebase, API related, JQuery -->
<!----------------------------------------------->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous">
</script>
<script src="https://www.gstatic.com/firebasejs/8.2.9/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.9/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.9/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/ui/4.6.1/firebase-ui-auth.js"></script>
<!-- Link to the api keys for your firebase project -->
<script src="scripts/firebase_api_elmo.js"></script>
<!--------------------------------------------------------------------->
<!-- JS files: Your own JavaScript functions included here -->
<!--------------------------------------------------------------------->
<script src="scripts/my_functions.js"></script>
<script>
sayHello();
function displayWebcams() {
//console.log("inside display web cams");
db.collection("webcams")
.where("fields.geo_local_area", "in", ["Downtown", "Oakridge"]) //new query to look for field in a set/array
.get() //READ asynch
.then(function (snapcollection) {
snapcollection.forEach(function (doc) {
//console.log(doc.data());
//console.log(doc.data().fields.name);
var id = doc.id; //document id of that webcam
var name = doc.data().fields.name;
//$('#webcams-go-here').append($('<p id = ${id}> ${name} </p>'));
$("#webcams-go-here").append("<p style='cursor:pointer' id='" + id + "'>" + name + "</p>");
addWebcamListener(id);
})
})
}
displayWebcams();
function addWebcamListener(id) {
document.getElementById(id)
.addEventListener("click", function () {
console.log(id + "was clicked!")
//window.location.href="details.html";
//when we redirect, tack on after "?" the id of the webcam
window.location.href = "details.html?id=" + id;
});
}
</script>
</body>
</html>