comparison Samples/WebAssembly/RtViewer/RtViewerWasmApp.js @ 1384:24bcff8ea58f

RtViewer : SDL ok. Preparation for WASM builds ongoing
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 27 Apr 2020 10:01:48 +0200
parents
children 27e0a00bd3e8
comparison
equal deleted inserted replaced
1383:ab871499ed30 1384:24bcff8ea58f
1 // Check support for WebAssembly
2 if (!('WebAssembly' in window)) {
3 alert('Sorry, your browser does not support WebAssembly :(');
4 } else {
5
6 // Wait for the module to be loaded (the event "WebAssemblyLoaded"
7 // must be emitted by the "main" function)
8 window.addEventListener('WebAssemblyLoaded', function() {
9
10 // Loop over the GET arguments
11 var parameters = window.location.search.substr(1);
12 if (parameters != null && parameters != '') {
13 var tokens = parameters.split('&');
14 for (var i = 0; i < tokens.length; i++) {
15 var arg = tokens[i].split('=');
16 if (arg.length == 2) {
17
18 // Send each GET argument to WebAssembly
19 Module.ccall('SetArgument', null, [ 'string', 'string' ],
20 [ arg[0], decodeURIComponent(arg[1]) ]);
21 }
22 }
23 }
24
25 // Inform the WebAssembly module that it can start
26 Module.ccall('Initialize', null, null, null);
27 });
28 }