-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
110 lines (92 loc) · 2.98 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Обман, чтобы набрать классы</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background: #f0f0f0;
}
.header {
background: white;
padding: 10px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
margin-bottom: 10px;
}
.search-bar {
margin: 0 auto;
display: flex;
justify-content: space-between;
}
.search-bar input {
padding: 5px;
font-size: 16px;
margin-right: 5px;
}
.gallery {
width: 90%;
margin: 0 auto;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
}
.screenshot {
background: white;
padding: 10px;
border: 1px solid #ddd;
}
.screenshot img {
max-width: 100%;
}
.screenshot-text {
margin-top: 5px;
}
</style>
</head>
<body>
<div class="header">
<div class="search-bar">
<input type="text" id="search-input" placeholder="Поиск..." />
</div>
</div>
<div class="gallery">
<!-- screenshots -->
</div>
<script>
const galleryElement = document.querySelector('.gallery');
const searchInput = document.getElementById('search-input');
let screenshotsData = [];
function filterScreenshots() {
const query = searchInput.value.toLowerCase();
galleryElement.innerHTML = ''; // Clear the gallery
// Filter and display screenshots that match the query
screenshotsData
.filter(screenshot => screenshot.text.toLowerCase().includes(query))
.forEach(screenshot => {
const div = document.createElement('div');
div.className = 'screenshot';
div.innerHTML = `
<img src="photos/${screenshot.file}" alt="Скриншот">
<div class="screenshot-text">${screenshot.text}</div>
`;
galleryElement.appendChild(div);
});
}
// Fetch the screenshots data from ScreenshotCatalog.json
fetch('ScreenshotCatalog.json')
.then(response => response.json())
.then(screenshots => {
screenshotsData = screenshots; // Save data to variable
filterScreenshots(); // Display all screenshots initially
})
.catch(error => {
console.error('Error fetching the screenshot catalog:', error);
});
// Add event listener for the search input
searchInput.addEventListener('keyup', filterScreenshots);
</script>
</body>
</html>