-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoint-valeur.html
More file actions
180 lines (154 loc) · 5.67 KB
/
point-valeur.html
File metadata and controls
180 lines (154 loc) · 5.67 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
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Convertisseur Point-Valeur</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 20px;
display: flex;
justify-content: center;
align-items: flex-start;
min-height: 100vh;
}
.container {
width: 100%;
max-width: 500px;
background-color: #fff;
padding: 20px;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
color: #4287f5;
margin-bottom: 20px;
}
label {
display: block;
font-size: 15px;
margin: 12px 0 5px;
color: #555;
}
input {
width: 100%;
padding: 12px;
border: 1px solid #ccc;
border-radius: 8px;
font-size: 16px;
box-sizing: border-box;
}
.btn {
display: block;
box-sizing: border-box;
width: 100%;
padding: 12px;
margin-top: 15px;
font-size: 16px;
border: none;
border-radius: 8px;
color: white;
background-color: #4287f5;
cursor: pointer;
text-align: center;
text-decoration: none;
display: inline-block;
transition: background-color 0.2s ease;
}
.btn:hover {
background-color: #2d5cc7;
}
.result, .formula {
margin-top: 15px;
font-size: 16px;
text-align: center;
color: #444;
}
</style>
</head>
<body>
<div class="container">
<h2>Convertisseur Point-Valeur</h2>
<div class="row">
<div>
<label for="lower_bound">Borne inférieure du signal:</label>
<input type="number" id="lower_bound" value="6400" oninput="convertPointToValue()">
<label for="upper_bound">Borne supérieure du signal:</label>
<input type="number" id="upper_bound" value="32000" oninput="convertPointToValue()">
</div>
<div>
<label for="scale_min">Échelle (Min):</label>
<input type="number" id="scale_min" value="0" oninput="convertPointToValue()">
<label for="scale_max">Échelle (Max):</label>
<input type="number" id="scale_max" value="100" oninput="convertPointToValue()">
</div>
</div>
<label for="point">Point :</label>
<input type="number" id="point" oninput="convertPointToValue()">
<div class="result" id="result"></div>
<div class="formula" id="formula"></div>
<label for="value">Valeur :</label>
<input type="number" id="value" oninput="convertValueToPoint()">
<button class="btn" onclick="resetAll()">Réinitialiser</button>
<a href="index.html" class="btn">⬅️ Retour à l’accueil</a>
</div>
<script>
function convertPointToValue() {
const point = parseFloat(document.getElementById("point").value);
const lowerBound = parseFloat(document.getElementById("lower_bound").value);
const upperBound = parseFloat(document.getElementById("upper_bound").value);
const scaleMin = parseFloat(document.getElementById("scale_min").value);
const scaleMax = parseFloat(document.getElementById("scale_max").value);
if (lowerBound >= upperBound || scaleMin >= scaleMax) {
document.getElementById("result").innerText = "Erreur : bornes incorrectes.";
return;
}
const value = scaleMin + (point - lowerBound) * (scaleMax - scaleMin) / (upperBound - lowerBound);
document.getElementById("value").value = value.toFixed(2);
document.getElementById("result").innerText = "";
updateFormula();
}
function convertValueToPoint() {
const value = parseFloat(document.getElementById("value").value);
const lowerBound = parseFloat(document.getElementById("lower_bound").value);
const upperBound = parseFloat(document.getElementById("upper_bound").value);
const scaleMin = parseFloat(document.getElementById("scale_min").value);
const scaleMax = parseFloat(document.getElementById("scale_max").value);
if (lowerBound >= upperBound || scaleMin >= scaleMax) {
document.getElementById("result").innerText = "Erreur : bornes incorrectes.";
return;
}
const point = lowerBound + (value - scaleMin) * (upperBound - lowerBound) / (scaleMax - scaleMin);
document.getElementById("point").value = point.toFixed(2);
document.getElementById("result").innerText = "";
updateFormula();
}
function updateFormula() {
const lowerBound = parseFloat(document.getElementById("lower_bound").value);
const upperBound = parseFloat(document.getElementById("upper_bound").value);
const scaleMin = parseFloat(document.getElementById("scale_min").value);
const scaleMax = parseFloat(document.getElementById("scale_max").value);
if (lowerBound >= upperBound || scaleMin >= scaleMax) {
document.getElementById("formula").innerText = "";
return;
}
const formulaText = `Valeur = ${scaleMin} + (signal - ${lowerBound}) × (${scaleMax} - ${scaleMin}) / (${upperBound} - ${lowerBound})`;
document.getElementById("formula").innerText = formulaText;
}
function resetAll() {
document.getElementById("lower_bound").value = 6400;
document.getElementById("upper_bound").value = 32000;
document.getElementById("scale_min").value = 0;
document.getElementById("scale_max").value = 100;
document.getElementById("point").value = "";
document.getElementById("value").value = "";
document.getElementById("result").innerText = "";
document.getElementById("formula").innerText = "";
}
</script>
</body>
</html>