Widget:Skill filter

 /** * Function that filters skills based on: *  - Skill name *  - Skill Type (Active/Passive) *  - Skill Level Learned **/ function filterSkills { // Get all the values from the filter / select inputs var skillNameText = document.getElementById("skill-name-search-text").value.toUpperCase; var skillTypeSelect = document.getElementById("skill-type-select").value; var skillLevelSelect = document.getElementById("skill-level-select").value;

// Get all the skills var skillsToFilter = document.getElementsByClassName("skill-collapsible");

// Go through every skill for (var i = 0; i < skillsToFilter.length; i++) { // Get the skill information from the data attributes var skillName = skillsToFilter[i].getAttribute("data-skill-name"); var skillType = skillsToFilter[i].getAttribute("data-skill-type"); var skillLevel = skillsToFilter[i].getAttribute("data-skill-level");

// Check skill name var matchesSkillName = (skillName.toUpperCase.indexOf(skillNameText) > -1);

// Check skill type var hasSkillType = (skillTypeSelect == "" || skillType == skillTypeSelect);

// Check skill level var levels = skillLevelSelect.split("-"); var inSkillLevel = isInLevelRange(skillLevel, levels);

// If it matches all the filter / selects, then display the skill. // Otherwise, hide the skill. if (matchesSkillName && hasSkillType && inSkillLevel) { skillsToFilter[i].style.display = ""; } else { skillsToFilter[i].style.display = "none"; }   } }

/** * Function that returns whether or not a skill level is within a level range * @param skillLevel The level the skill is learned at * @param levels Array with the min and max level range * @return bool **/ function isInLevelRange(skillLevel, levels) { if (skillLevel == "-") { skillLevel = 1; } else { skillLevel = parseInt(skillLevel); }

if (levels.length < 2) { return true; } else { for (var i = 0; i < levels.length; i++) { levels[i] = parseInt(levels[i]); }   }

if (skillLevel >= levels[0] && skillLevel <= levels[1]) { return true; }   return false; }

 Filter skills:   Show all skill types Active Passive  Show all level skills 1-10 11-20 21-30 31-40 41-50