287
|
1 ///<reference path='../../../Platforms/Wasm/wasm-application-runner.ts'/>
|
238
|
2
|
326
|
3 InitializeWasmApplication("OrthancStoneSimpleViewerSingleFile", "/orthanc");
|
287
|
4
|
|
5 function SelectTool(toolName: string) {
|
307
|
6 var command = {
|
|
7 command: "selectTool",
|
|
8 args: {
|
|
9 toolName: toolName
|
|
10 }
|
|
11 };
|
|
12 SendMessageToStoneApplication(JSON.stringify(command));
|
|
13
|
287
|
14 }
|
|
15
|
307
|
16 function PerformAction(commandName: string) {
|
|
17 var command = {
|
|
18 command: commandName,
|
|
19 commandType: "simple",
|
|
20 args: {}
|
|
21 };
|
|
22 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 }
|