Shh....
Send (awkwardly) from an Android phone.
--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I've just been making some blocks in the block factory and see that there is a dropdown next to the block definition code that lets me see the definition in JavaScript or in JSON format.I've never come across JSON format blocks before and couldn't see anything in the docs. How do we use it? Does this also mean I can use JSON instead of XML for the workspace too?
And here's the JSON based definition (actually it's javascript - but most of it's JSON :) ) for the Say block:
var ID_GREETING = "Greeting";
defineAction({
name: 'Say',
interface: [ {name:ID_GREETING, title: '', text:'...'} ],
javascript: function (block) {
return 'console.log("' + getText(block, ID_GREETING) + '");\n';
}
});And the Every Block:
var DURATION = 'DURATION';
defineRule({
name: 'Every', next:false, previous:false,
interface: [
{name:DURATION, title:'', number:1},
{menu:['Seconds','Minutes','Hours'], name:UNITS_MENU, title:''},
{statement:STATEMENT}
],
javascript: function(block) {
var duration = getNumber(block, DURATION);
switch (getMenu(block, UNITS_MENU)) {
case 'Minutes':
duration *= 60;
break;
case 'Hours':
duration *= 60*60;
break;
};
var statement = getStatement(block, STATEMENT);
var result = "quando.every("
+ duration
+ ", function() {\n"
+ statement
+ "});\n";
return result;
}
});Here's the generated code (for reference), where quando is my runtime library to simplify event handling on node js/browser:
quando = require("./quando.js");
quando.every(1, function() {
console.log("hi");
});
Hope this helps - let me know if you would like any more information.
Best wishes
Andy Stratton
--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
So Neil, now that we have JSON blocks, does that mean we could expected a JSON toolbox as well?
--
You received this message because you are subscribed to a topic in the Google Groups "Blockly" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/blockly/pMsZS3P7c0c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to blockly+u...@googlegroups.com.