summary refs log blame commit diff stats
path: root/tests/js.nim
blob: 92cb130bdce9fb2ad0eddc020390020b88cd6ac9 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
           
                                         

   
                                          






                                                                 
                                                                         

                                  





                                 
 
                           
                                                                 
discard """
  cmd: "nim js --hints:on $options $file"
"""

# 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!"