-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStudentGroup.html
245 lines (207 loc) · 7.25 KB
/
StudentGroup.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="/Project/Students/Groups/SG.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,[email protected],100..700,0..1,-50..200" />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<title>Masai Connect</title>
</head>
<body>
<div id="main">
<div id="left">
<div>
<div>
<img src="/Project/Images/Logo.png" id="logo" alt="Masai Connect">
</div>
<div><span class="material-symbols-outlined">
grid_view
</span><p><a href="/Dashboard.html">Dashboard</a></p></div>
<div > <span class="material-symbols-outlined">
person_search
</span><p><a href="/Search.html">Search</a></p></div>
<div id="task123"><span class="material-symbols-outlined">
groups
</span><p><a href="#" id="must">Groups</a></p></div>
<div ><span class="material-symbols-outlined">
task_alt
</span><p><a href="/Tasks.html">Tasks</a></p></div>
<div ><span class="material-symbols-outlined">
chat
</span><p><a href="/Discussion.html">Discussion</a></p></div>
<div><span class="material-symbols-outlined">
account_circle
</span><p><a href="/Account.html">Account</a></p></div>
</div>
<div>
<div><span class="material-symbols-outlined">
logout
</span><p><a href="" id="LogoutBtn">Logout</a></p></div>
</div>
</div>
<div id="right">
<div id="r1">
<div>
<span class="material-symbols-outlined" id="slide" class="icon">
keyboard_double_arrow_right
</span>
</div>
<div>
<img src="/Project/Images/dark theme icon/moon.png" alt="" id="darkmode_btn" class="icon">
<img src="/Project/Images/man.png" alt="" id="profile">
</div>
</div>
<div>
<p>Groups</p>
</div>
<div id="group00">
</div>
</div>
</div>
</body>
</html>
<script>
let visible = true;
let slidebtn = document.getElementById("slide");
let slide = document.getElementById("left");
slidebtn.addEventListener("click", function () {
if (visible == true) {
slide.style.display = 'none'
visible = false;
right.style.width = '100%';
}
else if (visible == false) {
slide.style.display = 'flex'
visible = true;
right.style.width = '86%';
}
})
let a=localStorage.getItem("current")
let id=localStorage.getItem("userid")
let API =` https://64b63253df0839c97e151a61.mockapi.io/api/admin/${a}/${id}`;
console.log(API);
let newsButton=document.getElementById("newsbutton");
let newsinput=document.getElementById("newsinput");
// <div>
// <div>
// <div><h3>Group Name</h3></div>
// <div>
// <button id="delete">DELETE</button>
// </div>
// </div>
// <div>
// <input type="text" name="" id="newsinput" placeholder="Write Your Announcement">
// <button id="newsbutton">SEND ANNOUNCEMENT</button>
// </div>
// <div>
// <h2>Latest Announcement</h2>
// <p></p>
// </div>
// </div>
setInterval(TEACH,2000)
async function TEACH(){
try {
let res= await fetch(`https://connect-api-0z76.onrender.com/groups`);
let data=await res.json();
console.log(data);
NEWS(data);
} catch (error) {
console.log(error);
}
}
TEACH();
let all=document.getElementById("group00");
function NEWS(arr){
all.innerHTML="";
if(arr.length==0){
let no=document.createElement("h1");
no.innerText="There is No groups present right now."
no.style.textAlign="center";
all.append(no);
}else{
console.log("CHECK");
arr.reverse();
arr.forEach(function(el,ind){
let div=document.createElement("div");
div.style.marginBottom="20px"
let div1=document.createElement("div");
let div2=document.createElement("div");
let h3=document.createElement("h3");
h3.innerText=el.name;
div2.append(h3);
div1.append(div2);
let div5=document.createElement("div");
let h2=document.createElement("h2");
h2.innerText="Announcements :-";
let ul=document.createElement("ul");
for(let i=el.news.length-1;i>=0;i--){
let p=document.createElement("li");
p.innerText=el.news[i];
p.style.margin="20px";
p.style.fontSize="20px"
ul.append(p);
}
div5.append(h2,ul);
div5.style.paddingBottom="30px";
div.append(div1,div5);
all.append(div);
})}
}
let LogoutBtn = document.getElementById("LogoutBtn");
LogoutBtn.addEventListener("click", async function (event) {
console.log("hiiii");
event.preventDefault();
let status = false;
try {
let res = await fetch(`https://64b63253df0839c97e151a61.mockapi.io/api/admin/${a}/${id}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ active: status }),
});
window.location.href = "/index.html";
} catch (error) {
console.log(error);
}
});
// Dark Mode
if (localStorage.getItem("darkmode") === null) {
localStorage.setItem("darkmode", "false");
}
function enableDarkMode() {
document.body.classList.add("dark-mode");
const darkButton = document.getElementById("darkmode_btn");
const slideBtn = document.getElementById("slide");
darkButton.src = "/Project/Images/dark theme icon/sun.png";
slideBtn.style.color = "white";
}
function disableDarkMode() {
document.body.classList.remove("dark-mode");
const darkButton = document.getElementById("darkmode_btn");
const slideBtn = document.getElementById("slide");
darkButton.src = "/Project/Images/dark theme icon/moon.png";
slideBtn.style.color = "black";
}
function toggleDarkMode() {
if (localStorage.getItem("darkmode") === "true") {
enableDarkMode();
} else {
disableDarkMode();
}
}
document.getElementById("darkmode_btn").addEventListener("click", function () {
if (localStorage.getItem("darkmode") === "false") {
localStorage.setItem("darkmode", "true")
enableDarkMode();
} else if (localStorage.getItem("darkmode") === "true") {
localStorage.setItem("darkmode", "false")
disableDarkMode();
}
toggleDarkMode();
});
toggleDarkMode();
</script>