comparison Resources/CodeGeneration/testWasmIntegrated/testWasmIntegrated.ts @ 498:6d62fc8a6988 bgo-commands-codegen

Web demonstrator for codegen ongoing work
author bgo-osimis
date Sun, 24 Feb 2019 13:23:14 +0100
parents 8b6ceae45ba0
children baa9e1e932db
comparison
equal deleted inserted replaced
497:d79f78971fae 498:6d62fc8a6988
1 export var SendMessageToStoneApplication: Function = null; 1 export var SendMessageToStoneApplication: Function = null;
2 2
3 function SelectTool(toolName: string) { 3 // install handlers
4 var command = { 4 document.querySelectorAll(".TestWasm-button").forEach((e) => {
5 command: "selectTool:" + toolName, 5 (e as HTMLButtonElement).addEventListener("click", () => {
6 commandType: "generic-no-arg-command", 6 ButtonClick(e.attributes["tool-selector"].value);
7 args: { 7 });
8 } 8 });
9 }; 9
10 SendMessageToStoneApplication(JSON.stringify(command)); 10 let stockSerializedMessages = new Map<string,string>();
11
12 stockSerializedMessages["Test 1"] = "Test 1 stock message fgdgg";
13 stockSerializedMessages["Test 2"] = "Test 2 stock message bccbbbbbb";
14 stockSerializedMessages["Test 3"] = "Test 3 stock message sdfsfsdfsdf";
15 stockSerializedMessages["Test 4"] = "Test 4 stock message 355345345";
16 stockSerializedMessages["Test 5"] = "Test 5 stock message 34535";
17 stockSerializedMessages["Test 6"] = "Test 6 stock message xcvcxvx";
18 stockSerializedMessages["Test 7"] = "Test 7 stock message fgwqewqdgg";
19 stockSerializedMessages["Test 8"] = "Test 8 stock message fgfsdfsdgg";
20
21 function ButtonClick(buttonName: string) {
22 if (buttonName.startsWith('Test ')) {
23 let e : HTMLTextAreaElement = document.getElementById('TestWasm-SerializedInput') as HTMLTextAreaElement;
24 e.value = stockSerializedMessages[buttonName];
25 }
26 else if(buttonName == 'Trigger')
27 {
28 console.error('Not implemented!')
29 }
11 } 30 }
12 31
13 (<any> window).StoneFrameworkModule = { 32 (<any> window).StoneFrameworkModule = {
14 preRun: [ 33 preRun: [
15 function() { 34 function() {
32 console.error(text); 51 console.error(text);
33 }, 52 },
34 totalDependencies: 0 53 totalDependencies: 0
35 }; 54 };
36 55
37 // install "SelectTool" handlers 56
38 document.querySelectorAll("[tool-selector]").forEach((e) => {
39 (e as HTMLButtonElement).addEventListener("click", () => {
40 SelectTool(e.attributes["tool-selector"].value);
41 });
42 });
43 57
44 // this method is called "from the C++ code" when the StoneApplication is updated. 58 // this method is called "from the C++ code" when the StoneApplication is updated.
45 // it can be used to update the UI of the application 59 // it can be used to update the UI of the application
46 function UpdateWebApplication(statusUpdateMessageString: string) { 60 function UpdateWebApplication(statusUpdateMessageString: string) {
47 console.log("updating web application: ", statusUpdateMessageString); 61 console.log("updating web application: ", statusUpdateMessageString);