мНет описания правки |
мНет описания правки |
||
Строка 3: | Строка 3: | ||
// console.log("Привет"); | // console.log("Привет"); | ||
/*_____________________*/ | /*_____________________*/ | ||
// Проверяем загрузку jQuery | |||
var $customContainer = $(' | mw.loader.using('jquery').then(function() { | ||
$(function() { | |||
// Создаем контейнер, если его нет | |||
var $customContainer = $('.citizen-header__custom-bottom'); | |||
if ($customContainer.length === 0) { | |||
$customContainer = $('<div>') | |||
.addClass('citizen-header__custom-bottom') | |||
.appendTo('.citizen-header'); | |||
} | |||
// Пример данных (замените на свои!) | |||
var items = [ | |||
{ | |||
type: 'image', | |||
src: 'https://wiki.ss220.club/resources/assets/logo.png', | |||
link: 'https://wiki.ss220.club', | |||
width: '40px' | |||
}, | |||
{ | |||
type: 'image', | |||
src: 'https://wiki.ss220.club/resources/assets/logo.png', | |||
link: 'https://bs.ss220.club', | |||
width: '40px' | |||
} | |||
]; | |||
// Очищаем контейнер перед добавлением | |||
$customContainer.empty(); | |||
// Добавляем элементы | |||
items.forEach(function(item) { | |||
var $element; | |||
if (item.type === 'image') { | |||
$element = $('<img>') | |||
.attr('src', item.src) | |||
.css('width', item.width); | |||
} else { | |||
$element = $('<span>').text(item.text); | |||
} | |||
var $link = $('<a>') | |||
.attr('href', item.link) | |||
.append($element) | |||
.css({ | |||
display: 'inline-block', | |||
margin: '0 10px' | |||
}); | |||
$customContainer.append($link); | |||
}); | |||
// Принудительно показываем контейнер | |||
$customContainer.css('display', 'flex'); | |||
}); | |||
}); | }); |
Версия от 18:19, 1 апреля 2025
/* Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице */
// console.log("Привет");
/*_____________________*/
// Проверяем загрузку jQuery
mw.loader.using('jquery').then(function() {
$(function() {
// Создаем контейнер, если его нет
var $customContainer = $('.citizen-header__custom-bottom');
if ($customContainer.length === 0) {
$customContainer = $('<div>')
.addClass('citizen-header__custom-bottom')
.appendTo('.citizen-header');
}
// Пример данных (замените на свои!)
var items = [
{
type: 'image',
src: 'https://wiki.ss220.club/resources/assets/logo.png',
link: 'https://wiki.ss220.club',
width: '40px'
},
{
type: 'image',
src: 'https://wiki.ss220.club/resources/assets/logo.png',
link: 'https://bs.ss220.club',
width: '40px'
}
];
// Очищаем контейнер перед добавлением
$customContainer.empty();
// Добавляем элементы
items.forEach(function(item) {
var $element;
if (item.type === 'image') {
$element = $('<img>')
.attr('src', item.src)
.css('width', item.width);
} else {
$element = $('<span>').text(item.text);
}
var $link = $('<a>')
.attr('href', item.link)
.append($element)
.css({
display: 'inline-block',
margin: '0 10px'
});
$customContainer.append($link);
});
// Принудительно показываем контейнер
$customContainer.css('display', 'flex');
});
});