Зафиксировал мысль, потом вернусь к идее с бэкендом на питоне.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
document.getElementById('bmi-form').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const height = document.getElementById('height').value;
|
||||
const weight = document.getElementById('weight').value;
|
||||
const resultDiv = document.getElementById('result');
|
||||
|
||||
fetch('/calculate', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ height, weight })
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.error) {
|
||||
resultDiv.style.display = 'block';
|
||||
resultDiv.style.color = '#cc0000';
|
||||
resultDiv.textContent = data.error;
|
||||
} else {
|
||||
resultDiv.style.display = 'block';
|
||||
resultDiv.style.color = '#003366';
|
||||
resultDiv.textContent = `Ваш BMI: ${data.bmi}`;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
resultDiv.style.display = 'block';
|
||||
resultDiv.textContent = 'Ошибка соединения с сервером.';
|
||||
resultDiv.style.color = '#cc0000';
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,109 @@
|
||||
/* Общие стили страницы */
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background-color: #e6f7ff; /* Светло-голубой фон */
|
||||
color: #003366; /* Тёмно-синий текст для контраста */
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* Шапка сайта */
|
||||
header {
|
||||
background-color: #b3e0ff; /* Более тёмный голубой */
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
header h1 {
|
||||
margin: 0;
|
||||
font-size: 28px;
|
||||
color: #003366;
|
||||
}
|
||||
|
||||
/* Основное содержимое */
|
||||
main {
|
||||
max-width: 600px;
|
||||
margin: 30px auto;
|
||||
padding: 20px;
|
||||
background-color: #d9f0ff; /* Светло-голубой блок */
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
/* Форма ввода */
|
||||
form label {
|
||||
display: block;
|
||||
margin-top: 15px;
|
||||
font-weight: bold;
|
||||
color: #003366;
|
||||
}
|
||||
|
||||
form input[type="text"] {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin-top: 5px;
|
||||
border: 1px solid #99d6ff;
|
||||
border-radius: 5px;
|
||||
font-size: 16px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
form button {
|
||||
margin-top: 20px;
|
||||
padding: 12px 20px;
|
||||
background-color: #0066cc; /* Синий цвет кнопки */
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
form button:hover {
|
||||
background-color: #004d99; /* Темнее при наведении */
|
||||
}
|
||||
|
||||
/* Блок результата */
|
||||
#result {
|
||||
margin-top: 20px;
|
||||
padding: 15px;
|
||||
background-color: #cce6ff;
|
||||
border-radius: 5px;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
display: none; /* Скрыто до расчёта */
|
||||
}
|
||||
|
||||
/* Дополнительная информация (шкала BMI) */
|
||||
aside {
|
||||
max-width: 600px;
|
||||
margin: 20px auto;
|
||||
padding: 15px;
|
||||
background-color: #c2e0ff;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
aside h3 {
|
||||
margin-top: 0;
|
||||
color: #003366;
|
||||
}
|
||||
|
||||
aside ul {
|
||||
margin: 10px 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
/* Подвал */
|
||||
footer {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
background-color: #b3e0ff;
|
||||
color: #003366;
|
||||
font-size: 14px;
|
||||
margin-top: 40px;
|
||||
}
|
||||
Reference in New Issue
Block a user