-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
158 lines (132 loc) · 6 KB
/
index.html
File metadata and controls
158 lines (132 loc) · 6 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
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
<!doctype html>
<html>
<head>
<title>Socket.IO Testing</title>
<!-- Bootstrap imports -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin="anonymous"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script>
const socket = io();
function listenServer() {
console.log('function run')
socket.emit('datainput', 'pageLoaded');
socket.on('datainput', (data) => {
console.log(data);
if(data.email !== undefined || data.email !== null){
document.getElementById('dataView').innerHTML=
`
<li>hi, Your email id is this ${data.email} </li>
<li>Your Day 1 Work is ${data.d1}</li>
<li>Your Day 2 Work is ${data.d2}</li>
<li>Your Day 3 Work is ${data.d3}</li>
<li>Your Day 4 Work is ${data.d4}</li>
`;
}
chart(data)
});
}
function dataSubmit(){
let email = document.getElementById("email").value;
let day1 = document.getElementById("day1").value;
let day2 = document.getElementById("day2").value;
let day3 = document.getElementById("day3").value;
let day4 = document.getElementById("day4").value;
let data = {
email : email,
d1: day1,
d2:day2,
d3:day3,
d4:day4
}
if(data.email.length>0 && data.d1.length>0 && data.d2.length>0){
listenServer();
return socket.emit('dataSave', data)
}else{
return alert('please add email');
}
}
function chart(chartdata){
var ctx = document.getElementById('myChart').getContext('2d');
var options={
};
var myDoughnutChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: ["Day 1", "Day 2", "Day 3", "Day 4"],
datasets: [{
label: '# of Votes',
data: [Number(chartdata.d1), Number(chartdata.d2),Number(chartdata.d3),Number(chartdata.d4),],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
],
borderColor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
],
borderWidth: 1
}]
},
});
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script>
</head>
<body>
<div style="height:420px; width:420px">
<canvas id="myChart" width="420" height="420"></canvas>
</div>
<form class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="email" placeholder="Enter email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="day1">Day 1 Hours:</label>
<div class="col-sm-10">
<input type="number" min="1" max="20" class="form-control" id="day1" placeholder="Enter No of Hours Worked">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="day2">Day 2 Hours:</label>
<div class="col-sm-10">
<input type="number" min="1" max="20" class="form-control" id="day2" placeholder="Enter No of Hours Worked">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="day3">Day 3 Hours:</label>
<div class="col-sm-10">
<input type="number" min="1" max="20" class="form-control" id="day3" placeholder="Enter No of Hours Worked">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="day4">Day 4 Hours:</label>
<div class="col-sm-10">
<input type="number" min="1" max="20" class="form-control" id="day4" placeholder="Enter No of Hours Worked">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="button" class="btn btn-default" onclick="dataSubmit()">Submit</button>
</div>
</div>
</form>
<div id="socket">
<ul id='dataView'></ul>
</div>
</body>
</html>