-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservices-script.js
More file actions
164 lines (144 loc) · 5.96 KB
/
services-script.js
File metadata and controls
164 lines (144 loc) · 5.96 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
function goToHomePage() {
window.location.href = 'index.html';
}
function predictHealth() {
// Get input values
const temperatureCelsius = parseFloat(document.getElementById("temperatureCelsius").value);
const pulseRate = parseInt(document.getElementById("pulseRate").value);
const hrv = parseInt(document.getElementById("hrv").value);
const healthTemperature = parseFloat(document.getElementById("healthTemperature").value);
// Define the health status categories
const healthStatus = {
temperature: "Normal",
pulseRate: "Normal",
hrv: "Normal",
overall: "Healthy"
};
// Check body temperature
if (temperatureCelsius < 5 || temperatureCelsius > 51.7) {
healthStatus.temperature = "Extreme";
healthStatus.overall = "Dangerous";
} else if (temperatureCelsius < 10 || temperatureCelsius > 45.6) {
healthStatus.temperature = "Dangerous";
healthStatus.overall = "Dangerous";
}
// Check pulse rate
if (pulseRate < 40 || pulseRate > 120) {
healthStatus.pulseRate = "Extreme";
healthStatus.overall = "Dangerous";
} else if (pulseRate < 50 || pulseRate > 100) {
healthStatus.pulseRate = "Dangerous";
healthStatus.overall = "Dangerous";
}
// Check HRV
if (hrv < 10 || hrv > 140) {
healthStatus.hrv = "Extreme";
healthStatus.overall = "Dangerous";
} else if (hrv < 20 || hrv > 120) {
healthStatus.hrv = "Dangerous";
healthStatus.overall = "Dangerous";
}
// Output the result
alert(`Health Status:
- Body Temperature: ${healthStatus.temperature}
- Pulse Rate: ${healthStatus.pulseRate}
- HRV: ${healthStatus.hrv}
- Overall: ${healthStatus.overall}`);
}
function analyzeEnvironment() {
// Get input values
const temperatureCelsius = parseFloat(document.getElementById("temperatureCelsius").value);
const humidity = parseFloat(document.getElementById("humidity").value);
// Define the environment status categories
const environmentStatus = {
temperature: "Normal",
humidity: "Normal",
overall: "Healthy"
};
// Check temperature and humidity
if (temperatureCelsius > 48 && humidity > 70) {
environmentStatus.temperature = "Extreme Danger";
environmentStatus.humidity = "Extreme Danger";
environmentStatus.overall = "Extreme Danger";
} else if (temperatureCelsius >= 43 && temperatureCelsius <= 10 && humidity >= 60 && humidity <= 10) {
environmentStatus.temperature = "Dangerous";
environmentStatus.humidity = "Dangerous";
environmentStatus.overall = "Dangerous";
} else if (temperatureCelsius < 13 || humidity < 5) {
environmentStatus.temperature = "Dangerous";
environmentStatus.humidity = "Dangerous";
environmentStatus.overall = "Dangerous";
}
// Output the result
alert(`Environment Status:
- Temperature: ${environmentStatus.temperature}
- Humidity: ${environmentStatus.humidity}
- Overall: ${environmentStatus.overall}`);
}
document.getElementById("serviceType").addEventListener("change", function() {
var selectedService = this.value;
var questionContainer = document.getElementById("questionContainer");
questionContainer.innerHTML = "";
if (selectedService === "healthCheck") {
// Ask questions for health check
questionContainer.innerHTML = `
<h2>Health Check</h2>
<div class="input-group">
<label>Select Animal Type:</label>
<select id="animalType">
<option value="cow">Cow</option>
<option value="buffalo">Buffalo</option>
<!-- Add other animal options -->
</select>
</div>
<div class="input-group">
<label>Temperature in Celsius:</label>
<input type="number" id="temperatureCelsius">
</div>
<div class="input-group">
<label>Humidity:</label>
<input type="number" id="humidity">
</div>
<h3>Enter the data of Health Monitor Device:</h3>
<div class="input-group">
<label>Temperature (°C):</label>
<input type="number" id="healthTemperature">
</div>
<div class="input-group">
<label>Pulse Rate:</label>
<input type="number" id="pulseRate">
</div>
<div class="input-group">
<label>HRV (Heart Rate Variability):</label>
<input type="number" id="hrv">
</div>
<div class="input-group">
<label>Calories Burned:</label>
<input type="number" id="caloriesBurned">
</div>
<button onclick="predictHealth()">Predict Health</button>
`;
} else if (selectedService === "environmentAnalysis") {
// Ask questions for environment analysis
questionContainer.innerHTML = `
<h2>Environment Analysis</h2>
<div class="input-group">
<label>Select Animal Name:</label>
<select id="animalName">
<option value="cow">Cow</option>
<option value="buffalo">Buffalo</option>
<!-- Add other animal options -->
</select>
</div>
<div class="input-group">
<label>Temperature in Celsius:</label>
<input type="number" id="temperatureCelsius">
</div>
<div class="input-group">
<label>Humidity:</label>
<input type="number" id="humidity">
</div>
<button onclick="analyzeEnvironment()">Analyze Environment</button>
`;
}
});