Browse Source

temporal fix for call from editor GUI

Nikolay Suslov 6 years ago
parent
commit
3860aa7008

+ 7 - 2
public/defaults/proxy/vwf.example.com/aframe/aentity.js

@@ -131,7 +131,12 @@ this.setOwner = function (param) {
 
     }
 
+}
 
+this.updateMethod = function (methodName, methodBody, params) {
+    vwf_view.kernel.setMethod(this.id, methodName, { body: methodBody, type: "application/javascript", parameters: params});
+}
 
-
-}
+this.callMethod = function(methodName, params){
+    vwf_view.kernel.callMethod(this.id, methodName, params)
+}

+ 9 - 0
public/defaults/proxy/vwf.example.com/aframe/aentity.vwf.yaml

@@ -83,5 +83,14 @@ methods:
   setOwner:
     parameters:
       - propertyValue
+  updateMethod:
+    parameters:
+      - methodName
+      - methodBody
+      - params
+  callMethod:
+    parameters:
+      - methodName
+      - params
 scripts:
   - source: "http://vwf.example.com/aframe/aentity.js"

+ 1 - 1
public/defaults/worlds/aframe-ar/index.vwf.yaml

@@ -62,7 +62,7 @@ children:
               var time = vwf.now;
               let rot = this.rotation; //AFRAME.utils.coordinates.parse(this.rotation);
               this.rotation = [rot[0], rot[1]+2, rot[2]];
-              this.future( 0.05 ).run();  // schedule the next step
+              this.future( 0.05 ).run();
   aranchor2:
     extends: http://vwf.example.com/aframe/a-arjs-anchor.vwf
     properties:

+ 1 - 1
public/defaults/worlds/aframe/index.vwf.yaml

@@ -123,7 +123,7 @@ children:
               let pos = this.position; //AFRAME.utils.coordinates.parse(this.position);
               this.position = [pos[0], pos[1], Math.sin(time)];
               this.rotation = [rot[0], rot[1], Math.sin(time)*100];
-              this.future( 0.01 ).run();  // schedule the next step
+              this.future( 0.01 ).run();
 methods:
   initialize:
     body: |

+ 1 - 1
public/defaults/worlds/aframe2/index.vwf.yaml

@@ -184,7 +184,7 @@ children:
               var time = vwf.now;
               let pos = this.position; //AFRAME.utils.coordinates.parse(this.position);
               this.position = [pos[0], pos[1], Math.sin(time)]
-              this.future( 0.01 ).run();  // schedule the next step
+              this.future( 0.01 ).run();
   sky:
     extends: http://vwf.example.com/aframe/asky.vwf
     properties:

+ 1 - 1
public/defaults/worlds/multipixel/index.vwf.yaml

@@ -57,7 +57,7 @@ children:
               var time = vwf.now;
               let rot = this.rotation; //AFRAME.utils.coordinates.parse(this.rotation);
               this.rotation = [rot[0], Math.sin(time)*50, rot[2]];
-              this.future( 0.01 ).run();  // schedule the next step
+              this.future( 0.01 ).run();
   spaceText:
     extends: http://vwf.example.com/aframe/atext.vwf
     properties:

+ 0 - 12
public/defaults/worlds/ohmlang-lsys/index.vwf.yaml

@@ -5,18 +5,6 @@ extends: http://vwf.example.com/aframe/ascene.vwf
 properties:
     assets: "assets.json"
 children:
-    light1:
-        extends: http://vwf.example.com/aframe/alight.vwf
-        properties:
-        type: "ambient"
-        color: "#BBB"
-    light2:
-        extends: http://vwf.example.com/aframe/alight.vwf
-        properties:
-        type: "directional"
-        color: "#FFF"
-        intensity: 0.6
-        position: "-0.5 1 1"
     skySun:
         extends: http://vwf.example.com/aframe/aentity.vwf
         children:

+ 2 - 2
public/lib/widgets.js

@@ -503,8 +503,8 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
             return {
                     $cell: true,
                     $type: "button",
-                    class: "mdc-button" + addClass,
-                    onclick: obj.onclickfunc,
+                    class: "mdc-button " + addClass,
+                    onclick: obj.onclick,
                     $components:[
                         {
                             $cell: true,

+ 119 - 17
public/vwf/view/editor-new.js

@@ -2551,11 +2551,19 @@ define([
                                 {
 
                                     $type: "div",
-                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
+                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1 tooltip",
                                     $components: [
-                                        self.widgets.buttonStroked(
-                                            {
-                                                "label": "Update",
+                                        {
+                                            class: "tooltiptext",
+                                            $type: "span",
+                                            $text: "Update"
+                                        },
+                                        self.widgets.iconButton({
+                                            'label': 'refresh',
+                                            "styleClass": "mdc-button--outlined",
+                                        // self.widgets.buttonStroked(
+                                        //     {
+                                        //         "label": "Update",
                                                 "onclick": function (e) {
                                                     let editor = document.querySelector("#aceEditor").env.editor;
                                                     let evalText = editor.getValue();
@@ -2584,11 +2592,19 @@ define([
                                 {
 
                                     $type: "div",
-                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
+                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1 tooltip",
                                     $components: [
-                                        self.widgets.buttonStroked(
-                                            {
-                                                "label": "Call",
+                                        {
+                                            class: "tooltiptext",
+                                            $type: "span",
+                                            $text: "Call It"
+                                        },
+                                        self.widgets.iconButton({
+                                            'label': 'play_arrow',
+                                            "styleClass": "mdc-button--outlined",
+                                        // self.widgets.buttonStroked(
+                                        //     {
+                                        //         "label": "Call",
                                                 "onclick": function (e) {
                                                     var params = [];
 
@@ -2606,8 +2622,39 @@ define([
                                                             }
                                                         }
                                                     };
-                                                    self.kernel.callMethod(this._editorNode, this._methodName, params);
 
+                                                    let editor = document.querySelector("#aceEditor").env.editor;
+                                                    let evalText = editor.getValue();
+                                                    let allLines = editor.selection.doc.getAllLines();
+
+                                                    let search = this._methodName+'(';
+                                                    let findLine = Object.entries(allLines).filter(el=>el[1].includes(search))[0];
+                                                    let position = {
+                                                        row: findLine[0],
+                                                        column: 0
+                                                    };
+                                                    var Range = ace.require("ace/range").Range;
+                                                    let tempString = "//CLICK FOR CALL AGAIN ";
+
+                                                    //TODO: temporal fix for recursive future call from the editor
+                                                    if(findLine[1].includes(search)) {
+                                                        if(findLine[1].includes(tempString)){
+                                                            let newText = findLine[1].replace(tempString, "");
+
+                                                            editor.session.replace(new Range(position.row, 0, position.row, Number.MAX_VALUE), newText);
+                                                            self.kernel.setMethod(this._editorNode, this._methodName,
+                                                                { body: editor.getValue(), type: "application/javascript", parameters: this._method.parameters });
+                                                        } else if(findLine[1].includes("//")) { //startsWith
+                                                        } else {
+
+                                                            let newText = tempString + findLine[1];
+                                                            editor.session.replace(new Range(position.row, 0, position.row, Number.MAX_VALUE), newText);
+                                                            self.kernel.setMethod(this._editorNode, this._methodName,
+                                                                { body: editor.getValue(), type: "application/javascript", parameters: this._method.parameters });
+                                                        }
+
+                                                    }
+                                                    self.kernel.callMethod(this._editorNode, this._methodName, params);
                                                 }
                                             })
                                     ]
@@ -2615,11 +2662,19 @@ define([
                                 {
 
                                     $type: "div",
-                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
+                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1 tooltip",
                                     $components: [
-                                        self.widgets.buttonStroked(
-                                            {
-                                                "label": "Do It",
+                                        {
+                                            class: "tooltiptext",
+                                            $type: "span",
+                                            $text: "Do It"
+                                        },
+                                        self.widgets.iconButton({
+                                            'label': 'arrow_forward',
+                                            "styleClass": "mdc-button--outlined",
+                                        // self.widgets.buttonStroked(
+                                        //     {
+                                        //         "label": "Do It",
                                                 "onclick": function (e) {
                                                     let editor = document.querySelector("#aceEditor").env.editor;
                                                     codeEditorDoit.call(self, editor, this._editorNode);
@@ -2630,17 +2685,48 @@ define([
                                 {
 
                                     $type: "div",
-                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-3",
+                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1 tooltip",
                                     $components: [
-                                        self.widgets.buttonStroked(
-                                            {
-                                                "label": "Print It",
+                                        {
+                                            class: "tooltiptext",
+                                            $type: "span",
+                                            $text: "Print It"
+                                        },
+                                        self.widgets.iconButton({
+                                            'label': 'details',
+                                            "styleClass": "mdc-button--outlined",
+                                        // self.widgets.buttonStroked(
+                                        //     {
+                                        //         "label": "Print It",
                                                 "onclick": function (e) {
                                                     let editor = document.querySelector("#aceEditor").env.editor;
                                                     codeEditorPrintit.call(self, editor, this._editorNode);
                                                 }
                                             })
                                     ]
+                                },
+                                {
+
+                                    $type: "div",
+                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1 tooltip",
+                                    $components: [
+                                        {
+                                            class: "tooltiptext",
+                                            $type: "span",
+                                            $text: "Print It on Console"
+                                        },
+                                        self.widgets.iconButton({
+                                            'label': 'code',
+                                            "styleClass": "mdc-button--outlined",
+                                        // self.widgets.buttonStroked(
+                                        //     {
+                                        //         "label": "Print It on Console",
+                                                "onclick": function (e) {
+                                                    let editor = document.querySelector("#aceEditor").env.editor;
+                                                    codeEditorPrintitInDebugger.call(self, editor, this._editorNode);
+                                                }
+                                            })
+                                    ]
                                 }
 
                             ]
@@ -4103,6 +4189,22 @@ define([
 
     }
 
+    function codeEditorPrintitInDebugger(editor, nodeID) {
+        var selectedText = editor.getSession().doc.getTextRange(editor.selection.getRange());
+
+        if (selectedText == "") {
+
+            var currline = editor.getSelectionRange().start.row;
+            var selectedText = editor.session.getLine(currline);
+
+        }
+
+        let scriptText = 'console.log(' + selectedText + ');'
+        self.kernel.execute(nodeID, scriptText);
+
+
+    }
+
     function codeEditorPrintit(editor, nodeID) {
         var selectedText = editor.getSession().doc.getTextRange(editor.selection.getRange());
 

+ 6 - 4
public/vwf/view/lib/editorLive.css

@@ -191,13 +191,15 @@
         padding: 5px 0;
         
         /* Position the tooltip */
-        position: absolute;
+        position: fixed;
         z-index: 1;
-        bottom: 100%;
+        margin-top: -40px;
+        /* bottom: 100%;
         left: 50%; 
-        margin-left: -50px; 
+        margin-left: -50px; */
     }
     
     .tooltip:hover .tooltiptext {
         visibility: visible;
-    }
+    }
+