5digit commited on
Commit
8519151
·
verified ·
1 Parent(s): 456d775

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +79 -18
index.html CHANGED
@@ -1,19 +1,80 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Конвертер размеров колец</title>
7
+ <style>
8
+ body { font-family: Arial, sans-serif; }
9
+ .container { max-width: 600px; margin: auto; padding: 20px; }
10
+ input, select { width: 100%; margin: 10px 0; padding: 10px; }
11
+ .result { margin-top: 20px; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <div class="container">
16
+ <h1>Конвертер размеров колец</h1>
17
+ <input type="number" id="value" placeholder="Введите значение" />
18
+ <select id="unitFrom">
19
+ <option value="in_diameter">Диаметр в дюймах (in)</option>
20
+ <option value="mm_diameter">Диаметр в миллиметрах (mm)</option>
21
+ <option value="in_circumference">Длина окружности в дюймах (in)</option>
22
+ <option value="mm_circumference">Длина окружности в миллиметрах (mm)</option>
23
+ </select>
24
+ <button onclick="convert()">Перевести</button>
25
+
26
+ <div class="result" id="result"></div>
27
+ </div>
28
+
29
+ <script>
30
+ function convert() {
31
+ const value = parseFloat(document.getElementById('value').value);
32
+ const unitFrom = document.getElementById('unitFrom').value;
33
+ const resultDiv = document.getElementById('result');
34
+
35
+ if (isNaN(value)) {
36
+ resultDiv.innerHTML = "Пожалуйста, введите корректное значение.";
37
+ return;
38
+ }
39
+
40
+ // Переменные для хранения результатов
41
+ let inDiameter, mmDiameter, inCircumference, mmCircumference;
42
+
43
+ // Конвертация входного значения
44
+ if (unitFrom === 'in_diameter') {
45
+ inDiameter = value;
46
+ mmDiameter = value * 25.4; // 1 дюйм = 25.4 мм
47
+ inCircumference = value * Math.PI; // C = π * d
48
+ mmCircumference = mmDiameter * Math.PI; // C = π * d
49
+ } else if (unitFrom === 'mm_diameter') {
50
+ mmDiameter = value;
51
+ inDiameter = value / 25.4; // 1 мм = 0.03937 дюйма
52
+ inCircumference = inDiameter * Math.PI;
53
+ mmCircumference = value * Math.PI;
54
+ } else if (unitFrom === 'in_circumference') {
55
+ inCircumference = value;
56
+ mmCircumference = value * 25.4; // 1 дюйм = 25.4 мм
57
+ inDiameter = value / Math.PI; // d = C / π
58
+ mmDiameter = inDiameter * 25.4;
59
+ } else if (unitFrom === 'mm_circumference') {
60
+ mmCircumference = value;
61
+ inCircumference = value / 25.4; // 1 мм = 0.03937 дюйма
62
+ mmDiameter = value / Math.PI; // d = C / π
63
+ inDiameter = mmDiameter / 25.4;
64
+ }
65
+
66
+ // Формирование вывода
67
+ resultDiv.innerHTML = `
68
+ <strong>Результаты:</strong><br>
69
+ Диаметр:<br>
70
+ ${inDiameter.toFixed(4)} дюймов (in)<br>
71
+ ${mmDiameter.toFixed(4)} миллиметров (mm)<br>
72
+ <br>
73
+ Длина окружности:<br>
74
+ ${inCircumference.toFixed(4)} дюймов (in)<br>
75
+ ${mmCircumference.toFixed(4)} миллиметров (mm)
76
+ `;
77
+ }
78
+ </script>
79
+ </body>
80
  </html>