<commit_before>var todoList = document.getElementById("todo-list");
var todoListPlaceholder = document.getElementById("todo-list-placeholder");
var form = document.getElementById("todo-form");
var todoTitle = document.getElementById("new-todo");
var error = document.getElementById("error");
var leftToDo = document.getElementById("count-label");
var viewAllButton = document.getElementById("view-all-button");
var viewActiveButton = document.getElementById("view-active-button");
var viewCompleteButton = document.getElementById("view-complete-button");
var viewSpinnerButton = document.getElementById("view-spinner-button");
var deleteAllDoneButton = document.getElementById("delete-all-done-button");

form.onsubmit = function(event) {
    var title = todoTitle.value;
    createTodo(title, function() {
        reloadTodoList();
    });
    todoTitle.value = "";
    event.preventDefault();
};

viewAllButton.onclick = setFilters();
viewActiveButton.onclick = setFilters({isCompleted: false});
viewCompleteButton.onclick = setFilters({isCompleted: true});

viewSpinnerButton.onclick = function() {
    if(todoListPlaceholder.getAttribute("data-override") !== "true") {
        todoListPlaceholder.style.display = "block";
        todoListPlaceholder.setAttribute("data-override", "true");
        viewSpinnerButton.innerHTML = "Hide OneDiv&trade; Spinner";
    } else {
        todoListPlaceholder.style.display = "none";
        viewSpinnerButton.innerHTML = "Show OneDiv&trade; Spinner";
        todoListPlaceholder.setAttribute("data-override", "false");
    }
};

function createTodo(title, callback) {
    fetch("/api/todo", {
        method: "post",
        headers: {
            "Content-type": "application/json"
        },
        body: JSON.stringify({title: title})
    }).then(function (response) {
        if (response.status === 201) {
            callback();
        } else {
            error.textContent = "Failed to create item. Server returned " + response.status + " - " +
                response.statusText;
        }
    });
}

function getTodoList(callback) {
    fetch("/api/todo").then(function(response) {
        if (response.status === 200) {

            response.json().then(function(data) {
                callback(data);
            });
        } else {
            error.textContent = "Failed to get list. Server returned " + response.status + " - " +
                response.statusText;
        }
    });
}

function deleteToDoEvent(event) {
    if (event && event.target) {
        var id = event.target.getAttribute("data-id");
        if (id) {
            deleteToDo(id, reloadTodoList);
        }
    }
}

function deleteToDo(id, callback) {
    fetch("/api/todo/" + id, {
        method: "DELETE"
    }).then(function(response) {
        if (response.status === 200) {
            if (callback) {
                callback();
            }
        } else {
            error.textContent = "Failed to delete. Server returned " + response.status + " - " +
                response.statusText;
        }
    });
}

function markDone(event) {
    if (event && event.target) {
        var id = event.target.getAttribute("data-id");
        if (id) {

            fetch("/api/todo", {
                method: "PUT",
                headers: {
                    "Content-type": "application/json"
                },
                body: JSON.stringify({
                    isCompleted: true,
                    id: id
                })
            }).then(function(response) {
                if (response.status === 200) {
                    reloadTodoList();
                } else {
                    error.textContent = "Failed to mark done. " +
                        "Server returned " + response.status + " - " + response.statusText;
                }
            });
        }
    }
}

function clearDone(data) {
    return function() {
        data.forEach(function(todo) {
            if (todo.isCompleted) {
                deleteToDo(todo.id);
            }
        });
        reloadTodoList();
    };
}

function reloadTodoList(filters, callback) {
    while (todoList.firstChild) {
        todoList.removeChild(todoList.firstChild);
    }
    deleteAllDoneButton.style.display = "none";
    todoListPlaceholder.style.display = "block";
    getTodoList(function(todos) {
        if(todoListPlaceholder.getAttribute("data-override") !== "true") {
            todoListPlaceholder.style.display = "none";
        }
        var itemsLeftToDo = 0;
        var itemsDone = 0;

        todos.forEach(function(todo) {
            var displayItem = true;
            var listItem;
            var deleteButton;
            if (filters) {
                var keys = Object.keys(filters);
                keys.forEach(function(key) {
                    if (filters[key] !== todo[key]) {
                        displayItem = false;
                    }
                });
            }

            if (displayItem) {
                listItem = document.createElement("div");
                var innerListItem = document.createElement("div");
                innerListItem.textContent = todo.title;
                listItem.appendChild(innerListItem);
                listItem.className = "todo-item";
                if (todo.isCompleted) {
                    listItem.className = "todo-done";
                }

                deleteButton = document.createElement("button");
                deleteButton.className = "delete-button";
                deleteButton.textContent = "Delete";<commit_msg>Fixed lint issues.<commit_after>var todoList = document.getElementById("todo-list");
var todoListPlaceholder = document.getElementById("todo-list-placeholder");
var form = document.getElementById("todo-form");
var todoTitle = document.getElementById("new-todo");
var error = document.getElementById("error");
var leftToDo = document.getElementById("count-label");
var viewAllButton = document.getElementById("view-all-button");
var viewActiveButton = document.getElementById("view-active-button");
var viewCompleteButton = document.getElementById("view-complete-button");
var viewSpinnerButton = document.getElementById("view-spinner-button");
var deleteAllDoneButton = document.getElementById("delete-all-done-button");

form.onsubmit = function(event) {
    var title = todoTitle.value;
    createTodo(title, function() {
        reloadTodoList();
    });
    todoTitle.value = "";
    event.preventDefault();
};

viewAllButton.onclick = setFilters();
viewActiveButton.onclick = setFilters({isCompleted: false});
viewCompleteButton.onclick = setFilters({isCompleted: true});

viewSpinnerButton.onclick = function() {
    if (todoListPlaceholder.getAttribute("data-override") !== "true") {
        todoListPlaceholder.style.display = "block";
        todoListPlaceholder.setAttribute("data-override", "true");
        viewSpinnerButton.innerHTML = "Hide OneDiv&trade; Spinner";
    } else {
        todoListPlaceholder.style.display = "none";
        viewSpinnerButton.innerHTML = "Show OneDiv&trade; Spinner";
        todoListPlaceholder.setAttribute("data-override", "false");
    }
};

function createTodo(title, callback) {
    fetch("/api/todo", {
        method: "post",
        headers: {
            "Content-type": "application/json"
        },
        body: JSON.stringify({title: title})
    }).then(function (response) {
        if (response.status === 201) {
            callback();
        } else {
            error.textContent = "Failed to create item. Server returned " + response.status + " - " +
                response.statusText;
        }
    });
}

function getTodoList(callback) {
    fetch("/api/todo").then(function(response) {
        if (response.status === 200) {

            response.json().then(function(data) {
                callback(data);
            });
        } else {
            error.textContent = "Failed to get list. Server returned " + response.status + " - " +
                response.statusText;
        }
    });
}

function deleteToDoEvent(event) {
    if (event && event.target) {
        var id = event.target.getAttribute("data-id");
        if (id) {
            deleteToDo(id, reloadTodoList);
        }
    }
}

function deleteToDo(id, callback) {
    fetch("/api/todo/" + id, {
        method: "DELETE"
    }).then(function(response) {
        if (response.status === 200) {
            if (callback) {
                callback();
            }
        } else {
            error.textContent = "Failed to delete. Server returned " + response.status + " - " +
                response.statusText;
        }
    });
}

function markDone(event) {
    if (event && event.target) {
        var id = event.target.getAttribute("data-id");
        if (id) {

            fetch("/api/todo", {
                method: "PUT",
                headers: {
                    "Content-type": "application/json"
                },
                body: JSON.stringify({
                    isCompleted: true,
                    id: id
                })
            }).then(function(response) {
                if (response.status === 200) {
                    reloadTodoList();
                } else {
                    error.textContent = "Failed to mark done. " +
                        "Server returned " + response.status + " - " + response.statusText;
                }
            });
        }
    }
}

function clearDone(data) {
    return function() {
        data.forEach(function(todo) {
            if (todo.isCompleted) {
                deleteToDo(todo.id);
            }
        });
        reloadTodoList();
    };
}

function reloadTodoList(filters, callback) {
    while (todoList.firstChild) {
        todoList.removeChild(todoList.firstChild);
    }
    deleteAllDoneButton.style.display = "none";
    todoListPlaceholder.style.display = "block";
    getTodoList(function(todos) {
        if (todoListPlaceholder.getAttribute("data-override") !== "true") {
            todoListPlaceholder.style.display = "none";
        }
        var itemsLeftToDo = 0;
        var itemsDone = 0;

        todos.forEach(function(todo) {
            var displayItem = true;
            var listItem;
            var deleteButton;
            if (filters) {
                var keys = Object.keys(filters);
                keys.forEach(function(key) {
                    if (filters[key] !== todo[key]) {
                        displayItem = false;
                    }
                });
            }

            if (displayItem) {
                listItem = document.createElement("div");
                var innerListItem = document.createElement("div");
                innerListItem.textContent = todo.title;
                listItem.appendChild(innerListItem);
                listItem.className = "todo-item";
                if (todo.isCompleted) {
                    listItem.className = "todo-done";
                }

                deleteButton = document.createElement("button");
                deleteButton.className = "delete-button";
                deleteButton.textContent = "Delete";
{'fraction_non_alphanumeric': 0.12757349635889598, 'fraction_numerical': 0.0025173064820641915, 'mean_word_length': 1.9537971322357939, 'pattern_counts': {'":': 4, '<': 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': '55723', 'n_tokens_mistral': 3022, 'n_tokens_neox': 2935, 'n_words': 525}