„MediaWiki:Common.js” változatai közötti eltérés
Innen: Sanctum2 Wikipédia
Ugrás a navigációhozUgrás a kereséshez
Nincs szerkesztési összefoglaló |
Nincs szerkesztési összefoglaló |
||
55. sor: | 55. sor: | ||
// Várjuk meg, amíg a dokumentum betöltődik | // Várjuk meg, amíg a dokumentum betöltődik | ||
document.addEventListener('DOMContentLoaded', function() { | document.addEventListener('DOMContentLoaded', function() { | ||
var | var mwBody = document.querySelector('.mw-body'); | ||
if (!mwBody) { | |||
if (! | |||
return; | return; | ||
} | } | ||
// Kereső buborék létrehozása és hozzáadása a mw-body elemeihez | |||
var searchBubble = document.createElement('div'); | |||
searchBubble.id = 'searchBubble'; | |||
searchBubble.innerHTML = ` | |||
<input type="text" id="searchInput" placeholder="Keresés..."> | |||
<button id="searchSubmit">Keresés</button> | |||
`; | |||
mwBody.insertBefore(searchBubble, mwBody.firstChild); | |||
var searchInput = document.getElementById('searchInput'); | |||
var searchSubmit = document.getElementById('searchSubmit'); | |||
// Keresés funkció | // Keresés funkció | ||
75. sor: | 84. sor: | ||
alert('Kérlek írj be valamit a kereséshez!'); | alert('Kérlek írj be valamit a kereséshez!'); | ||
} | } | ||
} | } | ||
105. sor: | 104. sor: | ||
var scrolledToTop = window.scrollY === 0; | var scrolledToTop = window.scrollY === 0; | ||
if (scrolledToTop) { | if (scrolledToTop) { | ||
searchBubble.style.display = 'block'; | |||
} else { | } else { | ||
searchBubble.style.display = 'none'; | |||
} | } | ||
}); | }); | ||
115. sor: | 114. sor: | ||
var scrolledToTop = window.scrollY === 0; | var scrolledToTop = window.scrollY === 0; | ||
if (scrolledToTop) { | if (scrolledToTop) { | ||
searchBubble.style.display = 'block'; | |||
} else { | } else { | ||
searchBubble.style.display = 'none'; | |||
} | } | ||
}); | }); | ||
}); | }); |
A lap 2024. június 24., 12:09-kori változata
// MediaWiki:Common.js $(document).ready(function() { // Add search box with styled input var searchBoxHtml = '<div id="searchBox" style="position: sticky; top: 0; background-color: #333; padding: 10px; border-radius: 5px; width: 90%; margin-left: auto; margin-right: auto;">' + '<label for="tableSearch" style="color: #fff; font-size: 1.2em; margin-right: 10px;">Keresés név alapján:</label>' + '<input type="text" id="tableSearch" placeholder="Írd be a tárgy nevét..." style="padding: 5px; border-radius: 5px; border: 1px solid #72716F; color: #333; width: 70%; max-width: 500px;">' + '</div>'; // Insert search box above the "Kép Név Beszerezhetőség" table $('.mw-parser-output table.wikitable:first').before(searchBoxHtml); // Search functionality $('#tableSearch').on('keyup', function() { var value = $(this).val().toLowerCase(); $('.mw-parser-output table.wikitable:first tr').filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1); }); }); }); // MediaWiki:Common.js $(document).ready(function() { // Add fixed header with logo and search box var headerHtml = '<div id="customHeader" style="position: fixed; top: 0; left: 0; right: 0; background-color: #333; color: #fff; padding: 10px; z-index: 1000;">' + '<div style="float: left;"><img src="/path/to/logo.png" style="height: 50px;"></div>' + '<div style="float: right;"><input type="text" id="searchInput" placeholder="Search..." style="padding: 5px; border-radius: 5px; border: 1px solid #72716F; color: #333; width: 200px;"></div>' + '<div style="clear: both;"></div>' + '</div>'; // Insert the custom header at the top of the page $('#mw-page-base').before(headerHtml); // Adjust content margin to prevent overlapping with fixed header $('#content').css('margin-top', '80px'); // Adjust this value as needed // Search functionality $('#searchInput').on('keyup', function() { var value = $(this).val().toLowerCase(); $('.mw-parser-output').find('h2, h3, h4, p').filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1); }); }); }); $(document).ready(function() { var footerImage = $('<div id="footer-image"><img src="https://wiki.nw2online.com/skins/monobook/content_foot.png?2017-05-14T14:15:00Z" alt="Footer Image"></div>'); $('#mw-content-text').append(footerImage); }); $(document).ready(function() { var headerImage = $('<div id="header-image"><img src="https://wiki.nw2online.com/skins/monobook/content_head.png?2017-05-14T14:15:00Z" alt="Header Image"></div>'); $('#firstHeading').prepend(headerImage); }); // Várjuk meg, amíg a dokumentum betöltődik document.addEventListener('DOMContentLoaded', function() { var mwBody = document.querySelector('.mw-body'); if (!mwBody) { return; } // Kereső buborék létrehozása és hozzáadása a mw-body elemeihez var searchBubble = document.createElement('div'); searchBubble.id = 'searchBubble'; searchBubble.innerHTML = ` <input type="text" id="searchInput" placeholder="Keresés..."> <button id="searchSubmit">Keresés</button> `; mwBody.insertBefore(searchBubble, mwBody.firstChild); var searchInput = document.getElementById('searchInput'); var searchSubmit = document.getElementById('searchSubmit'); // Keresés funkció function performSearch() { var searchTerm = searchInput.value.trim(); if (searchTerm !== '') { // Ide írd be a keresési logikát, például: // window.location.href = '/wiki/index.php?search=' + encodeURIComponent(searchTerm); // Ezt a sort cseréld ki a saját MediaWiki keresési URL-re és paraméterezésre. alert('Keresési funkció még nincs implementálva! Keresett kifejezés: ' + searchTerm); } else { alert('Kérlek írj be valamit a kereséshez!'); } } // Keresés indítása gombra kattintáskor searchSubmit.addEventListener('click', function(event) { event.preventDefault(); performSearch(); }); // Enter lenyomásakor is indítsuk el a keresést searchInput.addEventListener('keydown', function(event) { if (event.key === 'Enter') { event.preventDefault(); performSearch(); } }); // Görgetés figyelése és a buborék megjelenítése/elrejtése window.addEventListener('scroll', function() { var scrolledToTop = window.scrollY === 0; if (scrolledToTop) { searchBubble.style.display = 'block'; } else { searchBubble.style.display = 'none'; } }); // Az oldal betöltéskor is ellenőrizzük, hogy el kell-e rejteni a buborékot window.addEventListener('DOMContentLoaded', function() { var scrolledToTop = window.scrollY === 0; if (scrolledToTop) { searchBubble.style.display = 'block'; } else { searchBubble.style.display = 'none'; } }); });