Widget:Sort Passive

 function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f} r(function{ var variant = ; var passive_sort, subheader, columns, effect_columns; var effects_raw = []; var sorted = []; var effects = {   base: [], static: [], eqdh: [], eqdw: [], esper: [], evoke: [],    killer: [], damage: [], lbdamage: [], modifier: [],    target: [], evade: [], guts: [], cover: [], counter: [], resist: [],    dw: [], lb: [], refresh: [], auto: [], desperation: [], other: [] }; var regex = {    dw: /enable dual wielding|chain modifier|dual wield mastery/i,    eqdh: /increase (equipment|.*accuracy).* when single wielding/i,    eqdw: /increase (equipment|.*accuracy).* when dual wielding/i,    esper: /'s bonus (HP|MP|ATK|DEF|MAG|SPR|stats)/,    evoke: /evoke damage/i,    killer: /damage against/i,    damage: /jump damage/i,    lbdamage: /LB damage/i,    modifier: /increase modifier/i,    target: /being targeted/i,    evade: /evasion/i,    guts: /ignore fatal damage/i, cover: /chance to protect/i, counter: /chance to counter|counter chance/i, resist: /resistance|absorb/i, lb: /increase LB/i, refresh: /recover mp/i, auto: /auto-/i, desperation: /when HP drops/i, base: /Increase (HP|MP|ATK|DEF|MAG|SPR|EVO MAG)/, static: /Increase static (HP|MP|ATK|DEF|MAG|SPR)/ };

$("#passive_sort" + variant).show(0).css({'margin':'2px','padding':'2px 8px','background-color':'#6e9fc1','color':'#fafdff','border':'none','border-radius':'6px'}); $("#passive_sort" + variant).click(function{   $(this).text(function(i, text){ return text === "Sort" ? "Unsort" : "Sort"; });   passive_sort = $(this).parent.parent;    subheader = $(passive_sort).nextAll(".subheader").first;    columns = $(subheader).nextUntil(".subheader").has("td[colspan=3][align=left]");    if ($("#passive_sorted" + variant).length) {        $("#passive_sorted" + variant).toggle(0);        $(subheader).toggle(0);        $(columns).toggle(0);    }    else {        $(passive_sort).after(" <\/td><\/tr>");        $(subheader).hide(0);        $(columns).hide(0);        effect_columns = $(columns).find("td[colspan=3][align=left]");        $(effect_columns).each(function{ $(this).children("br").replaceWith(" "); var str = $(this).html.split(" ").map(el => el.trim); $(this).children("newline").replaceWith(" "); effects_raw = effects_raw.concat(str); });

effects_raw.forEach(function(effect){           var other = true;            for (var i in regex){                if (regex[i].test(effect) && other) {                    other = false;                    effects[i].push(effect);                }            }            if (other && effect.indexOf("Requirement") < 0) {                effects["other"].push(effect);            }        }); for (var i in effects){ effects[i].sort; }       sorted.push(["Stats", Array.prototype.concat(effects.base, effects.eqdh, effects.eqdw, effects.static, effects.esper)]); sorted.push(["Offense", Array.prototype.concat(effects.killer, effects.damage, effects.lbdamage, effects.modifier, effects.evoke)]); sorted.push(["Defense", Array.prototype.concat(effects.target, effects.evade, effects.guts, effects.cover, effects.counter, effects.resist)]); sorted.push(["Other", Array.prototype.concat(effects.dw, effects.lb, effects.refresh, effects.auto, effects.desperation, effects.other)]); for (var i in sorted){ (sorted[i][1].length ? $("#passive_sorted" + variant).append(" " + sorted[i][0] + "<\/h4>" + sorted[i][1].join(" ")) : ""); }   } }); }); Sort