Desnoo / Proxer.me UCP Anime/Mange Filter

// ==UserScript==
// @name         Proxer.me UCP Anime/Mange Filter
// @namespace    http://proxer.me
// @version      1.0
// @description  Filter your anime and manga by the 4 criteria ( geschaut, am schauen...)
// @author       Desnoo
// @match        http://proxer.me/ucp?s=*
// @grant        none
// @run-at       document-end
// ==/UserScript==
/* jshint -W097 */
'use strict';

var optionTargets;

main();

function displayTable(indexClicked){
    optionTargets.each(function(index){
        if(indexClicked === index){
            $(this).css("display","block");          
        } else {
            $(this).css("display","none");
        }
    });
}

function registerOnOptionClick($target, indexClicked){
    $target.on('click', function(e){
        displayTable(indexClicked);
    });
}


function main(){
    var $accordion = $("#accordion");
    var options = $accordion.find(".accordion");
    optionTargets = $accordion.find("table");

    for (var stateNum = 0; stateNum < 4 ; ++ stateNum) {
        $("#state" + stateNum).attr("id", "none");
    };
    options.each(function(index){
        // console.log("Register options");
        registerOnOptionClick($(this), index);
    });
    displayTable(0);

}