Explorar el Código

added call parseAll to myEvents.js

DS hace 2 años
padre
commit
fe64a4f40b
Se han modificado 2 ficheros con 25 adiciones y 2 borrados
  1. 21 0
      js/executeNodeSetParser.js
  2. 4 2
      js/myEvents.js

+ 21 - 0
js/executeNodeSetParser.js

@@ -0,0 +1,21 @@
+/*
+sources:
+https://stackoverflow.com/questions/1880198/how-to-execute-shell-command-in-javascript, 02/03/2022
+*/
+
+
+
+export function parseAll(){
+	var exec = require('child_process').exec;
+	var listxml = '';
+exec('cd .. && cd nodesets && ls',
+    function (error, stdout, stderr) {
+        //console.log('stdout: ' + stdout);
+        //console.log('stderr: ' + stderr);
+		listxml = stdout;
+		console.log('stdout: ' + listxml);
+        if (error !== null) {
+             console.log('exec error: ' + error);
+        }
+    });	
+}

+ 4 - 2
js/myEvents.js

@@ -1,5 +1,4 @@
 $(document).ready(function(){
-	import { parseAll } from './executeNodeSetParser.mjs';
     function newElementaddressSpace(){
 		var $tr = $('<tr>');
 		$tr.append('<td><img src='+'graphics/Gauge.svg'+' height='+"100"+' width='+"100"+'></img></td></tr>');
@@ -17,7 +16,10 @@ $(document).ready(function(){
 	$("#load_nodeset").click(function(){
 		
 		newElementaddressSpace();
-		let lt = parseAll();
+		$.getScript('executeNodeSetParser.js', function(jd) {
+		let lt = parseAll()
+		})
+		
 		console.log("Button1 clicked")
 	})