<commit_before>require(['bootstrap', 'jquery'], function() {
    const editButtons = document.querySelectorAll(".submission-edit");
    const editor = document.querySelector("#editor form");
    const channelField = editor.querySelector("#channel");
    const typeField = editor.querySelector("#type");
    const idField = editor.querySelector('input[name="id"]');

    let currentRow;
    const updateEditor = (e) => {
        currentRow = e.target.parentNode.parentNode;
        channelField.value = currentRow.cells[2].textContent;
        typeField.value = currentRow.cells[1].textContent;
        idField.value = currentRow.querySelector('input[name="id"]').value;
        document.querySelector('#editor .channel-name').textContent = currentRow.cells[0].textContent;
    };
    const save = (e) => {
        e.preventDefault();

        const body = new FormData(editor);

        fetch('/lib/subedit', {
            method: 'POST',
            body,
            credentials: 'same-origin'
        }).then((r) => {
            if(!r.ok) {
                throw r.status;
            }
            else {
                currentRow.cells[2].textContent = channelField.value;
                currentRow.cells[1].textContent = typeField.value;
                $('#editor').modal('hide');
            }
        }).catch(console.error);
    };

    editor.addEventListener("submit", save, false);
    for(const button of editButtons) {
        button.addEventListener("click", updateEditor, false);
    }
});<commit_msg>Better cell update<commit_after>require(['bootstrap', 'jquery'], function() {
    const editButtons = document.querySelectorAll(".submission-edit");
    const editor = document.querySelector("#editor form");
    const channelField = editor.querySelector("#channel");
    const typeField = editor.querySelector("#type");
    const idField = editor.querySelector('input[name="id"]');

    let currentRow;
    const updateEditor = (e) => {
        currentRow = e.target.parentNode.parentNode;
        channelField.value = currentRow.cells[2].textContent;
        typeField.value = currentRow.cells[1].textContent;
        idField.value = currentRow.querySelector('input[name="id"]').value;
        document.querySelector('#editor .channel-name').textContent = currentRow.cells[0].textContent;
    };
    const save = (e) => {
        e.preventDefault();

        const body = new FormData(editor);

        fetch('/lib/subedit', {
            method: 'POST',
            body,
            credentials: 'same-origin'
        }).then((r) => {
            if(!r.ok) {
                throw r.status;
            }
            else {
                if(channelField.value != currentRow.cells[2].textContent) {
                    currentRow.cells[2].innerHTML = "";
                    if(channelField.value.length) {
                        const link = document.createElement("a");
                        link.href = `https://twitch.tv/${channelField.value}`;
                        link.textContent = channelField.value;
                        currentRow.cells[2].appendChild(link);
                    }
                    else {
                        const icon = document.createElement("span");
                        icon.classList.add("glyphicon");
                        icon.classList.add("glyphicon-question-sign");
                        icon.classList.add("status-unknown");
                        icon.title = "No data";
                        currentRow.cells[2].appendChild(icon);
                    }

                }
                if(typeField.value != currentRow.cells[1].textContent) {
                    if(isNaN(typeField.value)) {
                        currentRow.cells[1].textContent = typeField.value;
                    }
                    else {
                        const link = document.createElement("a");
                        link.href = `/types/${typeField.value}`;
                        link.textContent = typeField.value;
                        currentRow.cells[1].innerHTML = "";
                        currentRow.cells[1].appendChild(link);
                    }
                }
                $('#editor').modal('hide');
            }
        }).catch(console.error);
    };

    editor.addEventListener("submit", save, false);
    for(const button of editButtons) {
        button.addEventListener("click", updateEditor, false);
    }
});
{'fraction_non_alphanumeric': 0.13559322033898305, 'fraction_numerical': 0.003615819209039548, 'mean_word_length': 1.8119440914866582, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 1, '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': '4469678', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1091, 'n_words': 176}