Codestyle fixes
This commit is contained in:
parent
3238422412
commit
459d696128
1 changed files with 23 additions and 23 deletions
|
|
@ -8,36 +8,36 @@ type
|
||||||
var
|
var
|
||||||
selectedEntry = -1
|
selectedEntry = -1
|
||||||
filter: Filter
|
filter: Filter
|
||||||
entriesSize: int
|
entriesLen: int
|
||||||
|
|
||||||
proc getItem(key : cstring ): cstring {.importc: "localStorage.getItem"}
|
proc getItem(key : cstring ): cstring {.importc: "localStorage.getItem"}
|
||||||
proc setItem(key, value : cstring ) {.importc: "localStorage.setItem"}
|
proc setItem(key, value : cstring ) {.importc: "localStorage.setItem"}
|
||||||
proc clearEntries() {.importc: "localStorage.clear"}
|
proc clearEntries() {.importc: "localStorage.clear"}
|
||||||
|
|
||||||
proc getEntryCstring(pos : int): cstring =
|
proc getEntryCstring(pos: int): cstring =
|
||||||
result = getItem(cstring($pos & "cstring"))
|
result = getItem(cstring($pos & "cstring"))
|
||||||
if result == cstring"null":
|
if result == cstring"null":
|
||||||
result = nil
|
result = nil
|
||||||
|
|
||||||
proc getEntryBool(pos : int): bool =
|
proc getEntryBool(pos: int): bool =
|
||||||
var value = getItem(cstring($pos & "bool"))
|
var value = getItem(cstring($pos & "bool"))
|
||||||
result = value == cstring"true"
|
result = value == cstring"true"
|
||||||
|
|
||||||
proc setEntryCstring(pos : int, value : cstring) =
|
proc setEntryCstring(pos: int, value: cstring) =
|
||||||
setItem(cstring($pos & "cstring"), value)
|
setItem(cstring($pos & "cstring"), value)
|
||||||
|
|
||||||
proc setEntryBool(pos : int, value : bool) =
|
proc setEntryBool(pos: int, value : bool) =
|
||||||
var val = cstring"true"
|
var val = cstring"true"
|
||||||
if not value:
|
if not value:
|
||||||
val = cstring"false"
|
val = cstring"false"
|
||||||
setItem(cstring($pos & "bool"), val)
|
setItem(cstring($pos & "bool"), val)
|
||||||
|
|
||||||
proc addEntry(str : cstring, bval : bool) =
|
proc addEntry(str: cstring, bval : bool) =
|
||||||
setEntryCstring(entriesSize, str)
|
setEntryCstring(entriesLen, str)
|
||||||
setEntryBool(entriesSize, bval)
|
setEntryBool(entriesLen, bval)
|
||||||
inc entriesSize
|
inc entriesLen
|
||||||
|
|
||||||
proc setEntry(pos : int, str : cstring, bval : bool) =
|
proc setEntry(pos: int, str: cstring, bval: bool) =
|
||||||
setEntryCstring(pos, str)
|
setEntryCstring(pos, str)
|
||||||
setEntryBool(pos, bval)
|
setEntryBool(pos, bval)
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ proc onAllDone(ev: Event; n: VNode) =
|
||||||
selectedEntry = -1
|
selectedEntry = -1
|
||||||
|
|
||||||
proc clearCompleted(ev: Event, n: VNode) =
|
proc clearCompleted(ev: Event, n: VNode) =
|
||||||
for i in 0..<entriesSize:
|
for i in 0..<entriesLen:
|
||||||
if getEntryBool(i): setEntryCstring(i, nil)
|
if getEntryBool(i): setEntryCstring(i, nil)
|
||||||
|
|
||||||
proc toClass(completed: bool): cstring =
|
proc toClass(completed: bool): cstring =
|
||||||
|
|
@ -131,7 +131,7 @@ proc createDom(): VNode =
|
||||||
var completedCount = 0
|
var completedCount = 0
|
||||||
ul(class = "todo-list"):
|
ul(class = "todo-list"):
|
||||||
#for i, d in pairs(entries):
|
#for i, d in pairs(entries):
|
||||||
for i in 0..entriesSize-1:
|
for i in 0..entriesLen-1:
|
||||||
|
|
||||||
var d0 = getEntryCstring(i)
|
var d0 = getEntryCstring(i)
|
||||||
var d1 = getEntryBool(i)
|
var d1 = getEntryBool(i)
|
||||||
|
|
@ -151,5 +151,5 @@ setOnHashChange(proc(hash: cstring) =
|
||||||
elif hash == "#/completed": filter = completed
|
elif hash == "#/completed": filter = completed
|
||||||
elif hash == "#/active": filter = active
|
elif hash == "#/active": filter = active
|
||||||
)
|
)
|
||||||
entriesSize = 0
|
entriesLen = 0
|
||||||
setRenderer createDom
|
setRenderer createDom
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue