Skip to content

Instantly share code, notes, and snippets.

@josher19
Created April 20, 2012 07:30
Show Gist options
  • Save josher19/2426844 to your computer and use it in GitHub Desktop.
Save josher19/2426844 to your computer and use it in GitHub Desktop.
Run LiveScript Code
<!DOCTYPE html>
<html>
<head>
<title>Run LiveScript Code</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.2/jquery.min.js" ></script>
<script src="https://raw.github.com/gkz/LiveScript/master/extras/livescript.js" async=true ></script>
</head>
<body>
<form>
<textarea rows=10 cols=80 name=inp id=inp >
</textarea>
<textarea rows=10 cols=80 name=outp id=outp >
</textarea>
<br />
<input type=button id=run value="Run" />
<input type=checkbox id=warn name=warn title="Warn" />
<div id="warnings" class="warn"></div>
</form>
<script type="text/javascript">
if (typeof console == "object") console.log("javascript");
jQuery(function($) {
function build() {
$('#outp').val(LiveScript.compile( $('#inp').val()))
}
function runit() {
$('#tabular').val( eval($('#outp').val() ))
}
$('#inp').change(build);
$('#run').click(runit);
});
</script>
<script type="text/LiveScript">
console.log "livescript" if console?
build = ->
$('#outp').val LiveScript.compile $('#inp').val()
runit = ->
$('#tabular').val eval $('#outp').val()
# $('#inp').change build
# $('#run').click runit
$('#warn').unbind("change")
warnerror = (a,b,c,d) ->
console?.info arguments
$('#warnings').html [a,b,c,d].join("<br />")
$('#warn').change ->
clicked = this.checked
console?.log clicked
$('#warnings').text ''
window.onerror = if clicked then warnerror else null
true
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment