comparison Applications/Samples/Deprecated/Web/simple-viewer-single-file.ts @ 1347:bfd77672d825 broker

Moved Application/Samples/* to Application/Samples/Deprecated/*
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 07 Apr 2020 14:29:01 +0200
parents Applications/Samples/Web/simple-viewer-single-file.ts@79bb0a02d1cc
children
comparison
equal deleted inserted replaced
1346:df8bf351c23f 1347:bfd77672d825
1 import wasmApplicationRunner = require('../../../Platforms/Wasm/wasm-application-runner');
2
3 wasmApplicationRunner.InitializeWasmApplication("OrthancStoneSimpleViewerSingleFile", "/orthanc");
4
5 function SelectTool(toolName: string) {
6 var command = {
7 command: "selectTool",
8 args: {
9 toolName: toolName
10 }
11 };
12 wasmApplicationRunner.SendSerializedMessageToStoneApplication(JSON.stringify(command));
13
14 }
15
16 function PerformAction(commandName: string) {
17 var command = {
18 command: commandName,
19 commandType: "simple",
20 args: {}
21 };
22 wasmApplicationRunner.SendSerializedMessageToStoneApplication(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 UpdateWebApplicationWithString(statusUpdateMessage: string) {
46 console.log(statusUpdateMessage);
47
48 if (statusUpdateMessage.startsWith("series-description=")) {
49 document.getElementById("series-description").innerText = statusUpdateMessage.split("=")[1];
50 }
51 }
52
53 function UpdateWebApplicationWithSerializedMessage(statusUpdateMessageString: string) {
54 console.log("updating web application with serialized message: ", statusUpdateMessageString);
55 console.log("<not supported in the simple viewer (single file)!>");
56 }
57
58 // make it available to other js scripts in the application
59 (<any> window).UpdateWebApplicationWithString = UpdateWebApplicationWithString;
60
61 (<any> window).UpdateWebApplicationWithSerializedMessage = UpdateWebApplicationWithSerializedMessage;