MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 9: | Line 9: | ||
btn.addEventListener('click', function () { | btn.addEventListener('click', function () { | ||
const tabId = this.dataset.tab; | const tabId = this.dataset.tab; | ||
const container = group.closest('.mw-tab-content') || document; | const container = group.closest('.mw-tab-content') || document; | ||
container.querySelectorAll('.mw-tab-content').forEach(c => { | container.querySelectorAll('.mw-tab-content').forEach(c => { | ||
c.style.display = 'none'; | c.style.display = 'none'; | ||
| Line 29: | Line 26: | ||
}); | }); | ||
if (buttons.length > 0) buttons[0].click(); | |||
if (buttons.length > 0) | |||
}); | }); | ||
/* ================= DROPDOWN | /* ================= DROPDOWN ================= */ | ||
function initDropdown(container) { | function initDropdown(container) { | ||
const label = container.dataset.label || "Select"; | const label = container.dataset.label || "Select"; | ||
| Line 41: | Line 35: | ||
const wrapper = document.createElement('div'); | const wrapper = document.createElement('div'); | ||
const button = document.createElement('button'); | |||
const list = document.createElement('div'); | |||
const content = document.createElement('div'); | |||
button.textContent = label; | button.textContent = label; | ||
list.style.display = 'none'; | list.style.display = 'none'; | ||
Object.keys(options).forEach(key => { | Object.keys(options).forEach(key => { | ||
const opt = options[key]; | const opt = options[key]; | ||
const item = document.createElement('div'); | const item = document.createElement('div'); | ||
item.textContent = opt.label; | item.textContent = opt.label; | ||
item.addEventListener('click', function () { | item.addEventListener('click', function () { | ||
button.textContent = opt.label; | button.textContent = opt.label; | ||
list.style.display = 'none'; | list.style.display = 'none'; | ||
if (container.classList.contains('combo-left')) { | |||
window.selectedLeft = key; | |||
} | |||
if (container.classList.contains('combo-right')) { | |||
window.selectedRight = key; | |||
} | |||
updateCombo(); | |||
}); | }); | ||
| Line 83: | Line 77: | ||
document.querySelectorAll('.mw-dropdown-ui').forEach(initDropdown); | document.querySelectorAll('.mw-dropdown-ui').forEach(initDropdown); | ||
/* ================= COMBO LOGIC ================= */ | |||
window.selectedLeft = null; | |||
window.selectedRight = null; | |||
function updateCombo() { | |||
const result = document.getElementById('combo-result'); | |||
if (!result) return; | |||
if (selectedLeft === 'flame_resonance' && selectedRight === 'burn') { | |||
result.innerHTML = "Max Burn Stack +2, Burn Duration -20%. Flash Effect: Burn DMG +5%"; | |||
} else { | |||
result.innerHTML = "No data for this combination."; | |||
} | |||
} | |||
}); | }); | ||
}); | }); | ||
Revision as of 18:27, 21 April 2026
mw.loader.using('mediawiki.util').then(function () {
$(function () {
/* ================= TAB SYSTEM ================= */
document.querySelectorAll('.mw-tab-buttons').forEach(group => {
const buttons = group.querySelectorAll('.mw-tab-btn');
buttons.forEach(btn => {
btn.addEventListener('click', function () {
const tabId = this.dataset.tab;
const container = group.closest('.mw-tab-content') || document;
container.querySelectorAll('.mw-tab-content').forEach(c => {
c.style.display = 'none';
});
container.querySelectorAll('.mw-tab-btn').forEach(b => {
b.classList.remove('active');
});
this.classList.add('active');
const target = container.querySelector('#' + tabId);
if (target) target.style.display = 'block';
});
});
if (buttons.length > 0) buttons[0].click();
});
/* ================= DROPDOWN ================= */
function initDropdown(container) {
const label = container.dataset.label || "Select";
const options = JSON.parse(container.dataset.options || "{}");
const wrapper = document.createElement('div');
const button = document.createElement('button');
const list = document.createElement('div');
const content = document.createElement('div');
button.textContent = label;
list.style.display = 'none';
Object.keys(options).forEach(key => {
const opt = options[key];
const item = document.createElement('div');
item.textContent = opt.label;
item.addEventListener('click', function () {
button.textContent = opt.label;
list.style.display = 'none';
if (container.classList.contains('combo-left')) {
window.selectedLeft = key;
}
if (container.classList.contains('combo-right')) {
window.selectedRight = key;
}
updateCombo();
});
list.appendChild(item);
});
button.addEventListener('click', function () {
list.style.display = list.style.display === 'none' ? 'block' : 'none';
});
wrapper.appendChild(button);
wrapper.appendChild(list);
wrapper.appendChild(content);
container.innerHTML = '';
container.appendChild(wrapper);
}
document.querySelectorAll('.mw-dropdown-ui').forEach(initDropdown);
/* ================= COMBO LOGIC ================= */
window.selectedLeft = null;
window.selectedRight = null;
function updateCombo() {
const result = document.getElementById('combo-result');
if (!result) return;
if (selectedLeft === 'flame_resonance' && selectedRight === 'burn') {
result.innerHTML = "Max Burn Stack +2, Burn Duration -20%. Flash Effect: Burn DMG +5%";
} else {
result.innerHTML = "No data for this combination.";
}
}
});
});