Mercurial > hg > orthanc-stone
annotate Applications/Samples/Web/simple-viewer-single-file.ts @ 482:f58fe38c8c04 bgo-commands-codegen
Ongoing work on codegen: ts and cpp enum and struct writing seem to be OK. No file write yet
author | bgo-osimis |
---|---|
date | Thu, 14 Feb 2019 20:58:42 +0100 |
parents | 5055031f4a06 |
children | 7105a0bad250 |
rev | line source |
---|---|
466
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
326
diff
changeset
|
1 import wasmApplicationRunner = require('../../../Platforms/Wasm/wasm-application-runner'); |
238 | 2 |
466
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
326
diff
changeset
|
3 wasmApplicationRunner.InitializeWasmApplication("OrthancStoneSimpleViewerSingleFile", "/orthanc"); |
287 | 4 |
5 function SelectTool(toolName: string) { | |
307 | 6 var command = { |
7 command: "selectTool", | |
8 args: { | |
9 toolName: toolName | |
10 } | |
11 }; | |
466
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
326
diff
changeset
|
12 wasmApplicationRunner.SendMessageToStoneApplication(JSON.stringify(command)); |
307 | 13 |
287 | 14 } |
15 | |
307 | 16 function PerformAction(commandName: string) { |
17 var command = { | |
18 command: commandName, | |
19 commandType: "simple", | |
20 args: {} | |
21 }; | |
466
5055031f4a06
- Added browserify to build. This allows using require calls for modules that
bgo-osimis
parents:
326
diff
changeset
|
22 wasmApplicationRunner.SendMessageToStoneApplication(JSON.stringify(command)); |
287 | 23 } |
24 | |
25 //initializes the buttons | |
26 //----------------------- | |
27 // install "SelectTool" handlers | |
28 document.querySelectorAll("[tool-selector]").forEach((e) => { | |
29 console.log(e); | |
30 (e as HTMLInputElement).addEventListener("click", () => { | |
31 console.log(e); | |
32 SelectTool(e.attributes["tool-selector"].value); | |
33 }); | |
34 }); | |
35 | |
36 // install "PerformAction" handlers | |
37 document.querySelectorAll("[action-trigger]").forEach((e) => { | |
38 (e as HTMLInputElement).addEventListener("click", () => { | |
39 PerformAction(e.attributes["action-trigger"].value); | |
40 }); | |
41 }); | |
42 | |
43 // this method is called "from the C++ code" when the StoneApplication is updated. | |
44 // it can be used to update the UI of the application | |
45 function UpdateWebApplication(statusUpdateMessage: string) { | |
46 console.log(statusUpdateMessage); | |
47 | |
48 if (statusUpdateMessage.startsWith("series-description=")) { | |
49 document.getElementById("series-description").innerText = statusUpdateMessage.split("=")[1]; | |
50 } | |
51 } |