]> git.scottworley.com Git - vopamoi/commitdiff
No MVMVC; DOM *is* the model.
authorScott Worley <scottworley@scottworley.com>
Tue, 25 Jan 2022 19:43:08 +0000 (11:43 -0800)
committerScott Worley <scottworley@scottworley.com>
Thu, 27 Jan 2022 20:20:33 +0000 (12:20 -0800)
vopamoi.ts

index 5967c7d909136eab3975fa042304f96d413105fe..cfa118695c4f82c00b113e605b522710eac07489 100644 (file)
@@ -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) {