« MediaWiki:Common.js » : différence entre les versions
Apparence
Aucun résumé des modifications Balise : Révoqué |
Aucun résumé des modifications Balise : Révoqué |
||
| Ligne 18 : | Ligne 18 : | ||
document.addEventListener("DOMContentLoaded", function () { | document.addEventListener("DOMContentLoaded", function () { | ||
if (!document.body.classList.contains("ns-14")) return; | if (!document.body.classList.contains("ns-14")) return; | ||
const links = document.querySelectorAll(".mw-category a"); | const links = document.querySelectorAll(".mw-category a"); | ||
| Ligne 28 : | Ligne 28 : | ||
links.forEach(link => { | links.forEach(link => { | ||
link.addEventListener("mouseenter", function (e) { | link.addEventListener("mouseenter", function (e) { | ||
const pageTitle = link.getAttribute("title"); | |||
const | |||
tooltip.innerHTML = "<img src='" + | fetch("/wiki/api.php?action=query&titles=" + encodeURIComponent(pageTitle) + "&prop=pageimages&format=json&pithumbsize=200") | ||
.then(res => res.json()) | |||
.then(data => { | |||
const pages = data.query.pages; | |||
const page = Object.values(pages)[0]; | |||
if (page.thumbnail) { | |||
tooltip.innerHTML = "<img src='" + page.thumbnail.source + "'>"; | |||
} else { | |||
tooltip.innerHTML = "Pas d'image"; | |||
} | |||
tooltip.style.display = "block"; | |||
}); | |||
tooltip.style.left = e.pageX + 10 + "px"; | tooltip.style.left = e.pageX + 10 + "px"; | ||
tooltip.style.top = e.pageY + 10 + "px"; | tooltip.style.top = e.pageY + 10 + "px"; | ||
Version du 24 avril 2026 à 16:43
$(function () {
const header = document.querySelector('.vector-header-end');
if (!header) return;
const container = document.createElement('div');
container.className = "pne-header-links";
container.innerHTML = `
<a href="/wiki/index.php/Spécial:Toutes_les_pages">Parcourir</a>
<a href="/wiki/index.php/Spécial:Catégories">Catégories</a>
`;
header.prepend(container);
});
document.addEventListener("DOMContentLoaded", function () {
if (!document.body.classList.contains("ns-14")) return;
const links = document.querySelectorAll(".mw-category a");
const tooltip = document.createElement("div");
tooltip.className = "category-tooltip";
document.body.appendChild(tooltip);
links.forEach(link => {
link.addEventListener("mouseenter", function (e) {
const pageTitle = link.getAttribute("title");
fetch("/wiki/api.php?action=query&titles=" + encodeURIComponent(pageTitle) + "&prop=pageimages&format=json&pithumbsize=200")
.then(res => res.json())
.then(data => {
const pages = data.query.pages;
const page = Object.values(pages)[0];
if (page.thumbnail) {
tooltip.innerHTML = "<img src='" + page.thumbnail.source + "'>";
} else {
tooltip.innerHTML = "Pas d'image";
}
tooltip.style.display = "block";
});
tooltip.style.left = e.pageX + 10 + "px";
tooltip.style.top = e.pageY + 10 + "px";
});
link.addEventListener("mousemove", function (e) {
tooltip.style.left = e.pageX + 10 + "px";
tooltip.style.top = e.pageY + 10 + "px";
});
link.addEventListener("mouseleave", function () {
tooltip.style.display = "none";
});
});
});