MediaWiki:Common.js: различия между версиями
Перейти к навигации
Перейти к поиску
Нет описания правки Метка: ручная отмена |
Нет описания правки |
||
| Строка 74: | Строка 74: | ||
categoriesAlternative.hide(); | categoriesAlternative.hide(); | ||
} | } | ||
}); | |||
/* Функция для вставки VK-видео на страницу для шаблона VK-video */ | |||
window.embedVKVideo = function(containerId, oid, id, width, height) { | |||
var container = document.getElementById(containerId); | |||
if (!container) return; | |||
var iframe = document.createElement('iframe'); | |||
iframe.src = 'https://vk.com/video_ext.php?oid=' + oid + '&id=' + id; | |||
iframe.width = width || 640; | |||
iframe.height = height || 360; | |||
iframe.frameBorder = '0'; | |||
iframe.allowFullscreen = true; | |||
container.innerHTML = ''; | |||
container.appendChild(iframe); | |||
}; | |||
/* Автоматическая инициализация при загрузке VK-видео (к предыдущему пункту) */ | |||
document.addEventListener('DOMContentLoaded', function() { | |||
var videoContainers = document.querySelectorAll('.vk-video-js'); | |||
videoContainers.forEach(function(container) { | |||
var oid = container.getAttribute('data-oid'); | |||
var id = container.getAttribute('data-id'); | |||
var width = container.getAttribute('data-width') || 640; | |||
var height = container.getAttribute('data-height') || 360; | |||
if (oid && id) { | |||
var iframe = document.createElement('iframe'); | |||
iframe.src = 'https://vk.com/video_ext.php?oid=' + oid + '&id=' + id; | |||
iframe.width = width; | |||
iframe.height = height; | |||
iframe.frameBorder = '0'; | |||
iframe.allowFullscreen = true; | |||
container.innerHTML = ''; | |||
container.appendChild(iframe); | |||
} | |||
}); | |||
}); | }); | ||
Версия от 11:26, 26 октября 2025
/* Нигилистические фокусы (см. [[Шаблон:Нигилизм/doc]]) */
$(function () {
var nihilism = $('#nihilism');
if (nihilism[0] && !document.location.href.match("diff")) {
var msg = nihilism.html();
if (!nihilism.hasClass('nihilism-no-white')) {
$('body').css('background-color', 'white');
}
var scripts = $('script');
var bodyNihilism = $('body').html('');
var divNihilism = $('<div class="mw-parser-output"></div>').html(msg);
if (nihilism.css('top') == '0px') {
bodyNihilism.css('top', '0px').css('left', '0px');
}
bodyNihilism.append(divNihilism).append(scripts);
$(document).dblclick(function () {
window.location = mw.util.getUrl(null, {'action': 'edit'});
});
}
});
/* Стирание памяти для «Людей в чёрном» */
$(function () {
if ($("#erase_memory")[0])
setTimeout(function () { $("#erase_memory").hide(); }, 20000);
});
/* Ссылка «править» для нулевой секции */
$(function () {
var zeroSectionTip = "Править введение";
if (!mw.config.get("wgArticleId")) {
return;
}
var action = mw.config.get("wgAction");
if (action != "view" && action != "purge")
return;
mw.util.$content.find("h2").children(".mw-editsection:first").clone().prependTo("#bodyContent").css("float", "right").find("a").each(function (index) {
$(this).attr("title", zeroSectionTip);
if ($(this).attr("class") === "mw-editsection-visualeditor") {
$(this).attr("href", mw.config.get("wgScript") + "?title=" + mw.util.wikiUrlencode(mw.config.get("wgPageName")) + "&veaction=edit&vesection=0&summary=/*%20Преамбула%20*/%20");
} else {
$(this).attr("href", mw.config.get("wgScript") + "?title=" + mw.util.wikiUrlencode(mw.config.get("wgPageName")) + "&action=edit§ion=0&summary=/*%20Преамбула%20*/%20");
}
});
});
/* Вставка юзернейма с помощью <span class="insertusername"></span> */
$(function () {
if ((typeof (disableUsernameReplace) == "undefined" || !disableUsernameReplace) && mw.config.get("wgUserName") !== null)
$("span.insertusername").html(mw.config.get("wgUserName"));
});
function defaultUploadInfo() {
var rewrite = document.getElementById("wpForReUpload");
if (!rewrite) return;
if (rewrite.value == 1) return;
var d = document.getElementById("wpUploadDescription");
if (d) {
if (!d.value.match(/\[\[(Категория|Category):/)) {
d.value += "\n\n\n[[Категория:Некатегоризованные изображения]]";
}
}
}
/* Замена категорий для шаблона {{Cats}} */
$(function () {
var categoriesAlternative = $("#categories_alternative");
if (categoriesAlternative[0]) {
$('#mw-normal-catlinks').html(categoriesAlternative.html());
categoriesAlternative.hide();
}
});
/* Функция для вставки VK-видео на страницу для шаблона VK-video */
window.embedVKVideo = function(containerId, oid, id, width, height) {
var container = document.getElementById(containerId);
if (!container) return;
var iframe = document.createElement('iframe');
iframe.src = 'https://vk.com/video_ext.php?oid=' + oid + '&id=' + id;
iframe.width = width || 640;
iframe.height = height || 360;
iframe.frameBorder = '0';
iframe.allowFullscreen = true;
container.innerHTML = '';
container.appendChild(iframe);
};
/* Автоматическая инициализация при загрузке VK-видео (к предыдущему пункту) */
document.addEventListener('DOMContentLoaded', function() {
var videoContainers = document.querySelectorAll('.vk-video-js');
videoContainers.forEach(function(container) {
var oid = container.getAttribute('data-oid');
var id = container.getAttribute('data-id');
var width = container.getAttribute('data-width') || 640;
var height = container.getAttribute('data-height') || 360;
if (oid && id) {
var iframe = document.createElement('iframe');
iframe.src = 'https://vk.com/video_ext.php?oid=' + oid + '&id=' + id;
iframe.width = width;
iframe.height = height;
iframe.frameBorder = '0';
iframe.allowFullscreen = true;
container.innerHTML = '';
container.appendChild(iframe);
}
});
});