diff --git a/examples/todoapp/index.html b/examples/todoapp/index.html new file mode 100644 index 0000000..f9fae08 --- /dev/null +++ b/examples/todoapp/index.html @@ -0,0 +1,71 @@ + + + + + Todo app + + + + + +
+ + + + + + + diff --git a/examples/todoapp/todoapp.nim b/examples/todoapp/todoapp.nim index 9027603..7f25712 100644 --- a/examples/todoapp/todoapp.nim +++ b/examples/todoapp/todoapp.nim @@ -1,113 +1,19 @@ import vdom, karax, karaxdsl, jstrutils -type - Filter = enum - all, active, completed - -var - entries: seq[(cstring, bool)] - selectedEntry = -1 - filter: Filter - proc onTodoEnter(ev: Event; n: VNode) = - entries.add((n.value, false)) - n.value = "" + kout cstring"ENTER" -proc removeHandler(ev: Event; n: VNode) = - entries[n.key] = (cstring(nil), false) - -proc editHandler(ev: Event; n: VNode) = - selectedEntry = n.key - -proc focusLost(ev: Event; n: VNode) = selectedEntry = -1 - -proc editEntry(ev: Event; n: VNode) = - entries[n.key][0] = n.value - selectedEntry = -1 - -proc toggleEntry(ev: Event; n: VNode) = - let id = n.key - entries[id][1] = not entries[id][1] - -proc onAllDone(ev: Event; n: VNode) = - entries = @[] - selectedEntry = -1 - -proc clearCompleted(ev: Event, n: VNode) = - for i in 0..