Closed
Conversation
Первая сдача лабораторной работы
Изменил код и css, чтобы лабиринт стал более похожим на лабиринт
Форматировал название классов согласно БЭМ, а также сделал лабиринт более похожим на лабиринт
Внес изменения согласно общим моментам с форматированием, а также отдельные корректировки с заданным про детей и родителей
Внесение изменений в CSS файл
…ьно добавлены кнопки навигации
mxwrlld
requested changes
Dec 17, 2025
Comment on lines
+8
to
+144
| <style> | ||
| .calculator { | ||
| max-width: 500px; | ||
| margin: 40px auto; | ||
| padding: 30px; | ||
| background: linear-gradient(135deg, #8a0017 0%, #5a000f 100%); | ||
| border-radius: 14px; | ||
| box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3); | ||
| color: #b6ae7f; | ||
| border: 1px solid rgba(182, 174, 127, 0.15); | ||
| } | ||
|
|
||
| .calculator h2 { | ||
| text-align: center; | ||
| margin-bottom: 30px; | ||
| font-size: 2em; | ||
| text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); | ||
| color: #b6ae7f; | ||
| } | ||
|
|
||
| .input-group { | ||
| margin-bottom: 20px; | ||
| } | ||
|
|
||
| .input-group label { | ||
| display: block; | ||
| margin-bottom: 8px; | ||
| font-weight: bold; | ||
| font-size: 1.1em; | ||
| color: #b6ae7f; | ||
| } | ||
|
|
||
| .input-group input, | ||
| .input-group select { | ||
| width: 100%; | ||
| padding: 12px 15px; | ||
| border: 1px solid rgba(182, 174, 127, 0.3); | ||
| border-radius: 10px; | ||
| font-size: 1.1em; | ||
| background-color: rgba(90, 0, 15, 0.7); | ||
| color: #b6ae7f; | ||
| font-family: 'Courier New', monospace; | ||
| box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2); | ||
| } | ||
|
|
||
| .calculate-btn { | ||
| width: 100%; | ||
| padding: 15px; | ||
| background: linear-gradient(135deg, #5a000f 0%, #6a0015 100%); | ||
| color: #b6ae7f; | ||
| border: 1px solid rgba(182, 174, 127, 0.15); | ||
| border-radius: 10px; | ||
| font-size: 1.3em; | ||
| font-family: 'Courier New', monospace; | ||
| font-weight: bold; | ||
| cursor: pointer; | ||
| margin: 20px 0; | ||
| transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94); | ||
| box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35); | ||
| text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3); | ||
| } | ||
|
|
||
| .calculate-btn:hover { | ||
| transform: translateY(-3px); | ||
| box-shadow: 0 8px 16px rgba(0, 0, 0, 0.45); | ||
| background: linear-gradient(135deg, #6a0015 0%, #7a001b 100%); | ||
| } | ||
|
|
||
| .calculate-btn:active { | ||
| transform: translateY(-1px); | ||
| box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3); | ||
| } | ||
|
|
||
| .result { | ||
| padding: 20px; | ||
| background-color: rgba(90, 0, 15, 0.7); | ||
| border-radius: 10px; | ||
| margin-top: 20px; | ||
| text-align: center; | ||
| font-size: 1.2em; | ||
| color: #b6ae7f; | ||
| min-height: 60px; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2); | ||
| border: 1px solid rgba(182, 174, 127, 0.2); | ||
| font-family: 'Courier New', monospace; | ||
| } | ||
|
|
||
| .error { | ||
| background-color: rgba(139, 0, 0, 0.8); | ||
| color: #ff9999; | ||
| } | ||
|
|
||
| .success { | ||
| background-color: rgba(0, 100, 0, 0.7); | ||
| color: #99ff99; | ||
| } | ||
|
|
||
| .calculator-info { | ||
| margin-top: 25px; | ||
| padding: 15px; | ||
| background-color: rgba(90, 0, 15, 0.5); | ||
| border-radius: 10px; | ||
| font-size: 0.9em; | ||
| border: 1px solid rgba(182, 174, 127, 0.1); | ||
| } | ||
|
|
||
| .calculator-info p { | ||
| margin: 0; | ||
| padding: 0; | ||
| font-size: 0.9em; | ||
| } | ||
|
|
||
| .back-link { | ||
| display: block; | ||
| text-align: center; | ||
| margin-top: 30px; | ||
| color: #b6ae7f; | ||
| text-decoration: none; | ||
| font-weight: bold; | ||
| font-size: 1.1em; | ||
| transition: color 0.3s; | ||
| text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3); | ||
| } | ||
|
|
||
| .back-link:hover { | ||
| color: #d4cc9f; | ||
| text-decoration: underline; | ||
| } | ||
|
|
||
| option { | ||
| background-color: #5a000f; | ||
| color: #b6ae7f; | ||
| } | ||
| </style> |
| <p><strong>Примечание:</strong> Калькулятор обрабатывает ошибки деления на ноль и некорректный ввод данных.</p> | ||
| </div> | ||
|
|
||
| <a href="main.html" class="back-link">← Вернуться на главную страницу</a> |
There was a problem hiding this comment.
Ссылка некорретная - main.html лежит на уровень выше
Comment on lines
+185
to
+285
| <script> | ||
| document.addEventListener('DOMContentLoaded', function() { | ||
| const num1Input = document.getElementById('num1'); | ||
| const num2Input = document.getElementById('num2'); | ||
| const operationSelect = document.getElementById('operation'); | ||
| const calculateBtn = document.getElementById('calculate'); | ||
| const resultDiv = document.getElementById('result'); | ||
|
|
||
| // Функция для вычисления результата | ||
| function calculate() { | ||
| // Получаем значения из полей ввода | ||
| const num1 = parseFloat(num1Input.value); | ||
| const num2 = parseFloat(num2Input.value); | ||
| const operation = operationSelect.value; | ||
|
|
||
| // Проверяем, что оба числа являются валидными числами | ||
| if (isNaN(num1) || isNaN(num2)) { | ||
| showError("Пожалуйста, введите оба числа"); | ||
| return; | ||
| } | ||
|
|
||
| let result; | ||
| let operationSymbol; | ||
|
|
||
| // Выполняем выбранную операцию | ||
| switch(operation) { | ||
| case 'add': | ||
| result = num1 + num2; | ||
| operationSymbol = '+'; | ||
| break; | ||
| case 'subtract': | ||
| result = num1 - num2; | ||
| operationSymbol = '-'; | ||
| break; | ||
| case 'multiply': | ||
| result = num1 * num2; | ||
| operationSymbol = '×'; | ||
| break; | ||
| case 'divide': | ||
| if (num2 === 0) { | ||
| showError("Ошибка: деление на ноль!"); | ||
| return; | ||
| } | ||
| result = num1 / num2; | ||
| operationSymbol = '÷'; | ||
| break; | ||
| case 'power': | ||
| result = Math.pow(num1, num2); | ||
| operationSymbol = '^'; | ||
| break; | ||
| case 'modulo': | ||
| if (num2 === 0) { | ||
| showError("Ошибка: деление на ноль!"); | ||
| return; | ||
| } | ||
| result = num1 % num2; | ||
| operationSymbol = '%'; | ||
| break; | ||
| default: | ||
| showError("Неизвестная операция"); | ||
| return; | ||
| } | ||
|
|
||
| // Округляем результат до 4 знаков после запятой | ||
| result = Math.round(result * 10000) / 10000; | ||
|
|
||
| // Показываем результат | ||
| showResult(`${num1} ${operationSymbol} ${num2} = <strong>${result}</strong>`); | ||
| } | ||
|
|
||
| // Функция для отображения ошибки | ||
| function showError(message) { | ||
| resultDiv.innerHTML = `<span class="error-text">${message}</span>`; | ||
| resultDiv.className = "result error"; | ||
| } | ||
|
|
||
| // Функция для отображения результата | ||
| function showResult(message) { | ||
| resultDiv.innerHTML = message; | ||
| resultDiv.className = "result success"; | ||
| } | ||
|
|
||
| // Обработчик события для кнопки "Вычислить" | ||
| calculateBtn.addEventListener('click', calculate); | ||
|
|
||
| // Обработчики событий для клавиши Enter | ||
| num1Input.addEventListener('keypress', function(e) { | ||
| if (e.key === 'Enter') calculate(); | ||
| }); | ||
|
|
||
| num2Input.addEventListener('keypress', function(e) { | ||
| if (e.key === 'Enter') calculate(); | ||
| }); | ||
|
|
||
| // Автозаполнение примерами для демонстрации | ||
| window.addEventListener('load', function() { | ||
| num1Input.value = "12"; | ||
| num2Input.value = "4"; | ||
| }); | ||
| }); | ||
| </script> |
Comment on lines
+206
to
+246
| let result; | ||
| let operationSymbol; | ||
|
|
||
| // Выполняем выбранную операцию | ||
| switch(operation) { | ||
| case 'add': | ||
| result = num1 + num2; | ||
| operationSymbol = '+'; | ||
| break; | ||
| case 'subtract': | ||
| result = num1 - num2; | ||
| operationSymbol = '-'; | ||
| break; | ||
| case 'multiply': | ||
| result = num1 * num2; | ||
| operationSymbol = '×'; | ||
| break; | ||
| case 'divide': | ||
| if (num2 === 0) { | ||
| showError("Ошибка: деление на ноль!"); | ||
| return; | ||
| } | ||
| result = num1 / num2; | ||
| operationSymbol = '÷'; | ||
| break; | ||
| case 'power': | ||
| result = Math.pow(num1, num2); | ||
| operationSymbol = '^'; | ||
| break; | ||
| case 'modulo': | ||
| if (num2 === 0) { | ||
| showError("Ошибка: деление на ноль!"); | ||
| return; | ||
| } | ||
| result = num1 % num2; | ||
| operationSymbol = '%'; | ||
| break; | ||
| default: | ||
| showError("Неизвестная операция"); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Выделите в отдельную функцию выполнение вычислений
Теперь файл calculator.js несет в себе основную функцию вычислений, а main.js - основную логику калькулятора
Удален повтор из файла styles.css, ссылка на главную страницу теперь работает, к .html подключены .js
Author
|
Внес все правки |
|
Зачтено! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Выполнил 4 ЛР с калькулятором, также сделал 3 ЛР (Визитку), как главную страницу, через которую можно перейти ко всем другим ЛР (В них же были добавлены кнопки навигации)