| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta charset="utf-8"> |
| 5 | <title>Blockly Demo: Cloud Storage</title> |
| 6 | <script src="/storage.js"></script> |
| 7 | <script src="../../blockly_compressed.js"></script> |
| 8 | <script src="../../blocks_compressed.js"></script> |
| 9 | <script src="../../msg/js/en.js"></script> |
| 10 | <style> |
| 11 | body { |
| 12 | background-color: #fff; |
| 13 | font-family: sans-serif; |
| 14 | } |
| 15 | h1 { |
| 16 | font-weight: normal; |
| 17 | font-size: 140%; |
| 18 | } |
| 19 | #sorry { |
| 20 | padding: 1ex; |
| 21 | background-color: #f9edbe; |
| 22 | border: solid 1px #f0c36d; |
| 23 | } |
| 24 | </style> |
| 25 | </head> |
| 26 | <body> |
| 27 | <h1><a href="https://developers.google.com/blockly/">Blockly</a> > |
| 28 | <a href="../index.html">Demos</a> > Cloud Storage</h1> |
| 29 | |
| 30 | <p>This is a simple demo of cloud storage using App Engine.</p> |
| 31 | |
| 32 | <script> |
| 33 | if ('BlocklyStorage' in window) { |
| 34 | BlocklyStorage.HTTPREQUEST_ERROR = 'There was a problem with the request.\n'; |
| 35 | BlocklyStorage.LINK_ALERT = 'Share your blocks with this link:\n\n%1'; |
| 36 | BlocklyStorage.HASH_ERROR = 'Sorry, "%1" doesn\'t correspond with any saved Blockly file.'; |
| 37 | BlocklyStorage.XML_ERROR = 'Could not load your saved file.\n'+ |
| 38 | 'Perhaps it was created with a different version of Blockly?'; |
| 39 | } else { |
| 40 | document.write('<p id="sorry">Sorry, cloud storage is not available. This demo must be hosted on App Engine.</p>'); |
| 41 | } |
| 42 | </script> |
| 43 | |
| 44 | <p>→ More info on <a href="https://developers.google.com/blockly/installation/cloud-storage">Cloud Storage</a>...</p> |
| 45 | |
| 46 | <p> |
| 47 | <button onclick="BlocklyStorage.link()">Save Blocks</button> |
| 48 | </p> |
| 49 | |
| 50 | <div id="blocklyDiv" style="height: 480px; width: 600px;"></div> |
| 51 | |
| 52 | <xml id="toolbox" style="display: none"> |
| 53 | <category name="Logic"> |
| 54 | <block type="controls_if"></block> |
| 55 | <block type="logic_compare"></block> |
| 56 | <block type="logic_operation"></block> |
| 57 | <block type="logic_negate"></block> |
| 58 | <block type="logic_boolean"></block> |
| 59 | </category> |
| 60 | <category name="Loops"> |
| 61 | <block type="controls_repeat_ext"> |
| 62 | <value name="TIMES"> |
| 63 | <block type="math_number"> |
| 64 | <field name="NUM">10</field> |
| 65 | </block> |
| 66 | </value> |
| 67 | </block> |
| 68 | <block type="controls_whileUntil"></block> |
| 69 | </category> |
| 70 | <category name="Math"> |
| 71 | <block type="math_number"></block> |
| 72 | <block type="math_arithmetic"></block> |
| 73 | <block type="math_single"></block> |
| 74 | </category> |
| 75 | <category name="Text"> |
| 76 | <block type="text"></block> |
| 77 | <block type="text_length"></block> |
| 78 | <block type="text_print"></block> |
| 79 | </category> |
| 80 | </xml> |
| 81 | |
| 82 | <script> |
| 83 | var workspace = Blockly.inject('blocklyDiv', |
| 84 | {media: '../../media/', |
| 85 | toolbox: document.getElementById('toolbox')}); |
| 86 | |
| 87 | // An href with #key trigers an AJAX call to retrieve saved blocks. |
| 88 | if ('BlocklyStorage' in window && window.location.hash.length > 1) { |
| 89 | BlocklyStorage.retrieveXml(window.location.hash.substring(1)); |
| 90 | } |
| 91 | </script> |
| 92 | |
| 93 | </body> |
| 94 | </html> |