Mercurial > hg > orthanc-stone
comparison Applications/Samples/Web/simple-viewer.ts @ 287:2038d76bf13f am-2
interaction with HTML/JS
author | am@osimis.io |
---|---|
date | Thu, 30 Aug 2018 11:36:36 +0200 |
parents | 6b98ac45aaee |
children | be2660b6e40a |
comparison
equal
deleted
inserted
replaced
286:6b3d91857b96 | 287:2038d76bf13f |
---|---|
1 ///<reference path='../../../Platforms/Wasm/wasm-application.ts'/> | 1 ///<reference path='../../../Platforms/Wasm/wasm-application-runner.ts'/> |
2 | 2 |
3 InitializeWasmApplication("OrthancStoneSimpleViewer", "/orthanc"); | 3 InitializeWasmApplication("OrthancStoneSimpleViewer", "/orthanc"); |
4 | |
5 function SelectTool(toolName: string) { | |
6 SendMessageToStoneApplication("select-tool:" + toolName); | |
7 } | |
8 | |
9 function PerformAction(actionName: string) { | |
10 SendMessageToStoneApplication("perform-action:" + actionName); | |
11 } | |
12 | |
13 //initializes the buttons | |
14 //----------------------- | |
15 // install "SelectTool" handlers | |
16 document.querySelectorAll("[tool-selector]").forEach((e) => { | |
17 console.log(e); | |
18 (e as HTMLInputElement).addEventListener("click", () => { | |
19 console.log(e); | |
20 SelectTool(e.attributes["tool-selector"].value); | |
21 }); | |
22 }); | |
23 | |
24 // install "PerformAction" handlers | |
25 document.querySelectorAll("[action-trigger]").forEach((e) => { | |
26 (e as HTMLInputElement).addEventListener("click", () => { | |
27 PerformAction(e.attributes["action-trigger"].value); | |
28 }); | |
29 }); | |
30 | |
31 // this method is called "from the C++ code" when the StoneApplication is updated. | |
32 // it can be used to update the UI of the application | |
33 function UpdateWebApplication(statusUpdateMessage: string) { | |
34 console.log(statusUpdateMessage); | |
35 | |
36 if (statusUpdateMessage.startsWith("series-description=")) { | |
37 document.getElementById("series-description").innerText = statusUpdateMessage.split("=")[1]; | |
38 } | |
39 } |