MediaWiki:BloodTest.js — различия между версиями
Материал из Guild Wars 2 wiki
Blood (обсуждение | вклад) |
Blood (обсуждение | вклад) |
||
Строка 4: | Строка 4: | ||
(function() { | (function() { | ||
− | document. | + | var buttonsContainer = document.getElementById("gmvbuttons"), |
− | document.querySelectorAll(".gamemode. | + | buttons, button, i; |
− | document.querySelectorAll(".gamemode.pve").forEach( | + | |
+ | if (!buttonsContainer) return; | ||
+ | |||
+ | buttons = buttonsContainer.getAttribute("data-gmvbuttons").split(","); | ||
+ | for (i = 0; i < buttons.length; i++) { | ||
+ | button = document.createElement("button"); | ||
+ | button.setAttribute("id", buttons[i]); | ||
+ | button.setAttribute("class", "gmvbutton"); | ||
+ | button.innerHTML = "<b><img alt='Game mode version' " + | ||
+ | "src='https://wiki.guildwars2.com/images/thumb/c/cc/Hero_panel_Menu_Bar_icon.png/16px-Hero_panel_Menu_Bar_icon.png' width='16' height='16'" + | ||
+ | "srcset='https://wiki.guildwars2.com/images/thumb/c/cc/Hero_panel_Menu_Bar_icon.png/24px-Hero_panel_Menu_Bar_icon.png 1.5x, " + | ||
+ | "https://wiki.guildwars2.com/images/c/cc/Hero_panel_Menu_Bar_icon.png 2x'> " + | ||
+ | buttons[i].replace(/\s/i, " / ").toUpperCase() + " </b>"; | ||
+ | buttonsContainer.appendChild(button); | ||
+ | } | ||
+ | |||
+ | |||
+ | document.querySelectorAll(".gamemode.wvw:not(.pve)").forEach(hide); | ||
+ | document.querySelectorAll(".gamemode.pvp:not(.pve)").forEach(hide); | ||
function hide(elem) { | function hide(elem) { | ||
elem.style.display = "none"; | elem.style.display = "none"; | ||
− | |||
− | |||
− | |||
− | |||
} | } | ||
})(); | })(); |
Версия 22:33, 20 мая 2018
/* Для тестирования разной фигни. * Подгружается через MediaWiki:Common.js */ (function() { var buttonsContainer = document.getElementById("gmvbuttons"), buttons, button, i; if (!buttonsContainer) return; buttons = buttonsContainer.getAttribute("data-gmvbuttons").split(","); for (i = 0; i < buttons.length; i++) { button = document.createElement("button"); button.setAttribute("id", buttons[i]); button.setAttribute("class", "gmvbutton"); button.innerHTML = "<b><img alt='Game mode version' " + "src='https://wiki.guildwars2.com/images/thumb/c/cc/Hero_panel_Menu_Bar_icon.png/16px-Hero_panel_Menu_Bar_icon.png' width='16' height='16'" + "srcset='https://wiki.guildwars2.com/images/thumb/c/cc/Hero_panel_Menu_Bar_icon.png/24px-Hero_panel_Menu_Bar_icon.png 1.5x, " + "https://wiki.guildwars2.com/images/c/cc/Hero_panel_Menu_Bar_icon.png 2x'> " + buttons[i].replace(/\s/i, " / ").toUpperCase() + " </b>"; buttonsContainer.appendChild(button); } document.querySelectorAll(".gamemode.wvw:not(.pve)").forEach(hide); document.querySelectorAll(".gamemode.pvp:not(.pve)").forEach(hide); function hide(elem) { elem.style.display = "none"; } })();