-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindecision-cost.html
More file actions
270 lines (244 loc) · 8.69 KB
/
Copy pathindecision-cost.html
File metadata and controls
270 lines (244 loc) · 8.69 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Meeting - Indecision Cost Calculator</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f7fa;
margin: 0;
padding: 20px;
display: flex;
justify-content: center;
}
.container {
background-color: white;
padding: 20px;
border-radius: 10px;
max-width: 800px;
width: 100%;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
margin-bottom: 20px;
}
.input-group {
display: flex;
justify-content: space-between;
align-items: center;
margin: 10px 0;
}
.input-group label {
width: 160px;
font-weight: bold;
}
.input-group input[type="range"] {
width: 60%;
}
.input-group input[type="number"] {
width: 80px;
}
button {
padding: 10px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
margin-top: 15px;
cursor: pointer;
width: 100%;
}
button:hover {
background-color: #0056b3;
}
.tabs {
display: flex;
margin-bottom: 10px;
}
.tablink {
flex: 1;
padding: 10px;
background-color: #ccc;
border: none;
cursor: pointer;
font-weight: bold;
}
.tablink.active {
background-color: #007bff;
color: white;
}
.tabcontent {
display: none;
}
.tabcontent.active {
display: block;
}
#result, #totalWastage {
text-align: center;
font-weight: bold;
margin-top: 15px;
}
</style>
</head>
<body>
<div class="container">
<h1>Meeting - Indecision Cost Calculator</h1>
<div class="input-group">
<label for="numPeople">Number of People:</label>
<input type="range" id="numPeople" min="1" max="50" value="5" oninput="updateValue('numPeople')">
<input type="number" id="numPeopleInput" value="5" oninput="syncInput('numPeopleInput', 'numPeople')">
</div>
<div class="input-group">
<label for="minRate">Min Daily Rate ($):</label>
<input type="range" id="minRate" min="100" max="2000" value="400" oninput="updateValue('minRate')">
<input type="number" id="minRateInput" value="400" oninput="syncInput('minRateInput', 'minRate')">
</div>
<div class="input-group">
<label for="maxRate">Max Daily Rate ($):</label>
<input type="range" id="maxRate" min="100" max="2000" value="800" oninput="updateValue('maxRate')">
<input type="number" id="maxRateInput" value="800" oninput="syncInput('maxRateInput', 'maxRate')">
</div>
<div class="input-group">
<label for="duration">Duration (hrs):</label>
<input type="range" id="duration" min="0.5" max="8" step="0.5" value="1" oninput="updateValue('duration')">
<input type="number" id="durationInput" step="0.5" value="1" oninput="syncInput('durationInput', 'duration')">
</div>
<button onclick="calculateAndTrack()">Calculate Indecision Cost</button>
<div id="result"></div>
<div class="tabs">
<button class="tablink active" onclick="switchTab('enterprise')">Enterprise</button>
<button class="tablink" onclick="switchTab('greenfield')">Greenfield</button>
</div>
<div id="tab-enterprise" class="tabcontent active">
<canvas id="chart-enterprise" height="150"></canvas>
</div>
<div id="tab-greenfield" class="tabcontent">
<canvas id="chart-greenfield" height="150"></canvas>
</div>
<div id="totalWastage"></div>
<button onclick="resetHistory()">Reset History</button>
</div>
<script>
const datasets = {
enterprise: { timestamps: [], min: [], max: [], avg: [], meta: [], chart: null },
greenfield: { timestamps: [], min: [], max: [], avg: [], meta: [], chart: null }
};
let currentTab = 'enterprise';
function updateValue(id) {
const val = document.getElementById(id).value;
document.getElementById(id + 'Input').value = val;
}
function syncInput(inputId, rangeId) {
const val = document.getElementById(inputId).value;
document.getElementById(rangeId).value = val;
}
function switchTab(tab) {
currentTab = tab;
document.querySelectorAll('.tablink').forEach(btn => btn.classList.remove('active'));
document.querySelectorAll('.tabcontent').forEach(div => div.classList.remove('active'));
document.querySelector(`[onclick*="${tab}"]`).classList.add('active');
document.getElementById(`tab-${tab}`).classList.add('active');
updateTotal();
}
function calculateAndTrack() {
const minRate = +document.getElementById('minRate').value;
const maxRate = +document.getElementById('maxRate').value;
if (minRate > maxRate) {
alert("Min Daily Rate cannot be more than Max Daily Rate.");
return;
}
const people = +document.getElementById('numPeople').value;
const duration = +document.getElementById('duration').value;
const minCost = people * (minRate / 8) * duration;
const maxCost = people * (maxRate / 8) * duration;
const avgCost = (minCost + maxCost) / 2;
document.getElementById('result').innerText =
`Estimated Wastage: $${minCost.toFixed(2)} - $${maxCost.toFixed(2)} (Avg: $${avgCost.toFixed(2)})`;
const now = new Date().toLocaleString();
const d = datasets[currentTab];
d.timestamps.push(now);
d.min.push(minCost);
d.max.push(maxCost);
d.avg.push(avgCost);
d.meta.push({ people, minRate, maxRate, duration });
d.chart.update();
saveHistory();
updateTotal();
}
function updateTotal() {
const d = datasets[currentTab];
const minSum = d.min.reduce((a, b) => a + b, 0);
const maxSum = d.max.reduce((a, b) => a + b, 0);
const avgSum = d.avg.reduce((a, b) => a + b, 0);
document.getElementById('totalWastage').innerText =
`Total Indecision Cost (${currentTab}): $${minSum.toFixed(2)} - $${maxSum.toFixed(2)} (Avg: $${avgSum.toFixed(2)})`;
}
function initCharts() {
['enterprise', 'greenfield'].forEach(id => {
const ctx = document.getElementById('chart-' + id).getContext('2d');
datasets[id].chart = new Chart(ctx, {
type: 'line',
data: {
labels: datasets[id].timestamps,
datasets: [
{ label: 'Min', data: datasets[id].min, borderColor: 'green', fill: false },
{ label: 'Avg', data: datasets[id].avg, borderColor: 'orange', fill: false },
{ label: 'Max', data: datasets[id].max, borderColor: 'red', fill: false }
]
},
options: {
responsive: true,
plugins: {
tooltip: {
callbacks: {
afterLabel: ctx => {
const i = ctx.dataIndex;
const m = datasets[id].meta[i];
return [`People: ${m.people}`, `Min Rate: $${m.minRate}`, `Max Rate: $${m.maxRate}`, `Duration: ${m.duration} hrs`];
}
}
},
title: { display: true, text: `Indecision Cost Over Time - ${id}` }
}
}
});
});
}
function saveHistory() {
const h = {};
for (const k in datasets) {
h[k] = datasets[k].timestamps.map((t, i) => ({
t, min: datasets[k].min[i], max: datasets[k].max[i], avg: datasets[k].avg[i], meta: datasets[k].meta[i]
}));
}
localStorage.setItem("indecisionCostTabs", JSON.stringify(h));
}
function loadHistory() {
const h = JSON.parse(localStorage.getItem("indecisionCostTabs") || "{}");
for (const k in h) {
h[k].forEach(pt => {
datasets[k].timestamps.push(pt.t);
datasets[k].min.push(pt.min);
datasets[k].max.push(pt.max);
datasets[k].avg.push(pt.avg);
datasets[k].meta.push(pt.meta);
});
}
}
function resetHistory() {
localStorage.removeItem("indecisionCostTabs");
for (const k in datasets) {
['timestamps', 'min', 'max', 'avg', 'meta'].forEach(arr => datasets[k][arr].length = 0);
datasets[k].chart.update();
}
updateTotal();
}
loadHistory();
window.onload = initCharts;
</script>
</body>
</html>