<commit_before>$(document).ready(function() {
    renderContainer(template_data);
    startHandlers();
    $('#summary').scrollToFixed();
});

function renderContainer(data) {
    dust.render('container', template_data,

    function(err, out) {
        if (err) {
            console.log(err);
        }
        $('.container').html(out);
    });
}

function resetButton() {
    $('#btn-reset').on('click', function(event) {
        for (var i = 0; i < template_data.slots.length; i++) {
            resetSlot(template_data.slots[i].id_prefix);
        }
        updatePrimaryStats();
        updateOffensiveDefensiveStats();
    });
};

function resetSlot(slotId) {
    $('#' + slotId + '-ql').val('10.0');
    $('#' + slotId + '-role').val('none');
    $('#' + slotId + '-glyph-ql').val('10.0');
    $('#' + slotId + '-primary-glyph').val('none');
    $('#' + slotId + '-secondary-glyph').val('none');
    $('#' + slotId + '-primary-glyph-dist-btn0').trigger('click');
    $('#' + slotId + '-secondary-glyph-dist-btn0').trigger('click');
};

function addAllRoleListenerToButton(role) {
  $('#btn-all-'+role).on('click', function(event) {
        for (var i = 0; i < template_data.slots.length; i++) {
            setRole(template_data.slots[i].id_prefix, role);
        }
        updatePrimaryStats();
        updateOffensiveDefensiveStats();
    });  
};

function setRole(slotId, role) {
    $('#'+slotId+'-role').val(role);
};

function startHandlers() {
    for (var i = 0; i < template_data.slots.length; i++) {
        var buttonHandler = new ButtonHandler(template_data.slots[i].id_prefix);
        buttonHandler.initiate();
        var selectHandler = new SelectHandler(template_data.slots[i].id_prefix);
        selectHandler.initiate();
    }
    resetButton();
    addAllRoleListenerToButton('dps');
    addAllRoleListenerToButton('healer');
    addAllRoleListenerToButton('tank');
}

function updatePrimaryStats() {
    sumHitPoints = 0;
    sumAttackRating = 0;
    sumHealRating = 0;
    for (var i = 0; i < template_data.slots.length; i++) {
        var role = $('#' + template_data.slots[i].id_prefix + '-role option:selected').attr('value');
        var ql = $('#' + template_data.slots[i].id_prefix + '-ql option:selected').attr('value');
        if (role == 'dps') {
            sumAttackRating += custom_gear_data[template_data.slots[i].group].heal_dps['ql' + (ql)].rating;
        } else if (role == 'healer') {
            sumHealRating += custom_gear_data[template_data.slots[i].group].heal_dps['ql' + (ql)].rating;
        } else if (role == 'tank') {
            sumHitPoints += custom_gear_data[template_data.slots[i].group].tank['ql' + (ql)].hitpoints;
        }
    }
    $('#stat-hitpoints').text(sumHitPoints);
    $('#stat-attack-rating').text(sumAttackRating);
    $('#stat-heal-rating').text(sumHealRating);
}

function updateOffensiveDefensiveStats() {
    sums = {
        'critical-rating': 0,
        'critical-power': 0,<commit_msg>Added working All 10.4/10.5 buttons<commit_after>$(document).ready(function() {
    renderContainer(template_data);
    startHandlers();
    $('#summary').scrollToFixed();
});

function renderContainer(data) {
    dust.render('container', template_data,

    function(err, out) {
        if (err) {
            console.log(err);
        }
        $('.container').html(out);
    });
}

function resetButton() {
    $('#btn-reset').on('click', function(event) {
        for (var i = 0; i < template_data.slots.length; i++) {
            resetSlot(template_data.slots[i].id_prefix);
        }
        updatePrimaryStats();
        updateOffensiveDefensiveStats();
    });
};

function resetSlot(slotId) {
    $('#' + slotId + '-ql').val('10.0');
    $('#' + slotId + '-role').val('none');
    $('#' + slotId + '-glyph-ql').val('10.0');
    $('#' + slotId + '-primary-glyph').val('none');
    $('#' + slotId + '-secondary-glyph').val('none');
    $('#' + slotId + '-primary-glyph-dist-btn0').trigger('click');
    $('#' + slotId + '-secondary-glyph-dist-btn0').trigger('click');
};

function addAllRoleListenerToButton(role) {
    $('#btn-all-' + role).on('click', function(event) {
        for (var i = 0; i < template_data.slots.length; i++) {
            setRole(template_data.slots[i].id_prefix, role);
        }
        updatePrimaryStats();
        updateOffensiveDefensiveStats();
    });
};

function addAllQlListenerToButton(ql) {
    qlid = ql.replace('.', '-');
    $('#btn-all-' + qlid).on('click', function(event) {
        for (var i = 0; i < template_data.slots.length; i++) {
            setQl(template_data.slots[i].id_prefix, ql);
        }
        updatePrimaryStats();
        updateOffensiveDefensiveStats();
    });
}

function setQl(slotId, ql) {
    $('#' + slotId + '-ql').val(ql);
    $('#' + slotId + '-glyph-ql').val(ql);
    $('#' + slotId + '-primary-glyph-dist-btn4').trigger('click');
};

function setRole(slotId, role) {
    $('#' + slotId + '-role').val(role);
};

function startHandlers() {
    for (var i = 0; i < template_data.slots.length; i++) {
        var buttonHandler = new ButtonHandler(template_data.slots[i].id_prefix);
        buttonHandler.initiate();
        var selectHandler = new SelectHandler(template_data.slots[i].id_prefix);
        selectHandler.initiate();
    }
    resetButton();
    addAllRoleListenerToButton('dps');
    addAllRoleListenerToButton('healer');
    addAllRoleListenerToButton('tank');
    addAllQlListenerToButton('10.4');
    addAllQlListenerToButton('10.5');
}

function updatePrimaryStats() {
    sumHitPoints = 0;
    sumAttackRating = 0;
    sumHealRating = 0;
    for (var i = 0; i < template_data.slots.length; i++) {
        var role = $('#' + template_data.slots[i].id_prefix + '-role option:selected').attr('value');
        var ql = $('#' + template_data.slots[i].id_prefix + '-ql option:selected').attr('value');
        if (role == 'dps') {
            sumAttackRating += custom_gear_data[template_data.slots[i].group].heal_dps['ql' + (ql)].rating;
        } else if (role == 'healer') {
            sumHealRating += custom_gear_data[template_data.slots[i].group].heal_dps['ql' + (ql)].rating;
        } else if (role == 'tank') {
            sumHitPoints += custom_gear_data[template_data.slots[i].group].tank['ql' + (ql)].hitpoints;
        }
    }
    $('#stat-hitpoints').text(sumHitPoints);
    $('#stat-attack-rating').text(sumAttackRating);
    $('#stat-heal-rating').text(sumHealRating);
}

function updateOffensiveDefensiveStats() {
    sums = {
        'critical-rating': 0,
        'critical-power': 0,
{'fraction_non_alphanumeric': 0.19509968041394005, 'fraction_numerical': 0.007304824227667022, 'mean_word_length': 3.1203761755485893, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2101409', 'n_tokens_mistral': 2213, 'n_tokens_neox': 2176, 'n_words': 316}