From: Scott Worley Date: Tue, 25 Jan 2022 19:43:08 +0000 (-0800) Subject: No MVMVC; DOM *is* the model. X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/9e79bdbb90ffcb5929f76a4fb6860ed6396ac9de?hp=28568279f452686693f5e92182ce83651afbc174 No MVMVC; DOM *is* the model. --- diff --git a/vopamoi.ts b/vopamoi.ts index 5967c7d..cfa1186 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -1,19 +1,12 @@ -var tasks: string[] = []; - -function createViewTask(task: string) { - const viewTask = document.createElement("div"); - viewTask.appendChild(document.createTextNode(task)); - viewTask.setAttribute("tabindex", "0"); - return viewTask; -} - -function updateView() { - tasks.forEach((t) => document.getElementById(t) || document.body.appendChild(createViewTask(t))); +function createTask(description: string) { + const task = document.createElement("div"); + task.appendChild(document.createTextNode(description)); + task.setAttribute("tabindex", "0"); + return task; } -function addTask(task: string) { - tasks.push(task); - updateView(); +function addTask(description: string) { + document.body.appendChild(createTask(description)); } function browserCreateTask(form: any) {