Debian Codegraph @

src/host-web/webchuck/examples/globals2/index.html

raw symbols SCIP
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 2: getting global ints and floats and responding to global Events
12 global Event metro;
13 global int ticks;
14 global float timeInSeconds;
15 fun void RideTheMetro()
16 {
17 while( true )
18 {
19 0.348::second => now;
20 ticks++;
21 now / second => timeInSeconds;
22 metro.broadcast();
23 }
24 }
25 spork ~ RideTheMetro();
26
27 while( true )
28 {
29 1::second => now;
30 }
31
32 </div>
33 </div>
34 <div class="buttons">
35 <button class="chuckButton" id="startChuck" disabled="disabled">Start ChucK</button>
36 <button class="chuckButton" id="compileButton" disabled="disabled">Compile and Run</button>
37 <button class="chuckButton" id="replaceButton" disabled="disabled">Replace</button>
38 <button class="chuckButton" id="removeButton" disabled="disabled">Remove</button>
39 <button class="chuckButton" id="clearButton" disabled="disabled">Clear VM and Globals</button>
40 <button class="chuckButton" id="micButton" disabled="disabled">Enable Microphone</button>
41 <button class="chuckButton" id="fileFormButton">Show File Uploader</button>
42 </div>
43 <div id="fileForm" class="hidden">
44 <p>File name to use in ChucK: <input type="text" id="uploadFilename"></p>
45 <p>Local file to upload: <input type="file" id="uploadFile" name="uploadFile"></p>
46 <p><button class="chuckButton" id="fileButton" disabled="disabled">Upload File to Virtual File System</button></p>
47 </div>
48 <div>
49 <textarea id="output"></textarea>
50 <div id="shreds">
51 <table id="shredstable">
52 <col width="60px">
53 <col width="1*">
54 <col width="50px">
55 <col width="60px">
56 <tr><th>shred</th><th>code</th><th>time</th><th>remove</th>
57 </table>
58 </div>
59 <div class="clearfix"></div>
60 </div>
61 <script type="text/javascript" src="../../js/ace-min-noconflict/ace.js" charset="utf-8"></script>
62 <script type="text/javascript" src="../../js/editor.js"></script>
63 <script type="text/javascript" src="../../js/defer.js"></script>
64 <script>
65 // override
66 var whereIsChuck = "../../js";
67 </script>
68 <script type="text/javascript" src="../../js/webchuck_host.js"></script>
69 <script type="text/javascript" src="../../js/host.js"></script>
70 <script>
71 theChuckReady.then( function()
72 {
73 var listenToMetro = function()
74 {
75 theChuck.getInt( "ticks" ).then( function( result ) {
76 chuckPrint( "[javascript] number of metro ticks is ", result );
77 });
78 theChuck.getFloat( "timeInSeconds" ).then( function( result ) {
79 chuckPrint( "[javascript] timeInSeconds is ", result );
80 });
81 }
82
83 // compile it for this test without waiting for the user to click button
84 // just to make sure the global Event exists
85 theChuck.runCode( "global Event metro;" ).then( function( shred )
86 {
87 // so we can do this after
88 theChuck.startListeningForEvent( "metro", listenToMetro );
89 });
90 });
91 </script>
92 </body>
93 </html>
94
95