<reponame>dhsdshdhk/tchan
function filterThreads(){
    let threads = document.getElementsByClassName('catalogCell');
    for(let t of threads){
        let message = t.getElementsByClassName('divMessage')[0].innerText;
        if(message.includes(this.value)){
            t.style.display = 'inline-block';
        }
        else{
            t.style.display = 'none';
        }
    }

}


document.addEventListener("DOMContentLoaded", function (event) {
    let threadFilter = document.createElement('div');
    threadFilter.setAttribute('class', 'divCatalogTools');
    let input = document.createElement('input');
    input.setAttribute('id', 'catalogSearchField');
    input.setAttribute('placeholder', 'Search...');
    input.addEventListener('input', filterThreads);
    threadFilter.append(input);
    let catalog = document.getElementsByClassName('catalogDiv')[0];
    catalog.prepend(threadFilter);
});