diff 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
line wrap: on
line diff
--- a/Resources/CodeGeneration/testWasmIntegrated/testWasmIntegrated.ts	Sun Feb 24 10:11:38 2019 +0100
+++ b/Resources/CodeGeneration/testWasmIntegrated/testWasmIntegrated.ts	Sun Feb 24 13:23:14 2019 +0100
@@ -1,13 +1,32 @@
 export var SendMessageToStoneApplication: Function = null;
 
-function SelectTool(toolName: string) {
-  var command = {
-    command: "selectTool:" + toolName,
-    commandType: "generic-no-arg-command",
-    args: {
-    }                                                                                                                       
-  };
-  SendMessageToStoneApplication(JSON.stringify(command));
+// install handlers
+document.querySelectorAll(".TestWasm-button").forEach((e) => {
+  (e as HTMLButtonElement).addEventListener("click", () => {
+    ButtonClick(e.attributes["tool-selector"].value);
+  });
+});
+
+let stockSerializedMessages = new Map<string,string>();
+
+stockSerializedMessages["Test 1"] = "Test 1 stock message fgdgg";
+stockSerializedMessages["Test 2"] = "Test 2 stock message bccbbbbbb";
+stockSerializedMessages["Test 3"] = "Test 3 stock message sdfsfsdfsdf";
+stockSerializedMessages["Test 4"] = "Test 4 stock message 355345345";
+stockSerializedMessages["Test 5"] = "Test 5 stock message 34535";
+stockSerializedMessages["Test 6"] = "Test 6 stock message xcvcxvx";
+stockSerializedMessages["Test 7"] = "Test 7 stock message fgwqewqdgg";
+stockSerializedMessages["Test 8"] = "Test 8 stock message fgfsdfsdgg";
+
+function ButtonClick(buttonName: string) {
+  if (buttonName.startsWith('Test ')) {
+    let e : HTMLTextAreaElement = document.getElementById('TestWasm-SerializedInput') as HTMLTextAreaElement;
+    e.value = stockSerializedMessages[buttonName];
+  }
+  else if(buttonName == 'Trigger')
+  {
+    console.error('Not implemented!')
+  }
 }
 
 (<any> window).StoneFrameworkModule = {
@@ -34,12 +53,7 @@
   totalDependencies: 0
 };
 
-// install "SelectTool" handlers
-document.querySelectorAll("[tool-selector]").forEach((e) => {
-    (e as HTMLButtonElement).addEventListener("click", () => {
-    SelectTool(e.attributes["tool-selector"].value);
-    });
-});
+
 
 // this method is called "from the C++ code" when the StoneApplication is updated.
 // it can be used to update the UI of the application