annotate Applications/Samples/Web/simple-viewer.ts @ 293:017044be141b am-2

renaming
author am@osimis.io
date Thu, 30 Aug 2018 17:15:22 +0200
parents 2038d76bf13f
children be2660b6e40a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
287
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
1 ///<reference path='../../../Platforms/Wasm/wasm-application-runner.ts'/>
238
126c9c0c9333 SimpleViewer demo running both with SDL and Wasm
am@osimis.io
parents:
diff changeset
2
264
6b98ac45aaee documented how to compile and execute WASM samples
am@osimis.io
parents: 240
diff changeset
3 InitializeWasmApplication("OrthancStoneSimpleViewer", "/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) {
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
6 SendMessageToStoneApplication("select-tool:" + toolName);
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
7 }
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
8
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
9 function PerformAction(actionName: string) {
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
10 SendMessageToStoneApplication("perform-action:" + actionName);
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
11 }
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
12
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
13 //initializes the buttons
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 // install "SelectTool" handlers
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
16 document.querySelectorAll("[tool-selector]").forEach((e) => {
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
17 console.log(e);
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
18 (e as HTMLInputElement).addEventListener("click", () => {
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
19 console.log(e);
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
20 SelectTool(e.attributes["tool-selector"].value);
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
21 });
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
22 });
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 // install "PerformAction" handlers
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
25 document.querySelectorAll("[action-trigger]").forEach((e) => {
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
26 (e as HTMLInputElement).addEventListener("click", () => {
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
27 PerformAction(e.attributes["action-trigger"].value);
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
28 });
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
29 });
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
30
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
31 // 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
32 // it can be used to update the UI of the application
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
33 function UpdateWebApplication(statusUpdateMessage: string) {
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
34 console.log(statusUpdateMessage);
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 if (statusUpdateMessage.startsWith("series-description=")) {
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
37 document.getElementById("series-description").innerText = statusUpdateMessage.split("=")[1];
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
38 }
2038d76bf13f interaction with HTML/JS
am@osimis.io
parents: 264
diff changeset
39 }