MediaWiki:SkillTools.js

/* Skill Template Tools version 0.5alpha, an extension module of ../TemplateTools. * Depends on ../SkillToolsOptions.js and ../SkillToolsChanges.js. * Licensed under BY-NC-SA 2.0 only. * An alternate GDFL licensed version is available elsewhere. * */

document.write(' '); document.write(' ');

function openSkillToolBox{ var toolBox = document.getElementById('skill_tool_box'); if (!toolBox) { createSkillToolBox; } else { toolBox.style.display='block'; }	document.getElementById('templateToolsDiv').style.display='none'; }

function createSkillToolBox { var toolsDiv = document.createElement("div"); toolsDiv.style.border='1px solid black'; toolsDiv.id = 'skill_tools'; toolsDiv.style.clear='both'; toolsDiv.innerHTML = '\n' + 'Skill Template Tools version 0.5alpha, released under CC-BY-SA only. report a bug \n' + 'Return to main menu \n' + 'Name=    \n' + 'Number of effects : \n' + '	 0 \n' + '	 1 \n' + '	 2 \n' + '	 3 \n' + '	 4 \n' + ' \n' + ' \n' + ' Desc=  ' + ' \n' + ' Unparsed:  ' + ' Template)" onClick="fillOutSkillTemplate"/>\n' + ' Form)" onClick="extractSkillTemplate"/>\n' + ' \n'; var editBuffer = document.getElementById("editform"); editBuffer.parentNode.insertBefore(toolsDiv, editBuffer); extractSkillTemplate; }

function fillOutSkillTemplate{ var toolBox = document.getElementById('skill_tool_box'); var output = '{{{Skill box {{{1|}}}|\n\t' + 'name=' + toolBox.SkillNameEn.value + '|\n\t' + 'campaign=' + toolBox.CampaignSel.value + '|\n\t' + 'profession=' + toolBox.ProfessionSel.value + '|\n\t' + 'attribute=' + toolBox.AttributeSel.value + '|\n\t' + 'type=' + toolBox.SkillTypeSel.value + '|'; if (toolBox.eliteness.checked){ output = output + 'elite=yes|\n\t'; } 	if (toolBox.costSel.value){ output = output + toolBox.costSel.value + '=' + toolBox.costNum.value + '|\n\t'; }	if (toolBox.castTime.value){ output = output	+ 'activation=' + toolBox.castTime.value + '|\n\t' }	if (toolBox.rechargeNum.value && toolBox.rechargeNum.value != 0){ output = output	+ 'recharge=' + toolBox.rechargeNum.value + '|\n\t' }	output = output + 'stat0=' + toolBox.miscSel.value + '|' switch (toolBox.miscSel.value){ case 'exhaustion': toolBox.miscNum.value = 'yes'; case 'upkeep': case 'sacrifice': output = output + toolBox.miscSel.value + '=' + toolBox.miscNum.value + '|\n\t'; default: }	output = output + 'description=' + toolBox.descText.value + '|\n\t'

switch (toolBox.effectCountSel.value){ case '4': output = output + 'progression_3_effect=' + toolBox.effect4_partial.value + toolBox.effect4Sel.value + toolBox.effect4_other.value + '|progression_3_0=' + toolBox.effect4_0.value + '|progression_3_15=' + toolBox.effect4_15.value + '|\n'; case '3': output = output + 'progression_2_effect=' + toolBox.effect3_partial.value + toolBox.effect3Sel.value + toolBox.effect3_other.value + '|progression_2_0=' + toolBox.effect3_0.value + '|progression_2_15=' + toolBox.effect3_15.value + '|\n'; case '2': output = output + 'progression_1_effect=' + toolBox.effect2_partial.value + toolBox.effect2Sel.value + toolBox.effect2_other.value + '|progression_1_0=' + toolBox.effect2_0.value + '|progression_1_15=' + toolBox.effect2_15.value + '|\n'; case '1': output = output + 'progression_0_effect=' + toolBox.effect1_partial.value + toolBox.effect1Sel.value + toolBox.effect1_other.value + '|progression_0_0=' + toolBox.effect1_0.value + '|progression_0_15=' + toolBox.effect1_15.value + '|\n'; default: output = output + toolBox.unparsedText.join('') + '}}\n'; }	document.editform.wpTextbox1.value = output; }

/* The following function assumes the entire list of parameters for * {{Skill box {{{1|}}} resides in its own article. If it is within * some other article, such is the case with most other types of info * box templates (beastinfo, weapons, locations etc), then additional * extraction is needed. See *     http://guildwars.wikia.com/wiki/MediaWiki:SkillTools.js  * for an example. */ function extractSkillTemplate{ var input = document.editform.wpTextbox1.value;

if(input.indexOf('{{Skill box {{{1|}}}')!= -1) { openSkillToolBox; parseSkillTemplate(input); return true; }	return false; }

function parseSkillTemplate(input){ var toolBox = document.getElementById('skill_tool_box');

var trimmed = input.replace(/\t/g,).replace(/\n/g,'|').replace('{{Skill box {{{1|}}}',); var assignments = trimmed.split('|');

toolBox.SkillNameEn.value = extractParameter('name', assignments); toolBox.CampaignSel.value = extractParameter('campaign', assignments); toolBox.ProfessionSel.value = extractParameter('profession', assignments); profChange; toolBox.AttributeSel.value = extractParameter('attribute', assignments); toolBox.SkillTypeSel.value = extractParameter('type', assignments); if (extractParameter('elite', assignments) == 'yes'){ toolBox.eliteness.checked = true; eliteChange; }

var val1 = extractParameter('energy', assignments); if (val1){ toolBox.costSel.value = 'energy'; costChange toolBox.costNum.value = val1; } else { val1 = extractParameter('adrenaline', assignments); if (val1){ toolBox.costSel.value = 'adrenaline'; costChange toolBox.costNum.value = val1; } else { toolBox.cosSel.value = ''; }	}

toolBox.castTime.value = extractParameter('activation', assignments); toolBox.rechargeNum.value = extractParameter('recharge', assignments);

var val0 = extractParameter('upkeep', assignments); if (val0){ toolBox.miscSel.value = 'upkeep'; miscChange toolBox.miscNum.value = val0; } else { val0 = extractParameter('sacrifice', assignments); if (val0){ toolBox.costSel.value = 'sacrifice'; miscChange toolBox.costNum.value = val0; } else { val0 = extractParameter('exhaustion', assignments); if (val0 == 'yes' ){ toolBox.costSel.value = 'exhaustion'; miscChange toolBox.costNum.value = val0; } else { toolBox.cosSel.value = ''; }		}	}

toolBox.descText.innerHTML = extractParameter('description', assignments);

var eff4 = extractParameter('progression_3_effect', assignments); var eff3 = extractParameter('progression_2_effect', assignments); var eff2 = extractParameter('progression_1_effect', assignments); var eff1 = extractParameter('progression_0_effect', assignments); var effCount = 0; if (eff4){ effCount = 4; } else if (eff3){ effCount = 3; } else if (eff2){ effCount = 2; } else if (eff1){ effCount = 1; } 	toolBox.effectCountSel.value = effCount; effectCountChange switch (effCount){ case 4: toolBox.effect4_other.value = eff4; toolBox.effect4_0.value = extractParameter('progression_3_0', assignments); toolBox.effect4_15.value = extractParameter('progression_3_15', assignments); case 3: toolBox.effect3_other.value = eff3; toolBox.effect3_0.value = extractParameter('progression_2_0', assignments); toolBox.effect3_15.value = extractParameter('progression_2_15', assignments); case 2: toolBox.effect2_other.value = eff2; toolBox.effect2_0.value = extractParameter('progression_1_0', assignments); toolBox.effect2_15.value = extractParameter('progression_1_15', assignments); case 1: toolBox.effect1_other.value = eff1; toolBox.effect1_0.value = extractParameter('progression_0_0', assignments); toolBox.effect1_15.value = extractParameter('progression_0_15', assignments); default: }	var unparsed = ''; for (var j=0; j < assignments.length; j++){ if (assignments[j] != ''){ unparsed = unparsed + assignments[j] + '|\n\t'; }	}	toolBox.unparsedText.value = unparsed; }

/* */