178 lines
9.4 KiB
HTML
178 lines
9.4 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="ru">
|
||
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
|
||
<title>Интернет-магазин: ЛК</title>
|
||
<link rel="stylesheet" href="css/style.css" />
|
||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css">
|
||
</head>
|
||
|
||
<body>
|
||
<header">
|
||
<div class="d-block mt-3 ms-3">
|
||
<img src="images/logo.jpg" alt="Название магазина" class="me-3" style="width: 200px; height: auto;">
|
||
<a href="newSite.html" class="text-decoration-none text-dark m-1">
|
||
<h1 class="display-4 h3 mt-3"><b>Название магазина</b></h1>
|
||
</a>
|
||
</div>
|
||
<navbar>
|
||
<div class="dropdown">
|
||
<button class="btn btn-primary dropdown-toggle" type="button" id="navigationDropdown"
|
||
data-bs-toggle="dropdown" aria-expanded="false">
|
||
Навигация
|
||
</button>
|
||
<ul class="dropdown-menu" aria-labelledby="navigationDropdown">
|
||
<li><a class="dropdown-item d-flex justify-content-between align-items-center"
|
||
href="Account.html">Личный кабинет<i class="bi bi-person-circle ms-2"></i></a></li>
|
||
<li><a class="dropdown-item d-flex justify-content-between align-items-center"
|
||
href="Basket.html">Корзина<i class="bi bi-cart4 ms-2"></i></a></li>
|
||
<li><a class="dropdown-item d-flex justify-content-between align-items-center"
|
||
href="Order.html">Заказы<i class="bi bi-receipt ms-2"></i></a></li>
|
||
<li><a class="dropdown-item d-flex justify-content-between align-items-center"
|
||
href="Favorites.html">Избранное<i class="bi bi-heart-fill ms-2"></i></a></li>
|
||
</ul>
|
||
</div>
|
||
</navbar>
|
||
</header>
|
||
<div class="container mt-5">
|
||
<div class="card text-center mx-auto" style="max-width: 400px; max-height: 400px;">
|
||
<img src="images/бананы.jpg" class="card-img-top" alt="Профиль"
|
||
style="width: 100%; height: 300px; object-fit: cover;">
|
||
<div class="card-body">
|
||
<h3 class="card-title">Имя Фамилия</h3>
|
||
<p class="card-text">Описание</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<footer class="container mt-5">
|
||
<div class="bg-light p-4">
|
||
<h5>Помощь:</h5>
|
||
<div class="d-flex flex-wrap">
|
||
<div class="d-flex align-items-center me-4 mb-3">
|
||
<i class="bi bi-telephone-fill me-2"></i>
|
||
<a href="#" class="text-decoration-none text-dark">8 (800)-555-35-35</a>
|
||
</div>
|
||
<div class="d-flex align-items-center me-4 mb-3">
|
||
<img src="images/vk.png" alt="VK" class="me-2" style="width: 24px; height: 24px;">
|
||
<a href="https://vk.com/howmakesite_nn?from=search" target="_blank"
|
||
class="text-decoration-none text-dark">vk.com</a>
|
||
</div>
|
||
<div class="d-flex align-items-center me-4 mb-3">
|
||
<img src="images/telegram.png" alt="Telegram" class="me-2" style="width: 24px; height: 24px;">
|
||
<a href="#" class="text-decoration-none text-dark">tg.me</a>
|
||
</div>
|
||
<div class="d-flex align-items-center mb-3">
|
||
<img src="images/gmail.png" alt="Gmail" class="me-2" style="width: 24px; height: 24px;">
|
||
<a href="mailto:ozon-zon-zon@mail.joke"
|
||
class="text-decoration-none text-dark">ozon-zon-zon@mail.joke</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</footer>
|
||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
||
crossorigin="anonymous"></script>
|
||
<script type="module">
|
||
let profile = {
|
||
firstName: "Иван",
|
||
lastName: "Иванов",
|
||
image: "images/бананы.jpg"
|
||
};
|
||
|
||
function renderProfile() {
|
||
const card = document.querySelector('.container .card');
|
||
card.innerHTML = `
|
||
<img src="${profile.image || 'images/бананы.jpg'}" class="card-img-top" alt="Профиль" style="width: 100%; height: 300px; object-fit: cover;">
|
||
<div class="card-body">
|
||
<h3 class="card-title">${profile.firstName} ${profile.lastName}</h3>
|
||
<button class="btn btn-primary" id="editProfileBtn"><i class="bi bi-pencil"></i> Редактировать профиль</button>
|
||
</div>
|
||
`;
|
||
card.querySelector('#editProfileBtn').onclick = showEditModal;
|
||
}
|
||
|
||
function showEditModal() {
|
||
let modalDiv = document.getElementById('profileModal');
|
||
if (!modalDiv) {
|
||
modalDiv = document.createElement('div');
|
||
modalDiv.className = 'modal fade';
|
||
modalDiv.id = 'profileModal';
|
||
modalDiv.tabIndex = -1;
|
||
modalDiv.innerHTML = `
|
||
<div class="modal-dialog">
|
||
<div class="modal-content" id="profileModalContent"></div>
|
||
</div>
|
||
`;
|
||
document.body.appendChild(modalDiv);
|
||
}
|
||
const modalContent = modalDiv.querySelector('#profileModalContent');
|
||
modalContent.innerHTML = `
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">Редактировать профиль</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||
</div>
|
||
<form id="profileForm">
|
||
<div class="modal-body">
|
||
<div class="mb-3">
|
||
<label class="form-label">Имя</label>
|
||
<input type="text" class="form-control" name="firstName" value="${profile.firstName}" required pattern="^[А-Яа-яЁё]+$" title="Только русские буквы!">
|
||
</div>
|
||
<div class="mb-3">
|
||
<label class="form-label">Фамилия</label>
|
||
<input type="text" class="form-control" name="lastName" value="${profile.lastName}" required pattern="^[А-Яа-яЁё]+$" title="Только русские буквы!">
|
||
</div>
|
||
<div class="mb-3">
|
||
<label class="form-label">Фото профиля</label>
|
||
<input type="file" class="form-control" name="image" accept="image/*">
|
||
<img id="profilePreviewImage" src="${profile.image || ''}" style="max-width:100%;margin-top:10px;${profile.image ? '' : 'display:none;'}"/>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="submit" class="btn btn-success">Сохранить</button>
|
||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Отмена</button>
|
||
</div>
|
||
</form>
|
||
`;
|
||
const modal = new bootstrap.Modal(modalDiv);
|
||
modal.show();
|
||
|
||
// Предпросмотр картинки
|
||
const fileInput = modalContent.querySelector('input[type="file"]');
|
||
|
||
document.getElementById('profileForm').onsubmit = function (e) {
|
||
e.preventDefault();
|
||
const formData = new FormData(e.target);
|
||
const firstName = formData.get('firstName');
|
||
const lastName = formData.get('lastName');
|
||
// Валидация кириллицы
|
||
if (!/^[А-Яа-яЁё]+$/.test(firstName) || !/^[А-Яа-яЁё]+$/.test(lastName)) {
|
||
alert('Имя и фамилия должны быть только на русском!');
|
||
return;
|
||
}
|
||
profile.firstName = firstName;
|
||
profile.lastName = lastName;
|
||
if (fileInput.files.length) {
|
||
const file = fileInput.files[0];
|
||
const reader = new FileReader();
|
||
reader.onload = function (event) {
|
||
profile.image = event.target.result; // base64
|
||
modal.hide();
|
||
renderProfile();
|
||
};
|
||
reader.readAsDataURL(file);
|
||
} else {
|
||
profile.image = fileInput.src || "images/бананы.jpg";
|
||
modal.hide();
|
||
renderProfile();
|
||
}
|
||
};
|
||
}
|
||
|
||
renderProfile();
|
||
</script>
|
||
</body>
|
||
</html> |