From 9714e472ba70c76bf3723e2609d493f3b388df78 Mon Sep 17 00:00:00 2001 From: Jason Kridner Date: Fri, 2 Aug 2013 10:10:20 -0500 Subject: [PATCH] bonescript-demo.js: add shellRun function --- static/bonescript-demo.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/static/bonescript-demo.js b/static/bonescript-demo.js index 003cecfff..f3a582f4f 100644 --- a/static/bonescript-demo.js +++ b/static/bonescript-demo.js @@ -95,6 +95,15 @@ function initClient() { originalDemoRun(myid); } } + var originalShellRun = shellRun; + shellRun = function(myid) { + if(typeof editor[myid].editor != 'undefined') { + var code = editor[myid].editor.getValue(); + myShell(code); + } else { + originalShellRun(myid); + } + } } } @@ -114,11 +123,15 @@ function onShell(x) { console.log(x); } -function shellRun(id) { - var myScript = document.getElementById(id).innerHTML; +function myShell(code) { var b = require('bonescript'); b.socket.on('shell', onShell); - b.socket.emit('shell', myScript); + b.socket.emit('shell', code); +} + +function shellRun(id) { + var myScript = document.getElementById(id).innerHTML; + myShell(myScript); } function demoRestore(id) { -- 2.11.4.GIT