annotate Applications/Samples/Web/simple-viewer-single-file.ts @ 1033:e160159b1905 toa2019100702

Fixed buggy return of stack data
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 07 Oct 2019 15:09:37 +0200
parents 79bb0a02d1cc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
126c9c0c9333 SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
diff changeset
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
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
4
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
5 function SelectTool(toolName: string) {
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 287
diff changeset
6 var command = {
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 287
diff changeset
7 command: "selectTool",
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 287
diff changeset
8 args: {
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 287
diff changeset
9 toolName: toolName
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 287
diff changeset
10 }
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 287
diff changeset
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
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 287
diff changeset
13
287
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
14 }
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
15
307
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 287
diff changeset
16 function PerformAction(commandName: string) {
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 287
diff changeset
17 var command = {
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 287
diff changeset
18 command: commandName,
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 287
diff changeset
19 commandType: "simple",
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 287
diff changeset
20 args: {}
be2660b6e40a wip: commands + status update
am@osimis.io
parents: 287
diff changeset
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
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
23 }
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
24
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
25 //initializes the buttons
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
26 //-----------------------
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
27 // install "SelectTool" handlers
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
28 document.querySelectorAll("[tool-selector]").forEach((e) => {
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
29 console.log(e);
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
30 (e as HTMLInputElement).addEventListener("click", () => {
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
31 console.log(e);
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
32 SelectTool(e.attributes["tool-selector"].value);
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
33 });
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
34 });
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
35
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
36 // install "PerformAction" handlers
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
37 document.querySelectorAll("[action-trigger]").forEach((e) => {
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
38 (e as HTMLInputElement).addEventListener("click", () => {
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
39 PerformAction(e.attributes["action-trigger"].value);
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
40 });
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
41 });
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
42
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
43 // this method is called "from the C++ code" when the StoneApplication is updated.
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
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
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
46 console.log(statusUpdateMessage);
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
47
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
48 if (statusUpdateMessage.startsWith("series-description=")) {
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
49 document.getElementById("series-description").innerText = statusUpdateMessage.split("=")[1];
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
50 }
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
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;