function renderTodo()

in src/frontend/www/js/main.js [102:138]


function renderTodo(todo){
    let div = document.createElement("div");
    div.classList.add("todo");
    if (todo.complete){
        div.classList.add("complete");
    }

    let input = document.createElement("input");
    input.type = "checkbox";
    input.id = `todo-${todo.id}-cb`;
    input.checked = todo.complete;
    input.addEventListener("change", checkHandler);

    let editor = document.createElement("span");
    editor.classList.add("editor");
    editor.contentEditable = true;
    editor.innerHTML = todo.title;
    editor.id = `todo-${todo.id}`;
    editor.addEventListener("blur", blurHandler);

    let icon = document.createElement("span");
    icon.classList.add("material-icons", "delete");
    icon.innerHTML = "delete";
    icon.id = `todo-${todo.id}-delete`;
    icon.addEventListener("click", deleteHandler);

    let h1 = document.createElement("h1");
    h1.appendChild(input);
    h1.appendChild(editor);
    h1.appendChild(icon);

    div.appendChild(h1);


    return div;

}