<commit_before>$.getJSON('/courts', function (allData) {
    var data = [].concat(allData.meilahti, allData.herttoniemi)
    var sameDates = groupBySortedAsList(data, 'date')

    $('.schedule').html(sameDates.map(function (dateObject) {
        var isoDate = dateObject.key
        var times = dateObject.val
        return '<h4>' + new Date(isoDate).toDateString() + '</h4>' +
        groupBySortedAsList(times, 'time').map(function (timeObject) {
            var isoTime = timeObject.key
            var fields = timeObject.val
            return '<p><span class="time">' + isoTime + '</span>' +
            groupBySortedAsList(fields, 'location').map(function(locationFields) {
                var location = locationFields.key
                var fields = locationFields.val
                return '<span class="locationBoxes"><button type="button" class="locationLabel btn btn-' +
                    (location === 'meilahti' ? 'primary' : 'success') +
                    ' btn-xs">' + location + ' (' + fields.length +')</button>' +
                fields.map(function (field) {
                    return '<button type="button" class="fieldLabel btn btn-' +
                        (field.location === 'meilahti' ? 'primary' : 'success') +
                        ' btn-xs">' + field.field + '</button>'
                }).join('')+'</span>'
            }).join('') + '</p>'
        }).join('')
    }).join(''))
})

$('.schedule').on('click', '.locationLabel', function(e) {
    console.log('click')
    var $locationLabel = $(e.currentTarget)
    $locationLabel.slideToggle()
    $locationLabel.parent().find('.fieldLabel').slideToggle()
})

function groupBySortedAsList(list, key) { return _.sortBy(_.map(_.groupBy(list, key), objectToArray), 'key')}

function objectToArray(val, key) { return { key: key, val:val}}<commit_msg>Replace slideToggle with toggle<commit_after>$.getJSON('/courts', function (allData) {
    var data = [].concat(allData.meilahti, allData.herttoniemi)
    var sameDates = groupBySortedAsList(data, 'date')

    $('.schedule').html(sameDates.map(function (dateObject) {
        var isoDate = dateObject.key
        var times = dateObject.val
        return '<h4>' + new Date(isoDate).toDateString() + '</h4>' +
        groupBySortedAsList(times, 'time').map(function (timeObject) {
            var isoTime = timeObject.key
            var fields = timeObject.val
            return '<p><span class="time">' + isoTime + '</span>' +
            groupBySortedAsList(fields, 'location').map(function(locationFields) {
                var location = locationFields.key
                var fields = locationFields.val
                return '<span class="locationBoxes"><button type="button" class="locationLabel btn btn-' +
                    (location === 'meilahti' ? 'primary' : 'success') +
                    ' btn-xs">' + location + ' (' + fields.length +')</button>' +
                fields.map(function (field) {
                    return '<button type="button" class="fieldLabel btn btn-' +
                        (field.location === 'meilahti' ? 'primary' : 'success') +
                        ' btn-xs">' + field.field + '</button>'
                }).join('')+'</span>'
            }).join('') + '</p>'
        }).join('')
    }).join(''))
})

$('.schedule').on('click', '.locationLabel', function(e) {
    console.log('click')
    var $locationLabel = $(e.currentTarget)
    $locationLabel.toggle()
    $locationLabel.parent().find('.fieldLabel').toggle()
})

function groupBySortedAsList(list, key) { return _.sortBy(_.map(_.groupBy(list, key), objectToArray), 'key')}

function objectToArray(val, key) { return { key: key, val:val}}
{'fraction_non_alphanumeric': 0.1731813246471227, 'fraction_numerical': 0.0010857763300760044, 'mean_word_length': 2.5095238095238095, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '3549199', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1048, 'n_words': 212}