Skip to content

Commit

Permalink
adding nasa image of the day
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatandrei committed May 7, 2020
1 parent 109937e commit ff699e0
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/NetCore2Blockly/TestBlocklyHtml/wwwroot/blockly.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<script src="/blockly/javascript_compressed.js"></script>
<script src="/blockly/en.js"></script>
<script src="/blockly/wait_block.js"></script>
<script src="/blockly/window/open.js"></script>
<script src="blockly/Http/ifxhr.js"></script>
<script src="blockly/blocklyControls.js"></script>
<script src="others/jszip.min.js"></script>
Expand Down Expand Up @@ -545,6 +546,7 @@ <h1>
</block>
</category>
<category id="Controls" name="GUI">
<block type="window_open"></block>
<block type="valuefromtext">
<value name="IdOfText">
<shadow type="text">
Expand Down Expand Up @@ -1027,6 +1029,12 @@ <h1>
interpreter.setProperty(globalObject, 'alert',
interpreter.createNativeFunction(wrapper));

var wrapper = function (text) {
window.open(text);
};
interpreter.setProperty(globalObject, 'open',
interpreter.createNativeFunction(wrapper));

// Add an API function for the prompt() block.
var wrapper = function (text) {
text = text ? text.toString() : '';
Expand Down
27 changes: 27 additions & 0 deletions src/NetCore2Blockly/TestBlocklyHtml/wwwroot/blockly/window/open.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Blockly.Blocks['window_open'] = {

init: function() {
this.jsonInit({
"message0": 'Open %1',
"args0": [
{
"type": "input_value",
"name": "TEXT"
}
],
"previousStatement": null,
"nextStatement": null,
"style": "text_blocks"

});
}
};



Blockly.JavaScript['window_open'] = function(block) {
// Print statement.
var msg = Blockly.JavaScript.valueToCode(block, 'TEXT',
Blockly.JavaScript.ORDER_NONE) || '\'\'';
return 'open(' + msg + ');\n';
};
106 changes: 106 additions & 0 deletions src/NetCore2Blockly/TestBlocklyHtml/wwwroot/doNotCopy/testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -1528,5 +1528,111 @@ var testBlocks = [
</next>
</block>
</xml>`
},
{
name: 'NASA image',
data:`<xml xmlns="https://developers.google.com/blockly/xml">
<variables>
<variable id="sDL./h^zT]uA,gn%uSp^">urlName</variable>
<variable id="d#~hn(B|Lt|O=M~N]n]Y">answer</variable>
</variables>
<block type="variables_set" y="37" x="-334">
<field id="sDL./h^zT]uA,gn%uSp^" name="VAR">urlName</field>
<value name="VALUE">
<block type="text">
<field name="TEXT">https://api.nasa.gov/planetary/apod?api_key=VHWR2tDJz47FuQZQccUS4MpyQyplcG9C0VpfpNQo</field>
</block>
</value>
<next>
<block type="variables_set">
<field id="d#~hn(B|Lt|O=M~N]n]Y" name="VAR">answer</field>
<value name="VALUE">
<block type="httprequest">
<field name="TypeOutput">JSON</field>
<field name="TypeRequest">GET</field>
<value name="TheUrl">
<shadow type="text">
<field name="TEXT">https://api.chucknorris.io/jokes/random</field>
</shadow>
<block type="variables_get">
<field id="sDL./h^zT]uA,gn%uSp^" name="VAR">urlName</field>
</block>
</value>
</block>
</value>
<next>
<block type="text_print">
<value name="TEXT">
<block type="variables_get">
<field id="d#~hn(B|Lt|O=M~N]n]Y" name="VAR">answer</field>
</block>
</value>
<next>
<block type="text_print">
<value name="TEXT">
<block type="getproperty">
<field name="objectName">object</field>
<field name="prop">property</field>
<value name="ObjectToChange">
<block type="variables_get">
<field id="d#~hn(B|Lt|O=M~N]n]Y" name="VAR">answer</field>
</block>
</value>
<value name="PropertyName">
<block type="text">
<field name="TEXT">title</field>
</block>
</value>
</block>
</value>
<next>
<block type="text_print">
<value name="TEXT">
<block type="getproperty">
<field name="objectName">object</field>
<field name="prop">property</field>
<value name="ObjectToChange">
<block type="variables_get">
<field id="d#~hn(B|Lt|O=M~N]n]Y" name="VAR">answer</field>
</block>
</value>
<value name="PropertyName">
<block type="text">
<field name="TEXT">explanation</field>
</block>
</value>
</block>
</value>
<next>
<block type="window_open">
<value name="TEXT">
<block type="getproperty">
<field name="objectName">object</field>
<field name="prop">property</field>
<value name="ObjectToChange">
<block type="variables_get">
<field id="d#~hn(B|Lt|O=M~N]n]Y" name="VAR">answer</field>
</block>
</value>
<value name="PropertyName">
<block type="text">
<field name="TEXT">url</field>
</block>
</value>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</xml>`

}
]

0 comments on commit ff699e0

Please sign in to comment.