Skip to content

Latest commit

 

History

History
21 lines (13 loc) · 519 Bytes

interactive_runtime.coffee.md

File metadata and controls

21 lines (13 loc) · 519 Bytes

Interactive Runtime

window.Point = require("./point")

Register our example runner.

Interactive.register "example", ({source, runtimeElement}) ->
  program = CoffeeScript.compile(source, bare: true)

  outputElement = document.createElement "pre"
  runtimeElement.empty().append outputElement

  result = eval(program)

  if typeof result is "number"
    if result != (0 | result)
      result = result.toFixed(4)


  outputElement.textContent = result