-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeed.html
128 lines (113 loc) · 4 KB
/
feed.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ChoreConnect - Task Feed</title>
<link rel="stylesheet" href="feet.css">
</head>
<body>
<header>
<nav>
<div class="logo">ChoreConnect</div>
<ul>
<li><a id="profile" href="#home"></a></li>
<li><a href="#profile">YourJob</a></li>
<li><a href="#messages">JobApplied</a></li>
<li><a href="./about.html">About</a></li>
<li><a id="logout" class="btn">Logout</a></li>
</ul>
</nav>
</header>
<section class="feed">
</section>
<footer>
<p>© 2024 ChoreConnect. All rights reserved.</p>
<a href="mailto:[email protected]">Contact Us</a>
</footer>
</body>
<script>
var user;
var template = '<div class="feed-container"><div class="task"><h3>Task Title: Lawn Mowing</h3><p>Description: Need someone to mow my lawn this weekend. Must have your own equipment.</p><p>Category: Household Chores</p><p>Posted by: User123</p><p>Price:</p><div class="task-actions"><button class="btn accept">Apply</button></div></div</div>'
function getQueryParam(name) {
const params = new URLSearchParams(window.location.search);
return params.get(name);
}
const userParam = getQueryParam('user');
if (userParam) {
// Decode and parse the JSON string back into an object
user = JSON.parse(decodeURIComponent(userParam));
} else {
console.log('User parameter not found');
}
//
//
document.querySelector("#profile").addEventListener("click",function(){
window.location.href = "./profile.html?user=" + encodeURIComponent(JSON.stringify(user));
})
//
document.querySelector("#profile").textContent = user.name
// suggesting feeds....
var jobData;
async function fetchJobs() {
try {
const response = await fetch(`https://statuscodebackend.onrender.com/jobs`);
if (!response.ok) {
throw new Error('Network response was not ok');
}
jobData = await response.json();
} catch (error) {
console.error('Error fetching users:', error);
}
}
document.querySelector("#logout").addEventListener("click",function(){
window.location.href = "./index.html"
})
fetchJobs()
var trackedJob = []
setTimeout(()=>{
var userTags = user.tags
for(var item=0;item<userTags.length;item++){
const filteredData = jobData.filter(items =>
Array.isArray(items.tags) && items.tags.includes(userTags[item])
);
for(var i=0;i<filteredData.length;i++){
if(filteredData[i].ownerEmail != user.email && !trackedJob.includes(filteredData[i])){
trackedJob.push(filteredData[i])
}
}
}
console.log(trackedJob)
var m = document.querySelector("section")
for(var i=0;i<trackedJob.length;i++){
m.innerHTML += template
}
var jj = document.querySelectorAll(".task")
for(var ii=0;ii<jj.length;ii++){
jj[ii].querySelector("h3").textContent = "Task Title: " + trackedJob[ii].title
var alle = jj[ii].querySelectorAll("p")
alle[0].textContent = "Description: " + trackedJob[ii].des
var cat =""
for(var n=0;n<trackedJob[ii].tags.length;n++){
if(n == trackedJob[ii].tags.length-1){
cat += trackedJob[ii].tags[n]
}
else{
cat += trackedJob[ii].tags[n] + ","
}
}
alle[1].textContent = "Category: " + cat
alle[2].textContent = "Posted By: " + trackedJob[ii].ownerEmail
alle[3].textContent = "Price: " + trackedJob[ii].price
console.log(trackedJob[ii])
}
all_b = document.querySelectorAll(".btn")
var all_applied = user.appliedJobId
for(var ib=0;ib<all_b.length;ib++){
all_b[ib].addEventListener("click",function(){
this.textContent = "Applied"
})
}
},2000)
</script>
</html>