<commit_before>((box) ->
    link = box.querySelector('a')
    input = box.querySelector('input')
    progress = box.querySelector('.upload-progress')

    if box.dataset.file?
        input = document.getElementById(box.dataset.file)

    link.addEventListener('click', (e) ->
        e.preventDefault()
        input.click()
    , false)

    input.addEventListener('change', (e) ->
        progress.style.width = 0
        progress.classList.remove('fade-out')
        eval(box.dataset.event + '(input.files, box)')
    , false)

    progress.addEventListener('animationend', (e) ->
        progress.style.width = 0
        progress.classList.remove('fade-out')
    , false)
)(box) for box in document.querySelectorAll('.upload-well')

link.addEventListener('click', (e) ->
    e.preventDefault()
    xhr = new XMLHttpRequest()
    if e.target.classList.contains('follow-button')
        xhr.open('POST', "/mod/#{e.target.dataset.mod}/follow")
        e.target.classList.remove('follow-button')
        e.target.classList.add('unfollow-button')
        e.target.textContent = 'Unfollow'
        try
            document.getElementById('alert-follow').classList.remove('hidden')
    else
        xhr.open('POST', "/mod/#{e.target.dataset.mod}/unfollow")
        e.target.classList.remove('unfollow-button')
        e.target.classList.add('follow-button')
        e.target.textContent = 'Follow'
    xhr.send()
, false) for link in document.querySelectorAll('.follow-button, .unfollow-button')

link.addEventListener('click', (e) ->
    e.preventDefault()
    xhr = new XMLHttpRequest()
    if e.target.classList.contains('feature-button')
        xhr.open('POST', "/mod/#{e.target.dataset.mod}/feature")
        e.target.classList.remove('feature-button')
        e.target.classList.add('unfeature-button')
        e.target.textContent = 'Unfeature'
    else
        xhr.open('POST', "/mod/#{e.target.dataset.mod}/unfeature")
        e.target.classList.remove('unfeature-button')
        e.target.classList.add('feature-button')
        e.target.textContent = 'Feature'
    xhr.send()
, false) for link in document.querySelectorAll('.feature-button, .unfeature-button')
<commit_msg>Fix follow button on mod listings<commit_after>((box) ->
    link = box.querySelector('a')
    input = box.querySelector('input')
    progress = box.querySelector('.upload-progress')

    if box.dataset.file?
        input = document.getElementById(box.dataset.file)

    link.addEventListener('click', (e) ->
        e.preventDefault()
        input.click()
    , false)

    input.addEventListener('change', (e) ->
        progress.style.width = 0
        progress.classList.remove('fade-out')
        eval(box.dataset.event + '(input.files, box)')
    , false)

    progress.addEventListener('animationend', (e) ->
        progress.style.width = 0
        progress.classList.remove('fade-out')
    , false)
)(box) for box in document.querySelectorAll('.upload-well')

link.addEventListener('click', (e) ->
    e.preventDefault()
    xhr = new XMLHttpRequest()
    follow = false
    if e.target.classList.contains('follow-button')
        xhr.open('POST', "/mod/#{e.target.dataset.mod}/follow")
        e.target.classList.remove('follow-button')
        e.target.classList.add('unfollow-button')
        e.target.textContent = 'Unfollow'
        follow = true
    else
        xhr.open('POST', "/mod/#{e.target.dataset.mod}/unfollow")
        e.target.classList.remove('unfollow-button')
        e.target.classList.add('follow-button')
        e.target.textContent = 'Follow'
    xhr.onload = () ->
        try
            JSON.parse(this.responseText)
            document.getElementById('alert-follow').classList.remove('hidden') if follow
        catch
            window.location.href = '/register'
    xhr.send()
, false) for link in document.querySelectorAll('.follow-button, .unfollow-button')

link.addEventListener('click', (e) ->
    e.preventDefault()
    xhr = new XMLHttpRequest()
    if e.target.classList.contains('feature-button')
        xhr.open('POST', "/mod/#{e.target.dataset.mod}/feature")
        e.target.classList.remove('feature-button')
        e.target.classList.add('unfeature-button')
        e.target.textContent = 'Unfeature'
    else
        xhr.open('POST', "/mod/#{e.target.dataset.mod}/unfeature")
        e.target.classList.remove('unfeature-button')
        e.target.classList.add('feature-button')
        e.target.textContent = 'Feature'
    xhr.send()
, false) for link in document.querySelectorAll('.feature-button, .unfeature-button')

{'fraction_non_alphanumeric': 0.16035049288061337, 'fraction_numerical': 0.0008762322015334064, 'mean_word_length': 2.88265306122449, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '1511067', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1372, 'n_words': 204}