-
Notifications
You must be signed in to change notification settings - Fork 0
/
team.html
406 lines (349 loc) · 10.9 KB
/
team.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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="team.css" />
<style>
body {
font-family: "Lucida Sans", "Lucida Sans Regular", "Lucida Grande",
"Lucida Sans Unicode", Geneva, Verdana, sans-serif;
}
</style>
</head>
<body>
<div id="mainTeamDiv">
<div id="fixedDiv">
<div>
<h1 style="margin-left: 10px">Team's</h1>
<p id="addTeam">+ New Team</p>
<input
type="text"
id="searchTeam"
placeholder="Search Your Team"
/><br /><br />
<button id="searchButton">Search</button>
</div>
<hr style="border: 1px solid rgb(75, 68, 186)" />
<p style="font-size: 20px; color: rgb(46, 26, 225); margin-left: 10px">
All Users : <span id="noOfusers">0</span>
</p>
<div id="allUsersAndteam"></div>
</div>
<div id="informationDiv">
<div
style="
height: 10vw;
width: 100%;
background-color: rgb(236, 232, 232);
"
>
<img src="https://i.ibb.co/PtkP22m/Michelle.png">
</div>
<div id="profileMainDiv">
<div><h1 id="profileNameofEachUser">All Users</h1></div>
<div>
<button id="addUserinEachteamButton" style="cursor: pointer;">+ Add Users</button>
</div>
</div>
<input id="searchUserOneachTeam" type="text" placeholder="Search users Of this team">
<button id="Button_searchUserOneachTeam" >Search</button>
<div id="tableHead">
<div>Email</div>
<div>Status</div>
<div>Delete</div>
</div>
<hr style="border: 1px solid grey" />
<div id="addUserEmailAndStatus"></div>
</div>
</div>
</body>
</html>
<script>
let body = document.querySelector("body");
let LSofTeamName = JSON.parse(localStorage.getItem("nameOfteam")) || [];
let addTeam = document.querySelector("#addTeam");
let allUsersAndteam = document.querySelector("#allUsersAndteam");
let noOfusers = document.querySelector("#noOfusers");
let searchTeam = document.querySelector("#searchTeam");
let searchButton = document.querySelector("#searchButton");
let profileNameofEachUser = document.querySelector("#profileNameofEachUser");
let addUserEmailAndStatus=document.querySelector("#addUserEmailAndStatus")
let addUserinEachteamButton=document.querySelector("#addUserinEachteamButton")
let LSaddMemberforEachTeam=JSON.parse(localStorage.getItem("addMemberIn-work"))
let LSodfuser_rederonEachTeam=JSON.parse(localStorage.getItem("rederdataonEachTeam"))||[]
let searchUserOneachTeam=document.querySelector("#searchUserOneachTeam")
let Button_searchUserOneachTeam=document.querySelector("#Button_searchUserOneachTeam")
Button_searchUserOneachTeam.addEventListener("click",function(){
let emailData=searchUserOneachTeam.value
let teamName=profileNameofEachUser.innerText
displaySeachedUser(emailData,teamName)
})
let flagOfAdduser=true
addUserinEachteamButton.addEventListener("click",function(){
if(flagOfAdduser==false){
return
}
flagOfAdduser=false
addUserinEachTeam( LSaddMemberforEachTeam)
})
searchButton.addEventListener("click", function (e) {
e.preventDefault();
let arr = [];
let seachingdata = searchTeam.value;
let flag = false;
LSofTeamName.forEach((e) => {
if (e.name == seachingdata) {
arr.push(e);
flag = true;
}
});
if (flag == false) {
alert("Not Found Your Team , May be Not here");
}else{
rederUsers(arr);
}
});
let flagOfaddTeam=true
addTeam.addEventListener("click", function () {
if( flagOfaddTeam==false){
return
}
flagOfaddTeam=false
createformForteam();
});
function createformForteam() {
let Bigdiv = document.createElement("div");
Bigdiv.setAttribute("id", "divOf_addmember");
addmemberBigDiv = Bigdiv;
let crossDiv = document.createElement("div");
crossDiv.innerText = "X";
crossDiv.addEventListener("click", function () {
Bigdiv.remove();
flagOfaddTeam=true
flag = false;
});
let heading = document.createElement("h1");
heading.innerText = "Create New Team for Work";
let p = document.createElement("p");
p.innerText = "Team name ";
let teamnameBox = document.createElement("input");
teamnameBox.type = "text";
teamnameBox.placeholder = "Enter the name of Your team ";
let breakLine1 = document.createElement("br");
let breakLine2 = document.createElement("br");
let breakLine3 = document.createElement("br");
let breakLine4 = document.createElement("br");
let button = document.createElement("button");
button.innerText = "Add Team";
button.addEventListener("click", function () {
flag = false;
collectnameOfteam(teamnameBox.value);
rederUsers(LSofTeamName);
flagOfaddTeam=true
Bigdiv.remove();
});
flag = true;
Bigdiv.append(
crossDiv,
heading,
p,
teamnameBox,
breakLine1,
breakLine2,
breakLine4,
button
);
body.append(Bigdiv);
}
function collectnameOfteam(name) {
let obj = {
name: name,
data:[]
};
LSofTeamName.push(obj);
localStorage.setItem("nameOfteam", JSON.stringify(LSofTeamName));
}
function numberOfUsers(){
let numOfuers = 0;
LSaddMemberforEachTeam.forEach((e)=>{
numOfuers++
})
profileNameofEachUser.innerText=`All Users (${numOfuers})`
profileNameofEachUser.style.marginLeft="20px"
noOfusers.innerText = numOfuers;
}
numberOfUsers()
function rederUsers(data) {
allUsersAndteam.innerHTML = null;
data.forEach((e, index) => {
let div = document.createElement("div");
div.style.display="flex"
div.addEventListener("click", function () {
rederInfoOfUser(index);
displaydataOfeachUseronteam( LSofTeamName)
});
let h2 = document.createElement("p");
h2.innerText = e.name +" ("+e.data.length+")----";
let remove=document.createElement("p")
remove.setAttribute("id","removeTeam")
remove.innerText= "(X)"
remove.style.float="right"
remove.addEventListener("click",function(){
removeTeam(index)
})
div.append(h2,remove);
allUsersAndteam.append(div);
});
}
rederUsers(LSofTeamName);
function removeTeam(index){
LSofTeamName.forEach((e,index2)=>{
if(index==index2){
LSofTeamName.splice(index,1)
}
})
localStorage.setItem("nameOfteam",JSON.stringify( LSofTeamName))
rederUsers(LSofTeamName)
}
function rederInfoOfUser(index) {
LSofTeamName.forEach((e, index2) => {
if (index == index2) {
profileNameofEachUser.innerText = e.name;
}
});
}
function addUserinEachTeam(data) {
let Bigdiv = document.createElement("div");
Bigdiv.setAttribute("id", "divOf_addmember");
addmemberBigDiv = Bigdiv;
let crossDiv = document.createElement("div");
crossDiv.innerText = "X";
crossDiv.addEventListener("click", function () {
Bigdiv.remove();
flag = false;
});
let heading = document.createElement("h1");
heading.innerText = "Select The User For Your Team";
let p = document.createElement("p");
p.innerText = "User name ";
let breakLine1 = document.createElement("br");
let breakLine2 = document.createElement("br");
let breakLine3 = document.createElement("br");
let breakLine4 = document.createElement("br");
let select=document.createElement("select")
select.style.width="90%"
select.style.padding="8px"
let option1=document.createElement("option")
option1.innerText="Select User "
option1.value=""
select.append(option1)
data.forEach((e)=>{
let option=document.createElement("option")
option.innerText=e.email
option.value=e.email
select.append(option)
})
select.addEventListener("change",function(){
sendDataToLS(select.value)
})
let button = document.createElement("button");
button.innerText = "Add Team";
button.addEventListener("click", function () {
flag = false;
displaydataOfeachUseronteam( LSofTeamName)
rederUsers(LSofTeamName);
flagOfAdduser=true
Bigdiv.remove();
});
flag = true;
Bigdiv.append(
crossDiv,
heading,
p,
select,
breakLine1,
breakLine2,
breakLine4,
button
);
body.append(Bigdiv);
}
function sendDataToLS(data){
for(let i=0;i< LSaddMemberforEachTeam.length;i++){
if( LSaddMemberforEachTeam[i].email==data){
let obj={
email:data,
status:LSaddMemberforEachTeam[i].status
}
LSofTeamName.forEach((e)=>{
if(e.name==profileNameofEachUser.innerText){
e.data.push(obj)
}
})
// LSodfuser_rederonEachTeam.push(obj)
break;
}
}
localStorage.setItem("nameOfteam",JSON.stringify( LSofTeamName))
}
function displaydataOfeachUseronteam(data){
// console.log(data)
addUserEmailAndStatus.innerText=null
data.forEach((a)=>{
if(a.name==profileNameofEachUser.innerText){
a.data.forEach((e,index)=>{
let div=document.createElement("div")
div.setAttribute("id","eachDivOfthreeDiv")
let div1=document.createElement("div")
div1.innerText=e.email
let div2=document.createElement("div")
div2.innerText=e.status
let div3=document.createElement("div")
div3.innerText="Remove"
div3.setAttribute("id","removeCell")
div3.addEventListener("click",function(){
removeUser(index)
rederUsers(LSofTeamName);
})
div.append(div1,div2,div3)
addUserEmailAndStatus.append( div)
})
}
})
}
displaydataOfeachUseronteam( LSofTeamName)
function removeUser(index){
LSofTeamName.forEach((e)=>{
if(e.name==profileNameofEachUser.innerText){
e.data.forEach((a,index2)=>{
if(index==index2){
e.data.splice(index,1)
}
})
}
})
localStorage.setItem("nameOfteam",JSON.stringify( LSofTeamName))
displaydataOfeachUseronteam( LSofTeamName)
}
function displaySeachedUser(emailData,teamName){
let obj={}
obj.name=teamName
let arr=[]
LSofTeamName.forEach((e)=>{
if(e.name==teamName){
e.data.forEach((a)=>{
if(a.email==emailData){
arr.push(a)
}
})
}
})
obj.data=arr
let array=[]
array.push(obj)
displaydataOfeachUseronteam( array)
}
</script>