comparison Applications/Samples/Web/simple-viewer-single-file.ts @ 319:daa04d15192c am-2

new SimpleViewer sample that has been split in multiple files to be able to scale it
author am@osimis.io
date Thu, 11 Oct 2018 13:16:54 +0200
parents Applications/Samples/Web/simple-viewer.ts@be2660b6e40a
children 612238b3f3e8
comparison
equal deleted inserted replaced
318:3a4ca166fafa 319:daa04d15192c
1 ///<reference path='../../../Platforms/Wasm/wasm-application-runner.ts'/>
2
3 InitializeWasmApplication("OrthancStoneSimpleViewer", "/orthanc");
4
5 function SelectTool(toolName: string) {
6 var command = {
7 command: "selectTool",
8 args: {
9 toolName: toolName
10 }
11 };
12 SendMessageToStoneApplication(JSON.stringify(command));
13
14 }
15
16 function PerformAction(commandName: string) {
17 var command = {
18 command: commandName,
19 commandType: "simple",
20 args: {}
21 };
22 SendMessageToStoneApplication(JSON.stringify(command));
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 }