<commit_before>function hash_set_value(key, value) {
    // Set value for key in hash
    var hash = $(location).attr('hash').substring(2).toLowerCase().replace(/\/$/, '');
    var keys;
    var values;

    if (!value) {
        value = '';
    }

    if (hash.length > 0) {
        keys = hash.split('/').filter(function(element, index) { return (index % 2 === 0); });
        values = hash.split('/').filter(function(element, index) { return (index % 2 === 1); });
    }
    else {
        keys = [];
        values = [];
    }

    index_of_key = keys.indexOf(key);

    if (index_of_key > -1) {
        values[index_of_key] = value;
    }
    else {
        keys.push(key);
        values.push(value);
    }

    hash = '/';
    for (var i=0; i < keys.length; i++) {
        if (values[i].length > 0 ) {
            hash += keys[i] + '/' + values[i] + '/';
        }
    }

    $(location).attr('hash', hash);
}

function hash_get_value(key) {
    // Get value for key in hash
    var hash = $(location).attr('hash').substring(2).toLowerCase();
    var keys = hash.split('/').filter(function(element, index) { return (index % 2 === 0); });
    var values = hash.split('/').filter(function(element, index) { return (index % 2 === 1); });
    var index_of_key = keys.indexOf(key);
    if (index_of_key > -1) {
        return values[index_of_key].toLowerCase();
    }

    return;
}

function set_dropdown_value(elm, value) {
    elm.val(value);
    // We have to force trigger 'change' for foundation to update.
    elm.trigger('change');
}

function pad2(number) {
    // Pad numbers
    // snippet from
    // http://www.electrictoolbox.com/pad-number-two-digits-javascript/
    return (number < 10 ? '0' : '') + number;
}

function append_to_formset(event) {
    event.preventDefault();
    var button_obj = $(event.currentTarget);
    var formset_obj = button_obj.closest('.formset');
    var block_obj = formset_obj.find('.copyblock').first();
    var new_block_obj = block_obj.clone();
    var prefix = formset_obj.data('prefix');
    var total_forms_obj = formset_obj.parent().children('#id_' + prefix + '-TOTAL_FORMS');
    var append_after_obj = block_obj;
    if (block_obj.siblings('.copyblock').length > 0) {
        append_after_obj = block_obj.siblings('.copyblock').last();
    }

    function attr_update(selector, attr, prepend){
        new_block_obj.find(selector + prefix + "]").each(function (index, item) {
            var item_obj = $(item);
            var item_id = item_obj.attr(attr).split('-').pop()
            newid = prepend + prefix + '-' + total_forms_obj.val() + '-' + item_id;
            item_obj.attr(attr, newid);
        });
    }
    attr_update('[id*=id_', 'id', 'id_');
    attr_update('[name*=', 'name', '');<commit_msg>[fix bug 910770] Not all selected nominees are saved for a rangepoll vote<commit_after>function hash_set_value(key, value) {
    // Set value for key in hash
    var hash = $(location).attr('hash').substring(2).toLowerCase().replace(/\/$/, '');
    var keys;
    var values;

    if (!value) {
        value = '';
    }

    if (hash.length > 0) {
        keys = hash.split('/').filter(function(element, index) { return (index % 2 === 0); });
        values = hash.split('/').filter(function(element, index) { return (index % 2 === 1); });
    }
    else {
        keys = [];
        values = [];
    }

    index_of_key = keys.indexOf(key);

    if (index_of_key > -1) {
        values[index_of_key] = value;
    }
    else {
        keys.push(key);
        values.push(value);
    }

    hash = '/';
    for (var i=0; i < keys.length; i++) {
        if (values[i].length > 0 ) {
            hash += keys[i] + '/' + values[i] + '/';
        }
    }

    $(location).attr('hash', hash);
}

function hash_get_value(key) {
    // Get value for key in hash
    var hash = $(location).attr('hash').substring(2).toLowerCase();
    var keys = hash.split('/').filter(function(element, index) { return (index % 2 === 0); });
    var values = hash.split('/').filter(function(element, index) { return (index % 2 === 1); });
    var index_of_key = keys.indexOf(key);
    if (index_of_key > -1) {
        return values[index_of_key].toLowerCase();
    }

    return;
}

function set_dropdown_value(elm, value) {
    elm.val(value);
    // We have to force trigger 'change' for foundation to update.
    elm.trigger('change');
}

function pad2(number) {
    // Pad numbers
    // snippet from
    // http://www.electrictoolbox.com/pad-number-two-digits-javascript/
    return (number < 10 ? '0' : '') + number;
}

function append_to_formset(event) {
    event.preventDefault();
    var button_obj = $(event.currentTarget);
    var formset_obj = button_obj.closest('.formset');
    var block_obj = formset_obj.find('.copyblock').first();
    var new_block_obj = block_obj.clone();
    var prefix = formset_obj.data('prefix');
    var total_forms_obj = formset_obj.parent().children('#id_' + prefix + '-TOTAL_FORMS');
    var append_after_obj = block_obj;
    if (block_obj.siblings('.copyblock').length > 0) {
        append_after_obj = block_obj.siblings('.copyblock').last();
    }

    function attr_update(selector, attr, prepend){
        new_block_obj.find(selector + prefix + "]").each(function (index, item) {
            var item_obj = $(item);
            var obj_length = total_forms_obj.val().length;
            var prologue_length = 2 + prepend.length + prefix.length + obj_length;
            var item_id = item_obj.attr(attr).substr(prologue_length - obj_length);
            var newid = prepend + prefix + '-' + total_forms_obj.val() + item_id;
            item_obj.attr(attr, newid);
        });
    }
    attr_update('[id*=id_', 'id', 'id_');
    attr_update('[name*=', 'name', '');
{'fraction_non_alphanumeric': 0.17434382061533113, 'fraction_numerical': 0.008169650617069354, 'mean_word_length': 2.651015228426396, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5415154', 'n_tokens_mistral': 1926, 'n_tokens_neox': 1876, 'n_words': 393}