-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
72 lines (63 loc) · 2.71 KB
/
script.js
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
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.getElementById('main-search');
const resultsSection = document.getElementById('results');
let topicsData = [];
fetch('topics.json')
.then(response => response.json())
.then(data => {
topicsData = data;
})
.catch(error => {
console.error('JSON verisi yüklenirken bir hata oluştu:', error);
});
searchInput.addEventListener('input', function () {
const query = searchInput.value.trim().toLowerCase();
if (query === '') {
resultsSection.classList.remove('show');
resultsSection.style.display = 'none';
resultsSection.style.opacity = '0';
return;
}
const filteredData = topicsData.filter(item =>
item.topic.toLowerCase().includes(query) ||
item.tool.toLowerCase().includes(query) ||
item.description.toLowerCase().includes(query)
);
if (filteredData.length > 0) {
resultsSection.innerHTML = filteredData.map(item => `
<a href="${item.url}" class="result-item">
<div class="result-content">
<h3>${item.topic}</h3>
<p>${item.description}</p>
</div>
<div class="result-meta">
<div class="app-label">
<img src="${item.image}" alt="${item.tool} icon" class="tool-image">
<div class="class-label class-${item.grade}">${item.grade}. Sınıf</div>
</div>
<div class="tool-name">${item.tool}</div>
</div>
</a>
`).join('');
resultsSection.style.display = 'block';
resultsSection.style.opacity = '1';
resultsSection.classList.add('show');
} else {
resultsSection.classList.remove('show');
resultsSection.style.display = 'none';
resultsSection.style.opacity = '0';
}
});
});
document.querySelectorAll('.powtoon-button').forEach(button => {
button.addEventListener('click', (event) => {
event.target.classList.add('clicked');
});
});
window.addEventListener("scroll", function() {
const progressBar = document.getElementById("progress-bar");
const scrollTop = window.scrollY;
const docHeight = document.documentElement.scrollHeight - window.innerHeight;
const scrollPercent = (scrollTop / docHeight) * 100;
progressBar.style.width = scrollPercent + "%";
});