Comments (4)
I've make a working 'Run in code demo' example in
http://www.gasolin.idv.tw/public/blockly/demos/code/index.html
all you need is:
1. add a link in demo page
<a href="javascript: return false;" onclick="javascript:runJS()">Run in
Javascript</a>
2. add a runJS() function below the init(blockly) function
function runJS() {
console.log("run");
tabClick("tab_javascript");
var x=document.getElementById('content_javascript');
console.log(x.innerHTML);
eval(x.innerHTML);
}
click the link will be switched to javascript tab and run the script.
Original comment by gasolin
on 7 Jun 2012 at 5:34
from blockly.
a modified version will just run the code without switch to JS tab
function runJS() {
eval(Blockly.Generator.workspaceToCode('JavaScript'))
}
Original comment by gasolin
on 9 Jun 2012 at 5:57
from blockly.
Good idea, and one that gets mentioned a lot by visitors. I've pushed revision
225 which adds a run button and does basic error trapping.
However, unlike the more limited and more complicated execution in the maze
demo, it does not detect infinite loops and it does not highlight the executed
blocks. Doing so would result in unreadable JS code filled with callbacks and
serial numbers.
Original comment by [email protected]
on 9 Jun 2012 at 7:40
- Changed state: Fixed
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
from blockly.
Have you looked at doing the same thing for playground.html?
Original comment by [email protected]
on 17 Sep 2013 at 8:29
from blockly.
Related Issues (20)
- When using blockly maze and puzzle etc the drop down arrows on the blocks don't operate on an iPad. HOT 1
- Number of app's lang-manu HOT 2
- turtle trail does not show on Android Nexus 10
- Blockly.Xml.workspaceToDom doesn´t work on Safari HOT 2
- context menu on tablets HOT 1
- Non Printing Text Characters
- [deleted issue]
- [deleted issue]
- Color dropdowns not listening for touch events HOT 1
- Trashcan Lid animation uses CPU when idle HOT 1
- Uncollapsing duplicated block "Connection already in database" error HOT 2
- Code blocks can become misaligned when moving a set of blocks with a "break out of loop" attached to it out of a loop HOT 1
- Mouse wheel scrolling fails to scroll blockly scroll bars up or down HOT 1
- Blocky GUI is pushed from view when a long text string is entered into a block
- If block breaks when click on the star. HOT 1
- Blockly games not running correctly on chrome! HOT 4
- Headless blockly doesn't work for function/procedure calls with parameters HOT 1
- How to create types to restrict connections between few custom blocks? HOT 1
- change name on google +
- Left-Right-Up-Down movement in Blockly JS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blockly.