-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfile.html
More file actions
126 lines (107 loc) · 3.32 KB
/
Profile.html
File metadata and controls
126 lines (107 loc) · 3.32 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
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Profile</title>
<link rel="stylesheet" href="main.css">
</head>
<style>
header{
padding-bottom: 100px;
}
#post {
margin-right: 1250px;
padding-top: 15px;
color: aliceblue;
}
p{
color: aliceblue;
}
#imageContainer{
padding:10px;
}
h1{
text-align: center;
}
#links{
background-color: aliceblue;
text-align: center;
padding-top: 12px;
padding-bottom: 12px;
}
</style>
<body>
<div id="logo">
WishMatch
</div>
<header>
<h1>Profile</h1>
<div id="links">
<input type="submit" onclick="window.location.href='explore.html'" value = "Explore">
<input type="submit" onclick="window.location.href='Profile.html'" value = "Profile">
</div>
<div id = "cred">
</div>
<div>
<input type="file" accept="image/*" name="image" id="file" onchange="loadFile(event)" style="display: none;">
<button><label for="file" style="cursor: pointer;">Upload Image</label></button>
<div id="imageContainer"></div>
</div>
</header>
<main>
<div id = "messageBox">
</div>
</main>
<script>
var loadFile = function(event) {
var imageContainer = document.getElementById('imageContainer');
var image = document.createElement('img');
image.width = 200;
image.height = 200;
image.src = URL.createObjectURL(event.target.files[0]);
imageContainer.appendChild(image);
};
</script>
<script src = "FirebaseConfig.js"></script>
<script type = "module">
import { email } from './login.html';
const db = getFirestore(firebaseApp);
import { doc, getDoc, getDocs, collection } from "firebase/firestore";
const docRef = doc(db, "profile", `${email}` );
const docSnap = await getDoc(docRef);
let html = ' ';
let result = document.querySelector(`#cred`);
html += `
<p>Username: ${docSnap.data().uname}</p>
<p>First and Last name: ${docSnap.data().fname} + ${docSnap.data().lname}</p>
<p>Email: ${email}</p>
`
result.innerHTML = html;
async function getMessage () {
const messageRef = collection (db, "message", `${docSnap.data().uname}` );
const q = await getDocs (messageRef);
const message = [];
querySnapshot.forEach((doc) => {
message.push(doc.data());
}
renderMessage (message);
}
async function renderMessage (message) {
let messageBox = document.querySelector("#messageBox")
let html = ' ';
for (let msg of message) {
html += `
<div class = "mBox">
<p>Sender: ${message.sender}</p>
<p>Message: ${message.message}</p>
<input type="submit" onclick="window.location.href='contact.html'" value = "Contact">
</div>
`;
}
messageBox.innerHTML = html;
}
getMessage();
</script>
</body>
</html>