Debian Codegraph @

src/host-web/webchuck/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">// Hi there, take a look at this example!
12 global int mouseX;
13 global Event mouseClicked;
14 SinOsc foo => dac;
15 300 => float currentBaseFrequency;
16
17 // The sine wave's frequency is mapped to
18 // the x position of the mouse...
19 fun void RespondToMouseMovement()
20 {
21 while( true )
22 {
23 currentBaseFrequency + 0.3 * mouseX => foo.freq;
24 10::ms => now;
25 }
26 }
27 spork ~ RespondToMouseMovement();
28
29 //... plus some randomness!
30 fun void UpdateBaseFrequency()
31 {
32 while( true )
33 {
34 Math.random2f( 300, 600 ) => currentBaseFrequency;
35 200::ms => now;
36 }
37 }
38 spork ~ UpdateBaseFrequency();
39
40 // It will stop playing when you click the mouse
41 // (at least 1 minute after starting)
42 // (you can also stop it with the "remove" button below)
43 1::minute => now;
44 mouseClicked => now;
45 </div>
46 </div>
47 <div class="buttons">
48 <button class="chuckButton" id="startChuck" disabled="disabled">Start ChucK</button>
49 <button class="chuckButton" id="compileButton" disabled="disabled">Compile and Run</button>
50 <button class="chuckButton" id="replaceButton" disabled="disabled">Replace</button>
51 <button class="chuckButton" id="removeButton" disabled="disabled">Remove</button>
52 <button class="chuckButton" id="clearButton" disabled="disabled">Clear VM and Globals</button>
53 <button class="chuckButton" id="micButton" disabled="disabled">Enable Microphone</button>
54 <button class="chuckButton" id="fileFormButton">Show File Uploader</button>
55 </div>
56 <div id="fileForm" class="hidden">
57 <p>File name to use in ChucK: <input type="text" id="uploadFilename"></p>
58 <p>Local file to upload: <input type="file" id="uploadFile" name="uploadFile"></p>
59 <p><button class="chuckButton" id="fileButton" disabled="disabled">Upload File to Virtual File System</button></p>
60 </div>
61 <div>
62 <textarea id="output"></textarea>
63 <div id="shreds">
64 <table id="shredstable">
65 <col width="60px">
66 <col width="1*">
67 <col width="50px">
68 <col width="60px">
69 <tr><th>shred</th><th>code</th><th>time</th><th>remove</th>
70 </table>
71 </div>
72 <div class="clearfix"></div>
73 </div>
74 <script src="./js/ace-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
75 <script type="text/javascript" src="./js/editor.js"></script>
76 <script type="text/javascript" src="./js/defer.js"></script>
77 <script>
78 // no need to override this, but this is how you would do it:
79 // the path from the HTML file to chuckscript.[js,wasm]
80 var whereIsChuck = "./js";
81
82 // files we want to load into our virtual filesystem
83 var serverFilesToPreload = [
84 {
85 serverFilename: './wav/aah.wav',
86 virtualFilename: 'aah5.wav'
87 }
88 ];
89 </script>
90 <script type="text/javascript" src="./js/webchuck_host.js"></script>
91 <script type="text/javascript" src="./js/host.js"></script>
92 <script>
93 theChuckReady.then( function() {
94 if( window.Event ) {
95 document.captureEvents( Event.MOUSEMOVE );
96 }
97 document.onmousemove = function( e )
98 {
99 var x = (window.Event) ? e.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
100 var y = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
101 theChuck.setInt( "mouseX", x );
102 }
103 document.onclick = function( e )
104 {
105 theChuck.broadcastEvent( "mouseClicked" );
106 }
107 });
108 </script>
109 </body>
110 </html>
111
112