comparison Samples/WebAssembly/app.js @ 831:d71cf8504159

handling of GET arguments
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 31 May 2019 10:30:22 +0200
parents
children
comparison
equal deleted inserted replaced
830:171a486a0373 831:d71cf8504159
1 /**
2 * This is a generic bootstrap code that is shared by all the Stone
3 * sample applications.
4 **/
5
6 // Check support for WebAssembly
7 if (!('WebAssembly' in window)) {
8 alert('Sorry, your browser does not support WebAssembly :(');
9 } else {
10
11 // Wait for the module to be loaded (the event "WebAssemblyLoaded"
12 // must be emitted by the "main" function)
13 window.addEventListener('WebAssemblyLoaded', function() {
14
15 // Loop over the GET arguments
16 var parameters = window.location.search.substr(1);
17 if (parameters != null && parameters != '') {
18 var tokens = parameters.split('&');
19 for (var i = 0; i < tokens.length; i++) {
20 var arg = tokens[i].split('=');
21 if (arg.length == 2) {
22
23 // Send each GET argument to WebAssembly
24 Module.ccall('SetArgument', null, [ 'string', 'string' ],
25 [ arg[0], decodeURIComponent(arg[1]) ]);
26 }
27 }
28 }
29
30 // Inform the WebAssembly module that it can start
31 Module.ccall('Initialize', null, null, null);
32 });
33 }