<commit_before>nelliel.ui.hideShowThread = function(element, command) {
    var id = element.getAttribute("data-id");
    var thread_id = id.split('_')[0];
    var post_files = document.getElementById("post-files-container-" + id);
    var post_contents = document.getElementById("post-contents-" + id);
    var thread_container = document.getElementById("thread-expand-" + thread_id);
    
    if (command === "hide-thread") {
        dataBin.hidden_threads[id] = Date.now();
    } else if (command === "show-thread") {    
        delete dataBin.hidden_threads[id];
    }

    if (thread_container !== null) {
        nelliel.ui.toggleHidden(thread_container);
    }
    
    if (post_files !== null) {
        nelliel.ui.toggleHidden(post_files);
    }
    
    if (post_contents !== null) {
        nelliel.ui.toggleHidden(post_contents);
    }

    nelliel.core.storeInLocalStorage(dataBin.hidden_threads_id, dataBin.hidden_threads);
    nelliel.ui.switchDataCommand(element, "hide-thread", "show-thread");
    nelliel.ui.swapContentAttribute(element, "data-alt-visual");
}

nelliel.ui.hideShowPost = function(element, command) {
    var id = element.getAttribute("data-id");
    var post_files = document.getElementById("post-files-container-" + id);
    var post_contents = document.getElementById("post-contents-" + id);
    
    if (command == "hide-post") {
        dataBin.hidden_posts[id] = Date.now();
    } else if (command == "show-post") {
        delete dataBin.hidden_posts[id];
    }
    
    if (post_files !== null) {
        nelliel.ui.toggleHidden(post_files);
    }
    
    if (post_contents !== null) {
        nelliel.ui.toggleHidden(post_contents);
    }
    
    nelliel.core.storeInLocalStorage(dataBin.hidden_posts_id, dataBin.hidden_posts);
    nelliel.ui.switchDataCommand(element, "hide-post", "show-post");
    nelliel.ui.swapContentAttribute(element, "data-alt-visual");
}

nelliel.ui.applyHidePostThread = function() {
    for (var id in dataBin.hidden_threads) {
        var thread_id = id.split('_')[0];
        var post_files = document.getElementById("post-files-container-" + id);
        var post_contents = document.getElementById("post-contents-" + id);
        var thread_container = document.getElementById("thread-expand-" + thread_id);
        var element = document.getElementById("hide-post-thread-" + id);
        
        if (thread_container !== null) {
            nelliel.ui.toggleHidden(thread_container);
        }
        
        if (post_files !== null) {
            nelliel.ui.toggleHidden(post_files);
        }
        
        if (post_contents !== null) {
            nelliel.ui.toggleHidden(post_contents);
        }
        
        nelliel.ui.switchDataCommand(element, "hide-thread", "show-thread");
        nelliel.ui.swapContentAttribute(element, "data-alt-visual");
    }
    
    for (var id in dataBin.hidden_posts) {
        var post_files = document.getElementById("post-files-container-" + id);
        var post_contents = document.getElementById("post-contents-" + id);
        var element = document.getElementById("hide-post-thread-" + id);

        if (post_files !== null) {
            nelliel.ui.toggleHidden(post_files);
        }
        
        if (post_contents !== null) {
            nelliel.ui.toggleHidden(post_contents);
        }
        
        nelliel.ui.switchDataCommand(element, "hide-post", "show-post");
        nelliel.ui.swapContentAttribute(element, "data-alt-visual");
    }
}

nelliel.ui.showHideFileMeta = function(element, command) {
    var full_id = element.getAttribute("data-id");
    var meta_element = document.getElementById("file-meta-" + full_id);
    nelliel.ui.swapContentAttribute(element, "data-alt-visual");
    nelliel.ui.toggleHidden(meta_element);
    nelliel.ui.switchDataCommand(element, "show-file-meta", "hide-file-meta");
}

nelliel.ui.expandCollapseThread = function(thread_id, command, element) {
    var target_element = document.getElementById("thread-expand-" + thread_id);

    if (!target_element) {
        return;
    }

    var url = "threads/" + thread_id + "/" + thread_id + "-" + command.split('-')[0] + ".html";
    var request = new XMLHttpRequest();
    request.open('GET', url);
    request.onload = function() {
        if (request.status === 200) {
            nelliel.ui.swapContentAttribute(element, "data-alt-visual");
            nelliel.ui.switchDataCommand(element, "expand-thread", "collapse-thread");
            target_element.innerHTML = request.responseText;
        }
    };
<commit_msg>And now works on expand/collapse too<commit_after>nelliel.ui.hideShowThread = function(element, command) {
    var id = element.getAttribute("data-id");
    var thread_id = id.split('_')[0];
    var post_files = document.getElementById("post-files-container-" + id);
    var post_contents = document.getElementById("post-contents-" + id);
    var thread_container = document.getElementById("thread-expand-" + thread_id);
    
    if (command === "hide-thread") {
        dataBin.hidden_threads[id] = Date.now();
    } else if (command === "show-thread") {    
        delete dataBin.hidden_threads[id];
    }

    if (thread_container !== null) {
        nelliel.ui.toggleHidden(thread_container);
    }
    
    if (post_files !== null) {
        nelliel.ui.toggleHidden(post_files);
    }
    
    if (post_contents !== null) {
        nelliel.ui.toggleHidden(post_contents);
    }

    nelliel.core.storeInLocalStorage(dataBin.hidden_threads_id, dataBin.hidden_threads);
    nelliel.ui.switchDataCommand(element, "hide-thread", "show-thread");
    nelliel.ui.swapContentAttribute(element, "data-alt-visual");
}

nelliel.ui.hideShowPost = function(element, command) {
    var id = element.getAttribute("data-id");
    var post_files = document.getElementById("post-files-container-" + id);
    var post_contents = document.getElementById("post-contents-" + id);
    
    if (command == "hide-post") {
        dataBin.hidden_posts[id] = Date.now();
    } else if (command == "show-post") {
        delete dataBin.hidden_posts[id];
    }
    
    if (post_files !== null) {
        nelliel.ui.toggleHidden(post_files);
    }
    
    if (post_contents !== null) {
        nelliel.ui.toggleHidden(post_contents);
    }
    
    nelliel.core.storeInLocalStorage(dataBin.hidden_posts_id, dataBin.hidden_posts);
    nelliel.ui.switchDataCommand(element, "hide-post", "show-post");
    nelliel.ui.swapContentAttribute(element, "data-alt-visual");
}

nelliel.ui.applyHidePostThread = function() {
    for (var id in dataBin.hidden_threads) {
        var thread_id = id.split('_')[0];
        var post_files = document.getElementById("post-files-container-" + id);
        var post_contents = document.getElementById("post-contents-" + id);
        var thread_container = document.getElementById("thread-expand-" + thread_id);
        var element = document.getElementById("hide-post-thread-" + id);
        
        if (thread_container !== null) {
            nelliel.ui.toggleHidden(thread_container);
        }
        
        if (post_files !== null) {
            nelliel.ui.toggleHidden(post_files);
        }
        
        if (post_contents !== null) {
            nelliel.ui.toggleHidden(post_contents);
        }
        
        nelliel.ui.switchDataCommand(element, "hide-thread", "show-thread");
        nelliel.ui.swapContentAttribute(element, "data-alt-visual");
    }
    
    for (var id in dataBin.hidden_posts) {
        var post_files = document.getElementById("post-files-container-" + id);
        var post_contents = document.getElementById("post-contents-" + id);
        var element = document.getElementById("hide-post-thread-" + id);

        if (post_files !== null) {
            nelliel.ui.toggleHidden(post_files);
        }
        
        if (post_contents !== null) {
            nelliel.ui.toggleHidden(post_contents);
        }
        
        nelliel.ui.switchDataCommand(element, "hide-post", "show-post");
        nelliel.ui.swapContentAttribute(element, "data-alt-visual");
    }
}

nelliel.ui.showHideFileMeta = function(element, command) {
    var full_id = element.getAttribute("data-id");
    var meta_element = document.getElementById("file-meta-" + full_id);
    nelliel.ui.swapContentAttribute(element, "data-alt-visual");
    nelliel.ui.toggleHidden(meta_element);
    nelliel.ui.switchDataCommand(element, "show-file-meta", "hide-file-meta");
}

nelliel.ui.expandCollapseThread = function(thread_id, command, element) {
    var target_element = document.getElementById("thread-expand-" + thread_id);

    if (!target_element) {
        return;
    }

    var url = "threads/" + thread_id + "/" + thread_id + "-" + command.split('-')[0] + ".html";
    var request = new XMLHttpRequest();
    request.open('GET', url);
    request.onload = function() {
        if (request.status === 200) {
            nelliel.ui.swapContentAttribute(element, "data-alt-visual");
            nelliel.ui.switchDataCommand(element, "expand-thread", "collapse-thread");
            target_element.innerHTML = request.responseText;
            nelliel.ui.applyHidePostThread();
        }
    };

{'fraction_non_alphanumeric': 0.14172026599803772, 'fraction_numerical': 0.0013081870707511174, 'mean_word_length': 2.9104859335038364, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6290627', 'n_tokens_mistral': 2780, 'n_tokens_neox': 2729, 'n_words': 438}