-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschedulerEmp.js
56 lines (48 loc) · 3.48 KB
/
schedulerEmp.js
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
// Replace schedule with data we get from our database and then format into an array like schedule below.
let schedule = [
{ Employee: "Pele", Monday: "5:30pm - 7:00pm", Tuesday: "Unavailable", Wednesday: "Unavailable", Thursday: "Unavailable", Friday: "Available", Saturday: "11:00am - 1:00pm", Sunday: "8:00am - 12:00pm", },
{ Employee: "Michael Phelps", Monday: "Unavailable", Tuesday: "3:00pm - 8:00pm", Wednesday: "Unavailable", Thursday: "2:00pm - 12:00am", Friday: "8:00am - 11:00am", Saturday: "12:00pm - 5:00pm", Sunday: "7:00am - 9:00am", },
{ Employee: "Babe Ruth", Monday: "Available", Tuesday: "Unavailable", Wednesday: "1:00pm - 4:00pm", Thursday: "8:00am - 4:00pm", Friday: "Unavailable", Saturday: "8:00am - 5:00pm", Sunday: "Available", },
{ Employee: "Muhammad Ali", Monday: "5:00pm - 10:00pm", Tuesday: "12:00pm - 8:00pm", Wednesday: "Available", Thursday: "2:00pm - 5:00pm", Friday: "8:00am - 6:00pm", Saturday: "10:00am - 12:00pm", Sunday: "8:00pm - 12:00am", },
{ Employee: "Tiger Woods", Monday: "7:00am - 4:00pm", Tuesday: "Available", Wednesday: "8:00am - 3:00pm", Thursday: "Unavailable", Friday: "Unavailable", Saturday: "Unavailable", Sunday: "Unavailable", },
{ Employee: "Diego Maradona", Monday: "5:30pm - 7:00pm", Tuesday: "Unavailable", Wednesday: "Unavailable", Thursday: "Unavailable", Friday: "Available", Saturday: "11:00am - 1:00pm", Sunday: "8:00am - 12:00pm", },
{ Employee: "Tony Hawk", Monday: "Unavailable", Tuesday: "3:00pm - 8:00pm", Wednesday: "Unavailable", Thursday: "2:00pm - 12:00am", Friday: "8:00am - 11:00am", Saturday: "12:00pm - 5:00pm", Sunday: "7:00am - 9:00am", },
{ Employee: "Aaron Rodgers", Monday: "Available", Tuesday: "Unavailable", Wednesday: "1:00pm - 4:00pm", Thursday: "8:00am - 4:00pm", Friday: "Unavailable", Saturday: "8:00am - 5:00pm", Sunday: "Available", },
{ Employee: "Lightning McQueen", Monday: "5:00pm - 10:00pm", Tuesday: "12:00pm - 8:00pm", Wednesday: "Available", Thursday: "2:00pm - 5:00pm", Friday: "8:00am - 6:00pm", Saturday: "10:00am - 12:00pm", Sunday: "8:00pm - 12:00am", },
{ Employee: "Novak Djokovic", Monday: "7:00am - 4:00pm", Tuesday: "Available", Wednesday: "8:00am - 3:00pm", Thursday: "Unavailable", Friday: "Unavailable", Saturday: "Unavailable", Sunday: "Unavailable", }
]
const GenerateTableModule = (function() {
let table = null;
let data = [];
const initialize = function(tableSelector, arr) {
table = tableSelector;
data = arr;
};
const _generateTableHead = function() {
let thead = table.createTHead();
let row = thead.insertRow();
for (let key in data[0]) {
let th = document.createElement("th");
let text = document.createTextNode(key);
th.appendChild(text);
row.appendChild(th);
}
};
const generateTable = function() {
for (let element of data) {
let row = table.insertRow();
for (key in element) {
let cell = row.insertCell();
let text = document.createTextNode(element[key]);
cell.appendChild(text);
}
}
_generateTableHead();
};
return { initialize, generateTable };
})();
let table = document.querySelector("table.empSchedule");
// Here is where schedule array is being used.
GenerateTableModule.initialize(table, schedule)
GenerateTableModule.generateTable();
module.exports = _generateTableHead;