MediaWiki:Common.js: Porovnání verzí
Skočit na navigaci
Skočit na vyhledávání
Bez shrnutí editace značka: revertováno |
Bez shrnutí editace |
||
| (Není zobrazeno 15 mezilehlých verzí od stejného uživatele.) | |||
| Řádek 1: | Řádek 1: | ||
/* Zde uvedený JavaScript bude použit pro všechny uživatele při načtení každé stránky */ | /* Zde uvedený JavaScript bude použit pro všechny uživatele při načtení každé stránky */ | ||
mw.loader.using( ['ext.categoryTree'] ); | /* mw.loader.using( ['ext.categoryTree'] ); */ | ||
$(function() { | |||
/* $( document ).ready(function() { | |||
$('.CategoryTreeToggle').click(); | |||
});*/ | |||
/* $( document ).ready(function() { $('.CategoryTreeToggle[data-ct-state="collapsed"]').click(); });*/ | |||
/* | |||
$( document ).ready(function() { | |||
$('.CategoryTreeToggle[data-ct-state="collapsed"]').click(); | |||
});*/ | |||
/*$(function() { | |||
// 1. Najdeme kontejner pro navigaci (v novém Vectoru je to id 'mw-panel-navigation') | // 1. Najdeme kontejner pro navigaci (v novém Vectoru je to id 'mw-panel-navigation') | ||
var $target = $('#mw-panel-navigation, #mw-panel'); | var $target = $('#mw-panel-navigation, #mw-panel'); | ||
| Řádek 17: | Řádek 28: | ||
$.get(mw.util.wikiScript('api'), { | $.get(mw.util.wikiScript('api'), { | ||
action: 'parse', | action: 'parse', | ||
text: '<categorytree mode=" | text: '<categorytree mode="all" depth="20" hideroot="on">Manuals</categorytree>', | ||
format: 'json' | format: 'json' | ||
}).done(function(data) { | }).done(function(data) { | ||
| Řádek 25: | Řádek 36: | ||
}); | }); | ||
} | } | ||
}); | |||
*/ | |||
/* Kód pro načítání textu z Gitea */ | |||
$(function() { | |||
$('.gitea-load').each(function() { | |||
var $container = $(this); | |||
var url = $container.data('url'); | |||
fetch(url) | |||
.then(response => { | |||
if (!response.ok) throw new Error('Network response was not ok'); | |||
return response.text(); | |||
}) | |||
.then(data => { | |||
// Vložíme text do pre tagu pro zachování formátování | |||
//$container.html('<pre style="background:#f9f9f9; border:1px solid #ddd; padding:10px;">' + | |||
// $('<div/>').text(data).html() + '</pre>'); | |||
$container.html('<pre style="background:#282a36; color:#f8f8f2; border-radius:5px; padding:15px; overflow-x:auto; font-family:Monaco,Consolas,monospace; line-height:1.5; box-shadow: inset 0 0 10px rgba(0,0,0,0.5);">' + | |||
$('<div/>').text(data).html() + '</pre>'); | |||
}) | |||
.catch(error => { | |||
$container.html('<span style="color:red;">Chyba načítání: ' + error.message + '</span>'); | |||
}); | |||
}); | |||
}); | }); | ||
Aktuální verze z 18. 2. 2026, 11:30
/* Zde uvedený JavaScript bude použit pro všechny uživatele při načtení každé stránky */
/* mw.loader.using( ['ext.categoryTree'] ); */
/* $( document ).ready(function() {
$('.CategoryTreeToggle').click();
});*/
/* $( document ).ready(function() { $('.CategoryTreeToggle[data-ct-state="collapsed"]').click(); });*/
/*
$( document ).ready(function() {
$('.CategoryTreeToggle[data-ct-state="collapsed"]').click();
});*/
/*$(function() {
// 1. Najdeme kontejner pro navigaci (v novém Vectoru je to id 'mw-panel-navigation')
var $target = $('#mw-panel-navigation, #mw-panel');
if ($target.length) {
// Vytvoříme hezčí kontejner, který zapadne do designu
var $customNav = $('<nav class="vector-menu vector-menu-portal portal" id="p-manuals-tree">' +
'<label class="vector-menu-heading"><span>Manuals</span></label>' +
'<div class="vector-menu-content"><ul class="vector-menu-content-list" id="manuals-target"></ul></div>' +
'</nav>');
$target.append($customNav);
// Načteme strom
$.get(mw.util.wikiScript('api'), {
action: 'parse',
text: '<categorytree mode="all" depth="20" hideroot="on">Manuals</categorytree>',
format: 'json'
}).done(function(data) {
if (data.parse && data.parse.text) {
$('#manuals-target').html(data.parse.text['*']);
}
});
}
});
*/
/* Kód pro načítání textu z Gitea */
$(function() {
$('.gitea-load').each(function() {
var $container = $(this);
var url = $container.data('url');
fetch(url)
.then(response => {
if (!response.ok) throw new Error('Network response was not ok');
return response.text();
})
.then(data => {
// Vložíme text do pre tagu pro zachování formátování
//$container.html('<pre style="background:#f9f9f9; border:1px solid #ddd; padding:10px;">' +
// $('<div/>').text(data).html() + '</pre>');
$container.html('<pre style="background:#282a36; color:#f8f8f2; border-radius:5px; padding:15px; overflow-x:auto; font-family:Monaco,Consolas,monospace; line-height:1.5; box-shadow: inset 0 0 10px rgba(0,0,0,0.5);">' +
$('<div/>').text(data).html() + '</pre>');
})
.catch(error => {
$container.html('<span style="color:red;">Chyba načítání: ' + error.message + '</span>');
});
});
});