Widget:chibiCommander: Difference between revisions
Jump to navigation
Jump to search
Different loading order |
Dynamic resources |
||
Line 1: | Line 1: | ||
<includeonly><script> | <includeonly><script> | ||
function initSelects(resourcesUl) { | |||
var resources = {}; | |||
var parts = resourcesUl; | |||
parts.children('li').each(function() { | |||
var part = $(this); | |||
part.typ = part.contents().get(0).nodeValue.trim(); | |||
part.costumes = {}; | |||
part.children('ul').children('li').each(function() { | |||
var costumeLi = $(this); | |||
var costume = {}; | |||
costumeLi.children('ul').children('li').each(function() { | |||
var dataLi = $(this); | |||
var paramFull = dataLi.contents().get(0).nodeValue.trim(); | |||
if (paramFull === "colors") { | |||
dataLi.children('ul').children('li').each(function() { | |||
var colorLi = $(this); | |||
costume.colors = costume.colors || []; | |||
var colorLink = colorLi.children('a').first().attr('href'); | |||
var colorLinkParts = colorLink.split('/'); | |||
costume.colors.push(colorLinkParts[colorLinkParts.length-1]); | |||
}); | |||
} else { | |||
var paramName = paramFull.split(":")[0]; | |||
var paramLink = dataLi.children('a').first().attr('href'); | |||
var paramLinkParts = paramLink.split('/'); | |||
costume[paramName] = paramLinkParts[paramLinkParts.length-1]; | |||
} | |||
}); | |||
costume.costumeId = costumeLi.contents().get(0).nodeValue.trim(); | |||
part.costumes[costume.costumeId] = costume; | |||
}); | |||
resources[part.typ] = part; | |||
}); | |||
for (var partKey in resources) { | |||
var part = resources[partKey]; | |||
for (var costumeKey in part.costumes) { | |||
var costume = part.costumes[costumeKey]; | |||
var colIdx = -1; | |||
for (var colorKey in costume.colors) { | |||
var color = costume.colors[colorKey]; | |||
var colName = colIdx == -1 ? "(Default)" : colIdx; | |||
$('.commander-sim-option.' + part.typ).append($('<option>', { | |||
value: costume.skel + ";" + costume.atlas + ";" + color, | |||
text: costume.costumeId + " " + colName | |||
})); | |||
} | |||
} | |||
} | |||
} | |||
RLQ.push(['jquery', function () { | RLQ.push(['jquery', function () { | ||
$(document).ready(function() { | $(document).ready(function() { | ||
Line 7: | Line 68: | ||
window.animations.PIXILoader.init().then(function() { | window.animations.PIXILoader.init().then(function() { | ||
// Let's make sure the correct values are shown | // Let's make sure the correct values are shown | ||
initSelects($('.commander-chibi-controls-panel-resources>ul')); | |||
$('.commander-sim-option').first().change(); | $('.commander-sim-option').first().change(); | ||
}, function(x,y,z) { | }, function(x,y,z) { | ||
Line 30: | Line 92: | ||
</script> | </script> | ||
<div class="commander-chibi-container"><div id="cancan" class="chibiAnimationContainer commander-chibi" data-tdoll-hidedormbutton="true"></div></div> | <div class="commander-chibi-container"><div id="cancan" class="chibiAnimationContainer commander-chibi" data-tdoll-hidedormbutton="true"></div></div> | ||
<div class="commander-chibi-controls-panel"> | <div class="commander-chibi-controls-panel"><div class="commander-chibi-controls-panel-resources" style="display:none;"><!--{$data}--></div> | ||
<label class="commander-sim-option-label head">Head: | <label class="commander-sim-option-label head">Head: | ||
<select class="gf-droplist commander-sim-option head" autocomplete="off"> | <select class="gf-droplist commander-sim-option head" autocomplete="off"></select> | ||
</label> | </label> | ||
<label class="commander-sim-option-label body">Body: | <label class="commander-sim-option-label body">Body: | ||
<select class="gf-droplist commander-sim-option body" autocomplete="off"> | <select class="gf-droplist commander-sim-option body" autocomplete="off"></select> | ||
</label> | </label> | ||
<label class="commander-sim-option-label feet">Feet: | <label class="commander-sim-option-label feet">Feet: | ||
<select class="gf-droplist commander-sim-option feet" autocomplete="off"> | <select class="gf-droplist commander-sim-option feet" autocomplete="off"></select> | ||
</label> | |||
</div></includeonly><noinclude>{{#widget:chibiCommander|data={{Widget:{{BASEPAGENAME}}/commanderResources}}}}</noinclude> | |||
</div></includeonly><noinclude>{{#widget:chibiCommander}}</noinclude> |
Revision as of 00:32, 13 November 2019