-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
62 lines (53 loc) · 2.06 KB
/
script.js
File metadata and controls
62 lines (53 loc) · 2.06 KB
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
// funkcja wyszukiwania tematów w liście
const searchInput = document.getElementById('searchInput');
const topics = document.querySelectorAll('.topic-list li');
searchInput.addEventListener('input', function () {
const filter = this.value.toLowerCase();
topics.forEach(function (topic) {
const text = topic.textContent.toLowerCase();
topic.style.display = text.includes(filter) ? 'block' : 'none';
});
});
// wysyłanie propozycji tematów na Discorda przez webhook
const proposalForm = document.getElementById("proposalForm");
const confirmationMessage = document.getElementById("confirmationMessage");
proposalForm.addEventListener("submit", function (e) {
e.preventDefault();
const newTopic = document.getElementById("newTopic").value.trim();
const webhookURL = "https://discord.com/api/webhooks/1440027170524102676/N4NVf0o97-o1IS37DAtSHOSVC6YJ9NbOUhbQ9oNkFZeig7-Xi-f9VcYAys0iIcAv8co6";
if (newTopic.length > 0) {
const payload = {
content: `📩 Nowa propozycja tematu: **${newTopic}**`
};
fetch(webhookURL, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
})
.then(response => {
if (response.ok) {
confirmationMessage.style.display = "block";
proposalForm.reset();
} else {
alert("Błąd podczas wysyłania do Discorda.");
}
})
.catch(error => {
console.error("Błąd:", error);
alert("Nie udało się połączyć z Discordem.");
});
}
});
const toggleButton = document.getElementById("toggle-theme");
// sprawdzenie i przywrócenie motywu ciemnego z pamięci przeglądarki
if (localStorage.getItem("theme") === "dark") {
document.body.classList.add("dark-mode");
}
// przełączanie między trybem jasnym i ciemnym
toggleButton.addEventListener("click", () => {
document.body.classList.toggle("dark-mode");
const isDark = document.body.classList.contains("dark-mode");
localStorage.setItem("theme", isDark ? "dark" : "light");
});