| 1 | <!doctype html> |
| 2 | <html lang="en-us"> |
| 3 | <head> |
| 4 | <meta charset="utf-8"> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 | <title>ChucK + JS => ChucKScript</title> |
| 7 | <link rel="stylesheet" href="../../css/editor.css"> |
| 8 | </head> |
| 9 | <body onresize="chuckEditor.resize();"> |
| 10 | <div> |
| 11 | <div id="program">// Globals 4: setting and getting ints, floats, strings; listen for event once |
| 12 | 1 => global int globalInt; |
| 13 | 2 => global float globalFloat; |
| 14 | "3" => global string globalString; |
| 15 | global Event windsOfChange; |
| 16 | |
| 17 | <<< globalInt, globalFloat, globalString >>>; |
| 18 | windsOfChange.signal(); |
| 19 | 0.5::second => now; |
| 20 | <<< globalInt, globalFloat, globalString >>>; |
| 21 | windsOfChange.signal(); |
| 22 | </div> |
| 23 | </div> |
| 24 | <div class="buttons"> |
| 25 | <button class="chuckButton" id="startChuck" disabled="disabled">Start ChucK</button> |
| 26 | <button class="chuckButton" id="compileButton" disabled="disabled">Compile and Run</button> |
| 27 | <button class="chuckButton" id="replaceButton" disabled="disabled">Replace</button> |
| 28 | <button class="chuckButton" id="removeButton" disabled="disabled">Remove</button> |
| 29 | <button class="chuckButton" id="clearButton" disabled="disabled">Clear VM and Globals</button> |
| 30 | <button class="chuckButton" id="micButton" disabled="disabled">Enable Microphone</button> |
| 31 | <button class="chuckButton" id="fileFormButton">Show File Uploader</button> |
| 32 | </div> |
| 33 | <div id="fileForm" class="hidden"> |
| 34 | <p>File name to use in ChucK: <input type="text" id="uploadFilename"></p> |
| 35 | <p>Local file to upload: <input type="file" id="uploadFile" name="uploadFile"></p> |
| 36 | <p><button class="chuckButton" id="fileButton" disabled="disabled">Upload File to Virtual File System</button></p> |
| 37 | </div> |
| 38 | <div> |
| 39 | <textarea id="output"></textarea> |
| 40 | <div id="shreds"> |
| 41 | <table id="shredstable"> |
| 42 | <col width="60px"> |
| 43 | <col width="1*"> |
| 44 | <col width="50px"> |
| 45 | <col width="60px"> |
| 46 | <tr><th>shred</th><th>code</th><th>time</th><th>remove</th> |
| 47 | </table> |
| 48 | </div> |
| 49 | <div class="clearfix"></div> |
| 50 | </div> |
| 51 | <script type="text/javascript" src="../../js/ace-min-noconflict/ace.js" charset="utf-8"></script> |
| 52 | <script type="text/javascript" src="../../js/editor.js"></script> |
| 53 | <script type="text/javascript" src="../../js/defer.js"></script> |
| 54 | <script> |
| 55 | // override |
| 56 | var whereIsChuck = "../../js"; |
| 57 | </script> |
| 58 | <script type="text/javascript" src="../../js/webchuck_host.js"></script> |
| 59 | <script type="text/javascript" src="../../js/host.js"></script> |
| 60 | <script> |
| 61 | theChuckReady.then( function() { |
| 62 | // compile it for this test without waiting for the user to click button |
| 63 | // just to make sure the global Event exists |
| 64 | theChuck.runCode( "global Event windsOfChange;" ).then( function( shred ) |
| 65 | { |
| 66 | // so we can do this after |
| 67 | theChuck.listenForEventOnce( "windsOfChange", function() |
| 68 | { |
| 69 | theChuck.setInt( "globalInt", 53 ); |
| 70 | theChuck.setFloat( "globalFloat", 5.3 ); |
| 71 | theChuck.setString( "globalString", "053" ); |
| 72 | |
| 73 | theChuck.listenForEventOnce( "windsOfChange", function() |
| 74 | { |
| 75 | theChuck.getInt( "globalInt" ).then( function( result ) |
| 76 | { |
| 77 | chuckPrint( "the gotten global int is ", result ); |
| 78 | }); |
| 79 | theChuck.getFloat( "globalFloat" ).then( function( result ) |
| 80 | { |
| 81 | chuckPrint( "the gotten global float is ", result ); |
| 82 | }); |
| 83 | theChuck.getString( "globalString" ).then( function( result ) |
| 84 | { |
| 85 | chuckPrint( "the gotten global string is ", result ); |
| 86 | }); |
| 87 | } ); |
| 88 | } ); |
| 89 | }); |
| 90 | }); |
| 91 | </script> |
| 92 | </body> |
| 93 | </html> |
| 94 | |
| 95 |