Mercurial > hg > orthanc-stone
annotate Applications/Samples/Web/simple-viewer-single-file.ts @ 839:c47031d9f6b1
Added dose struct load in (ongoing) FusionMprSample + doc change
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 03 Jun 2019 14:37:17 +0200 |
parents | 79bb0a02d1cc |
children |
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 }; | |
535
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
510
diff
changeset
|
12 wasmApplicationRunner.SendSerializedMessageToStoneApplication(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 }; | |
535
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
510
diff
changeset
|
22 wasmApplicationRunner.SendSerializedMessageToStoneApplication(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 | |
508
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
466
diff
changeset
|
45 function UpdateWebApplicationWithString(statusUpdateMessage: string) { |
287 | 46 console.log(statusUpdateMessage); |
47 | |
48 if (statusUpdateMessage.startsWith("series-description=")) { | |
49 document.getElementById("series-description").innerText = statusUpdateMessage.split("=")[1]; | |
50 } | |
51 } | |
508
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
466
diff
changeset
|
52 |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
466
diff
changeset
|
53 function UpdateWebApplicationWithSerializedMessage(statusUpdateMessageString: string) { |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
466
diff
changeset
|
54 console.log("updating web application with serialized message: ", statusUpdateMessageString); |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
466
diff
changeset
|
55 console.log("<not supported in the simple viewer (single file)!>"); |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
466
diff
changeset
|
56 } |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
466
diff
changeset
|
57 |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
466
diff
changeset
|
58 // make it available to other js scripts in the application |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
466
diff
changeset
|
59 (<any> window).UpdateWebApplicationWithString = UpdateWebApplicationWithString; |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
466
diff
changeset
|
60 |
7105a0bad250
- Added HandleSerializedMessage to IStoneApplication (empty impl)
Benjamin Golinvaux <bgo@osimis.io>
parents:
466
diff
changeset
|
61 (<any> window).UpdateWebApplicationWithSerializedMessage = UpdateWebApplicationWithSerializedMessage; |