Widget:costumeSwitcher: Difference between revisions
Jump to navigation
Jump to search
Debug Log |
Added document-ready wait functionality as the MediaWiki does not wait for DOM |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<includeonly><script> | <includeonly><script> | ||
RLQ.push(['jquery', function () { | |||
$(document).ready(function() { | |||
// Let's make sure the correct values are shown | |||
$('.modswitcher').change(); | |||
}); | |||
}]); | |||
function swap_mod(element) { | function swap_mod(element) { | ||
var selectBox = $(element); | var selectBox = $(element); | ||
Line 8: | Line 15: | ||
var statContainer = selectBox.closest('.stattable'); | var statContainer = selectBox.closest('.stattable'); | ||
tdollData = updateCalculatedValues(tdollData); | |||
for (var key in tdollData) { | for (var key in tdollData) { | ||
Line 15: | Line 21: | ||
var valField = statContainer.find('*[data-tdoll-stat-id="' + key + '"]'); | var valField = statContainer.find('*[data-tdoll-stat-id="' + key + '"]'); | ||
var newValue = tdollData[key]; | var newValue = tdollData[key]; | ||
valField.text(newValue); | valField.text(newValue); | ||
} | } | ||
} | } | ||
// ToDo: find a better way of finding out if it's a mod | |||
// ToDo: find a better way of telling which skills are available with which mod | |||
var isMod = selectBox.find(':selected').text().indexOf('MOD') >= 0; | |||
statContainer.find('.skillform .tabButtonLane button').last().toggle(isMod); | |||
// With mod-change the visible skillbuttons might change, too, so trigger the last visible one | |||
// For now it only has to be set if we change to Base, as it has only one skill | |||
if (!isMod) { | |||
statContainer.find('.skillform .tabButtonLane button:visible').last().click(); | |||
} | |||
} | |||
function updateCalculatedValues(data) { | |||
var ret = data; | |||
// Calculating Max HP for full dummied T-Doll | |||
if (ret.hasOwnProperty("max_hp_t")) { | |||
ret.hpmaxwd = ret.max_hp_t * 5; | |||
} | |||
return ret; | |||
} | } | ||
Line 48: | Line 75: | ||
selectBox.closest('.costumeContainer').find('.chibiAnimation,.live2dAnimation,.artTab').trigger("costume_changed", chibiCostumeName); | selectBox.closest('.costumeContainer').find('.chibiAnimation,.live2dAnimation,.artTab').trigger("costume_changed", chibiCostumeName); | ||
var basePath = " | var basePath = "https://en.gfwiki.com/images/"; // ToDo: find a better way to find out the base path | ||
var tdollId = selectBox.closest('.costumeContainer').find('.tdoll_chibi').data('tdollId'); | var tdollId = selectBox.closest('.costumeContainer').find('.tdoll_chibi').data('tdollId'); | ||
var costumeId = tdollId + chibiCostumeName; | var costumeId = tdollId + chibiCostumeName; | ||
Line 77: | Line 104: | ||
</script> | </script> | ||
<div style="display:flex"> | <div style="display:flex"> | ||
<!--{if $moddable neq ''}--><select class="gf-droplist" style="padding-left: 2px;padding-right: 8px;margin-right: 2px;" autocomplete="off" onchange="swap_mod(this)"> | <!--{if $moddable neq ''}--><select class="gf-droplist modswitcher" style="padding-left: 2px;padding-right: 8px;margin-right: 2px;" autocomplete="off" onchange="swap_mod(this)"> | ||
<option value='<!--{$defaultstats|escape:'html'}-->'>BASE</option> | <option value='<!--{$defaultstats|escape:'html'}-->'>BASE</option> | ||
<option value='<!--{$mod1stats|escape:'html'}-->'>MOD1</option> | <option value='<!--{$mod1stats|escape:'html'}-->'>MOD1</option> |