Skip to content

Commit

Permalink
historyを削除するボタンを追加 #80
Browse files Browse the repository at this point in the history
  • Loading branch information
jiro4989 committed Jul 10, 2020
1 parent 7cdd82e commit 24bab64
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion websh_front/src/index.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from strutils import split
from strformat import `&`
from unicode import isAlpha, toRunes, runeAt, `==`, `$`
from uri import encodeUrl
from sequtils import mapIt, toSeq, filterIt
from sequtils import mapIt, toSeq, filterIt, delete
import json except `%*`

import karax / [kbase, vdom, kdom, vstyles, karax, karaxdsl, jdict, jstrutils, jjson, kajax, localstorage]
Expand Down Expand Up @@ -86,6 +86,10 @@ proc sendShellButtonOnClick(ev: Event, n: VNode) = # シェルの実行中表示

localStorage.setItem("history", shellHistory.mapIt(cstring(it)).toJson)

proc clearShellHistory(ev: Event, n: VNode) =
shellHistory.delete(0, shellHistory.len)
localStorage.removeItem("history")

proc inputTextareaOnkeydown(ev: Event, n: VNode) =
let kbEvt = cast[KeyboardEvent](ev)
# Ctrl + Enterで実行
Expand Down Expand Up @@ -210,6 +214,9 @@ proc createDom(): VNode =
p(class = "title"):
text "history"
tdiv(class = "content"):
tdiv(class = "buttons"):
button(class="button is-danger", onclick = clearShellHistory):
text "Clear history"
for hist in shellHistory:
tdiv:
text hist
Expand Down

0 comments on commit 24bab64

Please sign in to comment.