4147bf1a24adcee52d4a847fc2912daf1b5f3721
[occt.git] / src / DRAWEXE / DRAWEXE.html
1 <!DOCTYPE html>
2 <html lang=en-us>
3 <head>
4 <meta charset=utf-8><meta content="text/html; charset=utf-8" http-equiv=Content-Type>
5 <link rel="shortcut icon" href="lamp.ico" type="image/x-icon" />
6 <title>OCCT Draw Harness</title>
7 </head>
8 <body>
9
10 <h2>OCCT Draw Harness</h2>
11 <div>
12   <canvas id=occViewerCanvas oncontextmenu=event.preventDefault() tabindex=-1 style="border:0 none;background-color:#000" width="409" height="409"></canvas>
13 </div>
14 <h4>Output (open JavaScript console):</h4>
15 <p id="output"></p>
16 <script type="text/javascript" src="DRAWEXE.js" charset="utf-8"></script>
17 <script>
18 //! Check browser support.
19 function isWasmSupported()
20 {
21   try {
22     if (typeof WebAssembly === "object"
23      && typeof WebAssembly.instantiate === "function") {
24       const aDummyModule = new WebAssembly.Module (Uint8Array.of (0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
25       if (aDummyModule instanceof WebAssembly.Module)
26       {
27         return new WebAssembly.Instance(aDummyModule) instanceof WebAssembly.Instance;
28       }
29     }
30   } catch (e) {}
31   return false;
32 }
33 if (!isWasmSupported())
34 {
35   var anElement = document.getElementById('output');
36   anElement.innerHTML += "Browser is too old - WebAssembly support is missing!<br>Please check updates or install a modern browser.<br>";
37 }
38
39 var DRAWEXE =
40 {
41   print: (function() {
42     var anElement = document.getElementById('output');
43     //return function(theText) { anElement.innerHTML += theText + "<br>"; };
44     return function(theText) { console.warn(theText); };
45   })(),
46   printErr: function(theText) {
47     //var anElement = document.getElementById('output');
48     //anElement.innerHTML += theText + "<br>";
49     console.warn(theText);
50   },
51   canvas: (function() {
52     var aCanvas = document.getElementById('occViewerCanvas');
53     return aCanvas;
54   })(),
55
56   onRuntimeInitialized: function() {
57     //
58   }
59 };
60
61 const DRAWEXEInitialized = createDRAWEXE(DRAWEXE);
62 DRAWEXEInitialized.then(function(Module) {
63   //DRAWEXE.eval("dversion");
64 });
65
66 </script>
67 </body>
68 </html>