MediaWiki:BloodTest.js — различия между версиями
Материал из Guild Wars 2 wiki
Blood (обсуждение | вклад) |
Blood (обсуждение | вклад) |
||
Строка 5: | Строка 5: | ||
(function() { | (function() { | ||
var buttonsContainer = document.getElementById("gmvbuttons"), | var buttonsContainer = document.getElementById("gmvbuttons"), | ||
− | buttons, button, i; | + | buttons, button, pveIcon, pvpIcon, wvwIcon, i; |
if (!buttonsContainer) return; | if (!buttonsContainer) return; | ||
+ | |||
+ | pveIcon = "<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'> "; | ||
+ | pvpIcon = "<img alt='Game mode version' " + | ||
+ | "src='https://wiki.guildwars2.com/images/thumb/2/23/PvP_Menu_Bar_icon.png/16px-PvP_Menu_Bar_icon.png' width='16' height='16' " + | ||
+ | "srcset='https://wiki.guildwars2.com/images/thumb/2/23/PvP_Menu_Bar_icon.png/24px-PvP_Menu_Bar_icon.png 1.5x, " + | ||
+ | "https://wiki.guildwars2.com/images/2/23/PvP_Menu_Bar_icon.png 2x'> "; | ||
+ | wvwIcon = "<img alt='Game mode version' " + | ||
+ | "src='https://wiki.guildwars2.com/images/thumb/1/1b/WvW_Menu_Bar_icon.png/16px-WvW_Menu_Bar_icon.png' width='16' height='16' " + | ||
+ | "srcset='https://wiki.guildwars2.com/images/thumb/1/1b/WvW_Menu_Bar_icon.png/24px-WvW_Menu_Bar_icon.png 1.5x, " + | ||
+ | "https://wiki.guildwars2.com/images/1/1b/WvW_Menu_Bar_icon.png 2x'> "; | ||
buttons = buttonsContainer.getAttribute("data-gmvbuttons").split(","); | buttons = buttonsContainer.getAttribute("data-gmvbuttons").split(","); | ||
Строка 14: | Строка 27: | ||
button.setAttribute("id", buttons[i]); | button.setAttribute("id", buttons[i]); | ||
button.setAttribute("class", (!i) ? "gmvbutton active" : "gmvbutton"); | button.setAttribute("class", (!i) ? "gmvbutton active" : "gmvbutton"); | ||
− | button.innerHTML = "<b> | + | button.innerHTML = "<b>" + getIcon(buttons[i]) + " </b>"; |
− | |||
− | |||
− | |||
− | |||
buttonsContainer.appendChild(button); | buttonsContainer.appendChild(button); | ||
} | } | ||
Строка 26: | Строка 35: | ||
document.querySelectorAll(".gamemode.pvp:not(.pve)").forEach(hide); | document.querySelectorAll(".gamemode.pvp:not(.pve)").forEach(hide); | ||
+ | function getIcon(type) { | ||
+ | var text = "", typeArr, i; | ||
+ | switch (type) { | ||
+ | case "pve": | ||
+ | return pveIcon + type.toUpperCase(); | ||
+ | case "pvp": | ||
+ | return pvpIcon + type.toUpperCase(); | ||
+ | case "wvw": | ||
+ | return wvwIcon + type.toUpperCase(); | ||
+ | case "pve wvw": | ||
+ | |||
+ | /*typeArr = type.split(" "); | ||
+ | for (i = 0; i < typeArr.length; i++) { | ||
+ | text += pveIcon + type.replace(/\s+/i, " / ").toUpperCase() + wvwIcon; | ||
+ | } | ||
+ | return text;*/ | ||
+ | |||
+ | return pveIcon + type.replace(/\s+/i, " / ").toUpperCase() + wvwIcon; | ||
+ | case "pve pvp": | ||
+ | |||
+ | /*typeArr = type.split(" "); | ||
+ | for (i = 0; i < typeArr.length; i++) { | ||
+ | text += pveIcon + type.replace(/\s+/i, " / ").toUpperCase() + pvpIcon; | ||
+ | } | ||
+ | return text;*/ | ||
+ | |||
+ | return pveIcon + type.replace(/\s+/i, " / ").toUpperCase() + pvpIcon; | ||
+ | case "wvw pvp": | ||
+ | |||
+ | /*typeArr = type.split(" "); | ||
+ | for (i = 0; i < typeArr.length; i++) { | ||
+ | text += wvwIcon + type.replace(/\s+/i, " / ").toUpperCase() + pvpIcon; | ||
+ | } | ||
+ | return text;*/ | ||
+ | |||
+ | return wvwIcon + type.replace(/\s+/i, " / ").toUpperCase() + pvpIcon; | ||
+ | } | ||
+ | } | ||
+ | |||
function hide(elem) { | function hide(elem) { | ||
elem.style.display = "none"; | elem.style.display = "none"; | ||
} | } | ||
})(); | })(); |
Версия 23:12, 20 мая 2018
/* Для тестирования разной фигни. * Подгружается через MediaWiki:Common.js */ (function() { var buttonsContainer = document.getElementById("gmvbuttons"), buttons, button, pveIcon, pvpIcon, wvwIcon, i; if (!buttonsContainer) return; pveIcon = "<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'> "; pvpIcon = "<img alt='Game mode version' " + "src='https://wiki.guildwars2.com/images/thumb/2/23/PvP_Menu_Bar_icon.png/16px-PvP_Menu_Bar_icon.png' width='16' height='16' " + "srcset='https://wiki.guildwars2.com/images/thumb/2/23/PvP_Menu_Bar_icon.png/24px-PvP_Menu_Bar_icon.png 1.5x, " + "https://wiki.guildwars2.com/images/2/23/PvP_Menu_Bar_icon.png 2x'> "; wvwIcon = "<img alt='Game mode version' " + "src='https://wiki.guildwars2.com/images/thumb/1/1b/WvW_Menu_Bar_icon.png/16px-WvW_Menu_Bar_icon.png' width='16' height='16' " + "srcset='https://wiki.guildwars2.com/images/thumb/1/1b/WvW_Menu_Bar_icon.png/24px-WvW_Menu_Bar_icon.png 1.5x, " + "https://wiki.guildwars2.com/images/1/1b/WvW_Menu_Bar_icon.png 2x'> "; 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", (!i) ? "gmvbutton active" : "gmvbutton"); button.innerHTML = "<b>" + getIcon(buttons[i]) + " </b>"; buttonsContainer.appendChild(button); } document.querySelectorAll(".gamemode.wvw:not(.pve)").forEach(hide); document.querySelectorAll(".gamemode.pvp:not(.pve)").forEach(hide); function getIcon(type) { var text = "", typeArr, i; switch (type) { case "pve": return pveIcon + type.toUpperCase(); case "pvp": return pvpIcon + type.toUpperCase(); case "wvw": return wvwIcon + type.toUpperCase(); case "pve wvw": /*typeArr = type.split(" "); for (i = 0; i < typeArr.length; i++) { text += pveIcon + type.replace(/\s+/i, " / ").toUpperCase() + wvwIcon; } return text;*/ return pveIcon + type.replace(/\s+/i, " / ").toUpperCase() + wvwIcon; case "pve pvp": /*typeArr = type.split(" "); for (i = 0; i < typeArr.length; i++) { text += pveIcon + type.replace(/\s+/i, " / ").toUpperCase() + pvpIcon; } return text;*/ return pveIcon + type.replace(/\s+/i, " / ").toUpperCase() + pvpIcon; case "wvw pvp": /*typeArr = type.split(" "); for (i = 0; i < typeArr.length; i++) { text += wvwIcon + type.replace(/\s+/i, " / ").toUpperCase() + pvpIcon; } return text;*/ return wvwIcon + type.replace(/\s+/i, " / ").toUpperCase() + pvpIcon; } } function hide(elem) { elem.style.display = "none"; } })();