From f3d2ddf4a2a4980092a462e5e3632aecfc4e5eab Mon Sep 17 00:00:00 2001 From: Roman Vishnevskii Date: Fri, 21 Apr 2017 14:36:49 +0700 Subject: [PATCH] Add sample of press enter programmatically --- examples/todoapp/index.html | 71 +++++++++++++++++++++++ examples/todoapp/todoapp.nim | 106 ++--------------------------------- src/karax.nim | 6 +- 3 files changed, 82 insertions(+), 101 deletions(-) create mode 100644 examples/todoapp/index.html 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..