56 lines
2.1 KiB
JavaScript
56 lines
2.1 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
// ---- Kategorie-Filter ----
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const btns = document.querySelectorAll('.mcn-filter-btn');
|
|
const cards = document.querySelectorAll('.mcn-card');
|
|
const empty = document.querySelector('.mcn-empty');
|
|
|
|
btns.forEach(function (btn) {
|
|
btn.addEventListener('click', function () {
|
|
btns.forEach(function (b) { b.classList.remove('active'); });
|
|
btn.classList.add('active');
|
|
|
|
var filter = btn.dataset.filter;
|
|
var visible = 0;
|
|
|
|
cards.forEach(function (card) {
|
|
if (filter === 'all' || card.dataset.category.split(' ').indexOf(filter) !== -1) {
|
|
card.style.display = '';
|
|
visible++;
|
|
} else {
|
|
card.style.display = 'none';
|
|
}
|
|
});
|
|
|
|
if (empty) {
|
|
empty.style.display = visible === 0 ? 'block' : 'none';
|
|
}
|
|
});
|
|
});
|
|
|
|
// ---- Server-IP Kopieren ----
|
|
document.querySelectorAll('.mcn-copy-btn').forEach(function (btn) {
|
|
btn.addEventListener('click', function () {
|
|
var ip = btn.dataset.ip;
|
|
if (navigator.clipboard) {
|
|
navigator.clipboard.writeText(ip).then(function () {
|
|
btn.textContent = '✅ Kopiert!';
|
|
setTimeout(function () { btn.textContent = 'Kopieren'; }, 2000);
|
|
});
|
|
} else {
|
|
var el = document.createElement('textarea');
|
|
el.value = ip;
|
|
document.body.appendChild(el);
|
|
el.select();
|
|
document.execCommand('copy');
|
|
document.body.removeChild(el);
|
|
btn.textContent = '✅ Kopiert!';
|
|
setTimeout(function () { btn.textContent = 'Kopieren'; }, 2000);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
})();
|