parent
0f2aa053d9
commit
1785c6877b
25 changed files with 127 additions and 126 deletions
24
tests/js.nim
Executable file
24
tests/js.nim
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
discard """
|
||||
cmd: "nimrod js --hints:on $# $#"
|
||||
"""
|
||||
|
||||
# This file tests the JavaScript generator
|
||||
|
||||
import
|
||||
dom, strutils
|
||||
|
||||
# We need to declare the used elements here. This is annoying but
|
||||
# prevents any kind of typo:
|
||||
var
|
||||
inputElement {.importc: "document.form1.input1", nodecl.}: ref TElement
|
||||
|
||||
proc OnButtonClick() {.exportc.} =
|
||||
let v = $inputElement.value
|
||||
if v.allCharsInSet(whiteSpace):
|
||||
echo "only whitespace, hu?"
|
||||
else:
|
||||
var x = parseInt(v)
|
||||
echo x*x
|
||||
|
||||
proc OnLoad() {.exportc.} =
|
||||
echo "Welcome! Please take your time to fill in this formular!"
|
||||
Loading…
Add table
Add a link
Reference in a new issue