Init commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Телефонный справочник</title>
|
||||
<link rel="stylesheet" href="/styles.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1>Телефонный справочник</h1>
|
||||
<div class="search-container">
|
||||
<input type="text" id="searchInput" placeholder="Поиск по имени, должности или отделу...">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-container">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ФИО</th>
|
||||
<th>Должность</th>
|
||||
<th>Отдел</th>
|
||||
<th>Телефон</th>
|
||||
<th>Email</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="contactsList">
|
||||
<!-- Контакты будут добавлены через JavaScript -->
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="no-results" style="display: none;">
|
||||
Контакты не найдены
|
||||
</div>
|
||||
</div>
|
||||
<script src="/script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,52 @@
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
const searchInput = document.getElementById('searchInput');
|
||||
const contactsList = document.getElementById('contactsList');
|
||||
const noResults = document.querySelector('.no-results');
|
||||
let contacts = [];
|
||||
|
||||
// Загрузка данных с сервера
|
||||
try {
|
||||
const response = await fetch('/api/contacts');
|
||||
contacts = await response.json();
|
||||
renderContacts(contacts);
|
||||
} catch (error) {
|
||||
console.error('Ошибка при загрузке контактов:', error);
|
||||
noResults.textContent = 'Ошибка при загрузке контактов';
|
||||
noResults.style.display = 'block';
|
||||
}
|
||||
|
||||
function formatPhoneNumbers(phone) {
|
||||
if (!phone || phone === '-') return '-';
|
||||
return phone.split(';').map(num => num.trim()).filter(Boolean).join('\n');
|
||||
}
|
||||
|
||||
function renderContacts(contactsToRender) {
|
||||
contactsList.innerHTML = contactsToRender.map(contact => `
|
||||
<tr>
|
||||
<td>${contact.name}</td>
|
||||
<td>${contact.title}</td>
|
||||
<td>${contact.department}</td>
|
||||
<td>${formatPhoneNumbers(contact.phone)}</td>
|
||||
<td>${contact.email}</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
function filterContacts(searchTerm) {
|
||||
searchTerm = searchTerm.toLowerCase();
|
||||
const filteredContacts = contacts.filter(contact =>
|
||||
contact.name.toLowerCase().includes(searchTerm) ||
|
||||
contact.title.toLowerCase().includes(searchTerm) ||
|
||||
contact.department.toLowerCase().includes(searchTerm) ||
|
||||
(contact.phone && contact.phone !== '-' && contact.phone.toLowerCase().includes(searchTerm)) ||
|
||||
(contact.email && contact.email !== '-' && contact.email.toLowerCase().includes(searchTerm))
|
||||
);
|
||||
|
||||
renderContacts(filteredContacts);
|
||||
noResults.style.display = filteredContacts.length ? 'none' : 'block';
|
||||
}
|
||||
|
||||
searchInput.addEventListener('input', (e) => {
|
||||
filterContacts(e.target.value);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,168 @@
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f5f5f5;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.header {
|
||||
background-color: white;
|
||||
padding: 20px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.table-container {
|
||||
margin-top: 160px;
|
||||
background-color: white;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
margin-left: 20px;
|
||||
margin-right: 20px;
|
||||
margin-bottom: 20px;
|
||||
overflow: auto;
|
||||
max-height: calc(100vh - 200px);
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
/* Стили для заголовка таблицы */
|
||||
thead {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 3;
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
thead::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
background: #f8f9fa;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
th {
|
||||
background: #f8f9fa;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 3;
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
font-weight: 600;
|
||||
color: #2c3e50;
|
||||
border-bottom: 2px solid #e9ecef;
|
||||
font-size: 14px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
/* Стили для ячеек таблицы */
|
||||
tbody tr {
|
||||
background: white;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 12px 15px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #f2f2f2;
|
||||
background: white;
|
||||
font-size: 14px;
|
||||
line-height: 1.4;
|
||||
color: #444;
|
||||
}
|
||||
|
||||
/* Разрешаем перенос текста для определенных столбцов */
|
||||
td:nth-child(1), /* ФИО */
|
||||
td:nth-child(2), /* Должность */
|
||||
td:nth-child(3) { /* Отдел */
|
||||
white-space: normal;
|
||||
min-width: 150px;
|
||||
max-width: 250px;
|
||||
}
|
||||
|
||||
/* Телефон */
|
||||
td:nth-child(4) {
|
||||
white-space: pre-line;
|
||||
min-width: 120px;
|
||||
font-family: monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* Email */
|
||||
td:nth-child(5) {
|
||||
min-width: 180px;
|
||||
font-family: monospace;
|
||||
font-size: 13px;
|
||||
color: #2962ff;
|
||||
}
|
||||
|
||||
/* Эффект при наведении */
|
||||
tr:hover td {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
/* Чередование строк */
|
||||
tbody tr:nth-child(even) {
|
||||
background-color: #fcfcfc;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #2c3e50;
|
||||
text-align: center;
|
||||
margin: 0 0 20px 0;
|
||||
font-size: 24px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.search-container {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#searchInput {
|
||||
width: 100%;
|
||||
padding: 12px 15px;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 6px;
|
||||
font-size: 15px;
|
||||
box-sizing: border-box;
|
||||
transition: all 0.2s ease;
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
#searchInput:focus {
|
||||
outline: none;
|
||||
border-color: #2962ff;
|
||||
box-shadow: 0 0 0 3px rgba(41, 98, 255, 0.1);
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
#searchInput::placeholder {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.no-results {
|
||||
text-align: center;
|
||||
padding: 30px;
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
background: #f8f9fa;
|
||||
border-radius: 6px;
|
||||
margin: 20px;
|
||||
font-size: 15px;
|
||||
}
|
||||
Reference in New Issue
Block a user