Nikolay Suslov 4 vuotta sitten
vanhempi
commit
0b19eba469
5 muutettua tiedostoa jossa 776 lisäystä ja 1040 poistoa
  1. 276 432
      public/app.js
  2. 4 4
      public/vwf/view/aframe.js
  3. 8 8
      public/vwf/view/editor-new.js
  4. 379 438
      public/web/index-app.js
  5. 109 158
      public/web/world-app.js

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 276 - 432
public/app.js


+ 4 - 4
public/vwf/view/aframe.js

@@ -936,9 +936,9 @@ define(["module", "vwf/view"], function (module, view) {
            if (!self.state.nodes[avatarName]) {
               
 
-               if (_LCSUSER.is) {
+               if (_LCSDB.user().is) {
 
-                   _LCSUSER.get('profile').get('alias').once(alias => {
+                _LCSDB.user().get('profile').get('alias').once(alias => {
                            if (alias){
 
                                newNode.properties.displayName = alias;
@@ -947,11 +947,11 @@ define(["module", "vwf/view"], function (module, view) {
                            vwf_view.kernel.createChild(nodeID, avatarName, newNode);
                            });
 
-                           _LCSUSER.get('profile').get('avatarNode').not(res=>{
+                           _LCSDB.user().get('profile').get('avatarNode').not(res=>{
                                //vwf_view.kernel.callMethod(avatarName, "createAvatarBody", []);
                            })
 
-                               _LCSUSER.get('profile').get('avatarNode').once(res => {
+                           _LCSDB.user().get('profile').get('avatarNode').once(res => {
                                    var myNode = null;
                                    if (res) {
                                        //myNode = JSON.parse(res.avatarNode);

+ 8 - 8
public/vwf/view/editor-new.js

@@ -473,7 +473,7 @@ define([
 
             var saveAvatar = {};
             var loadAvatar = {};
-            if (_LCSUSER.is) {
+            if (_LCSDB.user().is) {
                 saveAvatar = self.widgets.floatActionButton({
                     label: "save",
                     styleClass: "mdc-fab--mini",
@@ -484,7 +484,7 @@ define([
                         let nodeDef = self.helpers.getNodeDef(nodeID).children.avatarNode;
                         console.log(nodeDef);
 
-                        _LCSUSER.get('profile').get('avatarNode').put(JSON.stringify(nodeDef), acc => {
+                        _LCSDB.user().get('profile').get('avatarNode').put(JSON.stringify(nodeDef), acc => {
                             console.log("saved: " + acc)
                         });
 
@@ -498,7 +498,7 @@ define([
                     styleClass: "mdc-fab--mini",
                     onclickfunc: function () {
                         let nodeID = 'avatar-' + self.kernel.moniker();
-                        _LCSUSER.get('profile').get('avatarNode').once(res => {
+                        _LCSDB.user().get('profile').get('avatarNode').once(res => {
                             if (res) {
                                 var myNode = res;
 
@@ -1007,8 +1007,8 @@ define([
 
                     let worldOwner = self.helpers.getRoot(false).root.split('/')[0];
 
-                    if (_LCSUSER.is) {
-                        if (worldOwner == _LCSUSER.is.alias) {
+                    if (_LCSDB.user().is) {
+                        if (worldOwner == _LCSDB.user().is.alias) {
 
                             userGUI.push(
                                 {
@@ -1086,8 +1086,8 @@ define([
 
                                                 let worldOwner = self.helpers.getRoot(false).root.split('/')[0];
 
-                                                if (_LCSUSER.is) {
-                                                    if (worldOwner == _LCSUSER.is.alias) {
+                                                if (_LCSDB.user().is) {
+                                                    if (worldOwner == _LCSDB.user().is.alias) {
                                                         _app.saveStateAsFile(fileName.value);
                                                     } else {
                                                         console.log('clone world with prototype to: ' + fileName);
@@ -1823,7 +1823,7 @@ define([
 
             var saveGUI = {};
 
-            if (_LCSUSER.is) {
+            if (_LCSDB.user().is) {
                 saveGUI = self.widgets.floatActionButton({
                     label: "save",
                     styleClass: "mdc-fab--mini",

+ 379 - 438
public/web/index-app.js

@@ -84,16 +84,16 @@ class IndexApp {
 
 
         //if(this.entry !== 'index'){
-            import('/web/header.js').then(res => {
-                let gui = new res.Header();
-                gui.init();
-              })
-       // }
+        import('/web/header.js').then(res => {
+            let gui = new res.Header();
+            gui.init();
+        })
+        // }
 
-       import('/web/footer.js').then(res => {
-        let gui = new res.Footer();
-        gui.init();
-      })
+        import('/web/footer.js').then(res => {
+            let gui = new res.Footer();
+            gui.init();
+        })
 
 
 
@@ -142,11 +142,10 @@ class IndexApp {
             $init: function () {
                 //this._status = "Welcome!"
                 //this._status = 'Welcome!';
-                //userEl.style.backgroundColor = '#e6e6e6';  
-                self.initUser(); 
+                self.initUser();
                 this._refresh(); //$update();
             },
-            $update: function () {},
+            $update: function () { },
             _refresh: function () {
 
                 var gui = {};
@@ -159,8 +158,6 @@ class IndexApp {
                                 "onclick": function (e) {
                                     _LCSDB.user().leave();
                                     setTimeout(() => {
-                                        //window.sessionStorage.removeItem('alias');
-                                        //window.sessionStorage.removeItem('tmp');
                                         window.location.reload(true);
                                     }, 1);
 
@@ -223,8 +220,8 @@ class IndexApp {
             $type: "div",
             $components: [],
             _comps: [],
-            _refresh: function(){
-                this.$components = this._comps.concat([userGUI,  _app.widgets.getLoginGUI(), _app.widgets.divider, self.getLookWorlds()]);
+            _refresh: function () {
+                this.$components = this._comps.concat([userGUI, _app.widgets.getLoginGUI(), _app.widgets.divider, self.getLookWorlds()]);
             },
             $init: function () {
                 //this._comps = self.initUserGUI()
@@ -244,16 +241,16 @@ class IndexApp {
 
         var worlds = {};
 
-        if(userPub) {
-        worlds = this.createWorldsGUI('proto', userAlias, userPub) 
+        if (userPub) {
+            worlds = this.createWorldsGUI('proto', userAlias, userPub)
         } else {
 
-        worlds = {
-            $type: 'div',
-            $text:  'Could not find user with name: ' + userAlias,
-            class: "mdc-typography--headline4"
+            worlds = {
+                $type: 'div',
+                $text: 'Could not find user with name: ' + userAlias,
+                class: "mdc-typography--headline4"
+            }
         }
-    }
 
         let components = [
             {
@@ -287,7 +284,7 @@ class IndexApp {
         ];
 
         doc._refresh(components);
-   
+
     }
 
     async allWorldsStatesForUser(userAlias, worldName, elID) {
@@ -295,66 +292,63 @@ class IndexApp {
         let userPub = await _app.helpers.getUserPub(userAlias);
         //let db = _LCSDB.user(userPub);
 
-        let doc = elID ? document.querySelector("#" + elID): document.querySelector("#worldsGUI");
+        let doc = elID ? document.querySelector("#" + elID) : document.querySelector("#worldsGUI");
 
         var worlds = {};
 
-        if(userPub) {
-            if(!worldName){
-                worlds = this.createWorldsGUI('state', userAlias, userPub) 
+        if (userPub) {
+            if (!worldName) {
+                worlds = this.createWorldsGUI('state', userAlias, userPub)
             } else {
-                worlds = this.createWorldsGUI('state', userAlias, userPub, worldName) 
+                worlds = this.createWorldsGUI('state', userAlias, userPub, worldName)
             }
-        
+
         } else {
 
-        worlds = {
-            $type: 'div',
-            $text:  'Could not find user with name: ' + userAlias,
-            class: "mdc-typography--headline4"
+            worlds = {
+                $type: 'div',
+                $text: 'Could not find user with name: ' + userAlias,
+                class: "mdc-typography--headline4"
+            }
         }
-    }
 
-    let components = [
-        {
-            $type: "div",
-            class: "mdc-layout-grid",
-            $components: [
-                {
-                    $type: "div",
-                    class: "mdc-layout-grid__inner",
-                    $components: [
-                        {
-                            $type: "div",
-                            class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
-                            $components: [
-                                {
-                                    $type: "h1",
-                                    class: "mdc-typography--headline4",
-                                    $text: 'States for ' + userAlias
-                                }
-                            ]
-                        },
-                        {
-                            $type: "div",
-                            class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
-                            $components: [].concat(worlds)
-                        }
-                    ]
-                }
-            ]
-        }
-    ]
+        let components = [
+            {
+                $type: "div",
+                class: "mdc-layout-grid",
+                $components: [
+                    {
+                        $type: "div",
+                        class: "mdc-layout-grid__inner",
+                        $components: [
+                            {
+                                $type: "div",
+                                class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
+                                $components: [
+                                    {
+                                        $type: "h1",
+                                        class: "mdc-typography--headline4",
+                                        $text: 'States for ' + userAlias
+                                    }
+                                ]
+                            },
+                            {
+                                $type: "div",
+                                class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
+                                $components: [].concat(worlds)
+                            }
+                        ]
+                    }
+                ]
+            }
+        ]
 
         doc._refresh(components);
-   
-    }
-
-
 
+    }
 
 
-    authGUI(){
+    authGUI() {
 
         let alias = _LCSDB.user().is.alias;
         let userEl = document.querySelector('#userGUI');
@@ -392,16 +386,16 @@ class IndexApp {
             type: 'success'
         }).show();
 
-        if(this.entry == 'index'){
+        if (this.entry == 'index') {
             //change for LiveCoding.space to 'app'
-           //this.initWorldsProtosListForUserNew(alias);
-           this.allWorldsProtosForUser(alias)
+            //this.initWorldsProtosListForUserNew(alias);
+            this.allWorldsProtosForUser(alias)
         }
 
-       
 
 
-        
+
+
     }
 
 
@@ -409,7 +403,7 @@ class IndexApp {
     initUser() {
         let self = this;
 
-        if(_LCSDB.user().is) {
+        if (_LCSDB.user().is) {
             self.authGUI()
         } else {
             _LCSDB.on('auth', function (ack) {
@@ -421,12 +415,12 @@ class IndexApp {
             });
         }
 
-       
+
     }
 
-    getLookWorlds(){
+    getLookWorlds() {
         let self = this;
-        let lookWorlds = 
+        let lookWorlds =
         {
             $type: "div",
             id: "lookWorlds",
@@ -479,34 +473,34 @@ class IndexApp {
                                 //         self.initWorldsStatesListForUser(searchName);
                                 //     }
                                 // }
-                    _app.widgets.buttonRaised(
-                        {
-                            "label": 'World Protos',
-                            "onclick": function (e) {
-                                e.preventDefault();
-                                //page("/app/worlds/protos")
-                                let searchName = this._userNameField.value;
-                                if(searchName !== "")
-                                    window.location.pathname = "/"+searchName+"/worlds/protos"
-                                //_app.indexApp.getAppDetailsFromDefaultDB('protos');
+                                _app.widgets.buttonRaised(
+                                    {
+                                        "label": 'World Protos',
+                                        "onclick": function (e) {
+                                            e.preventDefault();
+                                            //page("/app/worlds/protos")
+                                            let searchName = this._userNameField.value;
+                                            if (searchName !== "")
+                                                window.location.pathname = "/" + searchName + "/worlds/protos"
+                                            //_app.indexApp.getAppDetailsFromDefaultDB('protos');
 
-                            }
-                        }), 
-                        _app.widgets.space,
-                    _app.widgets.buttonRaised(
-                        {
-                            "label": 'World States',
-                            "onclick": function (e) {
-                                e.preventDefault();
-                                //page("/app/worlds/states")
-                                let searchName = this._userNameField.value;
-                                if(searchName !== "")
-                                    window.location.pathname = "/"+searchName+"/worlds/states"
-                                //_app.indexApp.getAppDetailsFromDefaultDB('states');
+                                        }
+                                    }),
+                                _app.widgets.space,
+                                _app.widgets.buttonRaised(
+                                    {
+                                        "label": 'World States',
+                                        "onclick": function (e) {
+                                            e.preventDefault();
+                                            //page("/app/worlds/states")
+                                            let searchName = this._userNameField.value;
+                                            if (searchName !== "")
+                                                window.location.pathname = "/" + searchName + "/worlds/states"
+                                            //_app.indexApp.getAppDetailsFromDefaultDB('states');
+
+                                        }
+                                    })
 
-                            }
-                        })
-                               
                             ]
                     },
                     // window._app.widgets.buttonStroked(
@@ -705,261 +699,229 @@ class IndexApp {
             $init: function () {
                 this._worldName = worldName;
 
-                    if(type == 'min') {
-                        if(worldType == 'proto') {
+                if (type == 'min') {
+                    if (worldType == 'proto') {
 
-                            db.get('worlds').get(this._worldName).path('info_json').on((res)=>{
-                                if(res){
+                        db.get('worlds').get(this._worldName).path('info_json').on((res) => {
+                            if (res) {
+
+                                if (res.file) {
+                                    let doc = {
+                                        'worldName': this._worldName,
+                                        'created': undefined,
+                                        'modified': undefined,
+                                        'type': 'proto',
+                                        'userAlias': userAlias,
+                                        'info': { title: 'Need to repair!' }
+                                    }
+                                    this._refresh(doc);
+                                    return
+                                }
+
+                                console.log(res);
+
+                                let worldDesc = JSON.parse(res);
+
+                                let root = Object.keys(worldDesc)[0];
+                                var appInfo = worldDesc[root]['en'];
+
+                                let langID = localStorage.getItem('krestianstvo_locale');
+                                if (langID) {
+                                    appInfo = worldDesc[root][langID]
+                                }
 
-                            if(res.file){
                                 let doc = {
                                     'worldName': this._worldName,
                                     'created': undefined,
                                     'modified': undefined,
                                     'type': 'proto',
                                     'userAlias': userAlias,
-                                    'info': {title:'Need to repair!'}
-                                  }
-                                  this._refresh(doc);
-                                  return
-                            }        
-
-                                console.log(res);
-    
-                               let worldDesc = JSON.parse(res);
-                            
-                               let root = Object.keys(worldDesc)[0];
-                               var appInfo = worldDesc[root]['en'];
-                   
-                               let langID = localStorage.getItem('krestianstvo_locale');
-                               if (langID) {
-                                 appInfo = worldDesc[root][langID]
-                               }
-    
-                               let doc = {
-                                  'worldName': this._worldName,
-                                  'created': undefined,
-                                  'modified': undefined,
-                                  'type': 'proto',
-                                  'userAlias': userAlias,
-                                  'info': appInfo
+                                    'info': appInfo
                                 }
                                 this._refresh(doc);
-       
+
                                 //callback
-                                if(cb)
-                                   cb(doc);
+                                if (cb)
+                                    cb(doc);
                             }
-                            })
-                        } else if (worldType == 'state'){
-                            let pathName = 'savestate_/' + this._worldName.protoName+ '/' + this._worldName.stateName + '_info_vwf_json';
-                            db.get('documents').get(this._worldName.protoName).path(pathName).on((res)=>{
-
-                                if(res){
-                                
-                                    if(res.file){
-                                        let doc = {
-                                            'worldName': this._worldName.protoName + '/load/' + this._worldName.stateName,
-                                            'created': undefined,
-                                            'modified': undefined,
-                                            'type': 'state',
-                                            'userAlias': userAlias,
-                                            'info': {title:'Need to repair!'}
-                                          }
-                                          this._refresh(doc);
-                                          return
-                                    }        
+                        })
+                    } else if (worldType == 'state') {
+                        let pathName = 'savestate_/' + this._worldName.protoName + '/' + this._worldName.stateName + '_info_vwf_json';
+                        db.get('documents').get(this._worldName.protoName).path(pathName).on((res) => {
 
+                            if (res) {
 
-                                console.log(res);
-    
-                               let worldDesc = JSON.parse(res);
-                            
-                               let root = Object.keys(worldDesc)[0];
-                               var appInfo = worldDesc[root]['en'];
-                   
-                               let langID = localStorage.getItem('krestianstvo_locale');
-                               if (langID) {
-                                 appInfo = worldDesc[root][langID]
-                               }
-    
-                               let doc = {
-                                  'worldName': this._worldName.protoName + '/load/' + this._worldName.stateName,
-                                  'created': undefined,
-                                  'modified': undefined,
-                                  'type': 'saveState',
-                                  'userAlias': userAlias,
-                                  'info': appInfo
+                                if (res.file) {
+                                    let doc = {
+                                        'worldName': this._worldName.protoName + '/load/' + this._worldName.stateName,
+                                        'created': undefined,
+                                        'modified': undefined,
+                                        'type': 'state',
+                                        'userAlias': userAlias,
+                                        'info': { title: 'Need to repair!' }
+                                    }
+                                    this._refresh(doc);
+                                    return
                                 }
-                                this._refresh(doc);
-       
-                                //callback
-                                if(cb)
-                                   cb(doc);
-                            }
-                            })
 
-                        }
-                     
 
+                                console.log(res);
+
+                                let worldDesc = JSON.parse(res);
 
-                    } else if (type == 'full'){
+                                let root = Object.keys(worldDesc)[0];
+                                var appInfo = worldDesc[root]['en'];
 
-                if(worldType == 'proto') {
-                     db.get('worlds').get(this._worldName).on((res)=>{
-                         if(res){
+                                let langID = localStorage.getItem('krestianstvo_locale');
+                                if (langID) {
+                                    appInfo = worldDesc[root][langID]
+                                }
 
-                            if(res["info_json"]['#']){
                                 let doc = {
-                                    'worldName': this._worldName,
+                                    'worldName': this._worldName.protoName + '/load/' + this._worldName.stateName,
                                     'created': undefined,
                                     'modified': undefined,
-                                    'type': 'proto',
+                                    'type': 'saveState',
                                     'userAlias': userAlias,
-                                    'info': {title:'Need to repair!'}
-                                  }
-                                  this._refresh(doc);
-                                //   if(cb)
-                                //     cb(doc);
+                                    'info': appInfo
+                                }
+                                this._refresh(doc);
 
-                                  return
-                            }        
+                                //callback
+                                if (cb)
+                                    cb(doc);
+                            }
+                        })
 
+                    }
 
 
-                         console.log(res);
 
-                        let worldDesc = JSON.parse(res['info_json']);
-                        
-            
-                        let root = Object.keys(worldDesc)[0];
-                        var appInfo = worldDesc[root]['en'];
-            
-                        let langID = localStorage.getItem('krestianstvo_locale');
-                        if (langID) {
-                          appInfo = worldDesc[root][langID]
-                        }
-            
-                        let settings = worldDesc[root]['settings'];
-
-
-                        let doc = {
-                           'worldName': this._worldName,
-                           'created': res.created ? res.created : "",
-                           'modified': res.modified ? res.modified : "",
-                           'proxy': res.proxy,
-                           'type': 'proto',
-                           'userAlias': userAlias,
-                           'info': appInfo,
-                           'settings': settings
-                         }
-                         this._refresh(doc);
-
-                         //callback
-                         if(cb)
-                            cb(doc);
-                        } else {
-                            //no world
-                            this._refresh({})
-                        }
-                     })
+                } else if (type == 'full') {
+
+                    if (worldType == 'proto') {
+                        db.get('worlds').get(this._worldName).on((res) => {
+                            if (res) {
+
+                                if (res["info_json"]['#']) {
+                                    let doc = {
+                                        'worldName': this._worldName,
+                                        'created': undefined,
+                                        'modified': undefined,
+                                        'type': 'proto',
+                                        'userAlias': userAlias,
+                                        'info': { title: 'Need to repair!' }
+                                    }
+                                    this._refresh(doc);
+                                    //   if(cb)
+                                    //     cb(doc);
+
+                                    return
+                                }
+
+
+
+                                console.log(res);
+
+                                let worldDesc = JSON.parse(res['info_json']);
+
+
+                                let root = Object.keys(worldDesc)[0];
+                                var appInfo = worldDesc[root]['en'];
+
+                                let langID = localStorage.getItem('krestianstvo_locale');
+                                if (langID) {
+                                    appInfo = worldDesc[root][langID]
+                                }
+
+                                let settings = worldDesc[root]['settings'];
+
+
+                                let doc = {
+                                    'worldName': this._worldName,
+                                    'created': res.created ? res.created : "",
+                                    'modified': res.modified ? res.modified : "",
+                                    'proxy': res.proxy,
+                                    'type': 'proto',
+                                    'userAlias': userAlias,
+                                    'info': appInfo,
+                                    'settings': settings
+                                }
+                                this._refresh(doc);
+
+                                //callback
+                                if (cb)
+                                    cb(doc);
+                            } else {
+                                //no world
+                                this._refresh({})
+                            }
+                        })
 
                     } else if (worldType == 'state') {
 
-                        let pathNameInfo = 'savestate_/' + this._worldName.protoName+ '/' + this._worldName.stateName + '_info_vwf_json';
-                        db.get('documents').get(this._worldName.protoName).path(pathNameInfo).on((res)=>{
-                            if(res){
+                        let pathNameInfo = 'savestate_/' + this._worldName.protoName + '/' + this._worldName.stateName + '_info_vwf_json';
+                        db.get('documents').get(this._worldName.protoName).path(pathNameInfo).on((res) => {
+                            if (res) {
 
-                                if(res.file){
+                                if (res.file) {
                                     let doc = {
                                         'worldName': this._worldName.protoName + '/load/' + this._worldName.stateName,
                                         'created': undefined,
                                         'modified': undefined,
                                         'type': 'state',
                                         'userAlias': userAlias,
-                                        'info': {title:'Need to repair!'}
-                                      }
-                                      this._refresh(doc);
-                                      return
-                                }        
-
-                            
-                            console.log(res);
-                           let worldDesc = JSON.parse(res);
-                        
-                           let root = Object.keys(worldDesc)[0];
-                           var appInfo = worldDesc[root]['en'];
-               
-                           let langID = localStorage.getItem('krestianstvo_locale');
-                           if (langID) {
-                             appInfo = worldDesc[root][langID]
-                           }
-
-                           let settings = worldDesc[root]['settings'];
-
-                           let doc = {
-                              'worldName': this._worldName.protoName + '/load/' + this._worldName.stateName,
-                              'created': undefined,
-                              'modified': undefined,
-                              'type': 'saveState',
-                              'userAlias': userAlias,
-                              'info': appInfo,
-                              'settings': settings
-                            }
-                            this._refresh(doc);
-   
-                            //callback
-                            if(cb)
-                               cb(doc);
-                        } else {
-                            //no world
-                            this._refresh({})
-                        }
-                        })
+                                        'info': { title: 'Need to repair!' }
+                                    }
+                                    this._refresh(doc);
+                                    return
+                                }
 
-                        // let pathNameState = 'savestate_/' + this._worldName.protoName+ '/' + this._worldName.stateName + '_vwf_json';
-                        // db.get('documents').get(this._worldName.protoName).path(pathNameState).on((res)=>{
-                        //     console.log(res);
-                        // //    let worldDesc = JSON.parse(res);
-                        
-                        // //    let root = Object.keys(worldDesc)[0];
-                        // //    var appInfo = worldDesc[root]['en'];
-               
-                        // //    let langID = localStorage.getItem('krestianstvo_locale');
-                        // //    if (langID) {
-                        // //      appInfo = worldDesc[root][langID]
-                        // //    }
-
-                        //    let settings = worldDesc[root]['settings'];
-
-                        //    let doc = {
-                        //       'worldName': this._worldName.protoName + '/load/' + this._worldName.stateName,
-                        //       'created': res.created,
-                        //       'modified': res.modified,
-                        //       'type': 'saveState',
-                        //       'userAlias': userAlias,
-                        //       'info': appInfo,
-                        //       'settings': settings
-                        //     }
-                        //     this._refresh(doc);
-   
-                        //     //callback
-                        //     if(cb)
-                        //        cb(doc);
-                        // })
 
+                                console.log(res);
+                                let worldDesc = JSON.parse(res);
 
-                    }
+                                let root = Object.keys(worldDesc)[0];
+                                var appInfo = worldDesc[root]['en'];
 
+                                let langID = localStorage.getItem('krestianstvo_locale');
+                                if (langID) {
+                                    appInfo = worldDesc[root][langID]
+                                }
+
+                                let settings = worldDesc[root]['settings'];
+
+                                let doc = {
+                                    'worldName': this._worldName.protoName + '/load/' + this._worldName.stateName,
+                                    'created': undefined,
+                                    'modified': undefined,
+                                    'type': 'saveState',
+                                    'userAlias': userAlias,
+                                    'info': appInfo,
+                                    'settings': settings
+                                }
+                                this._refresh(doc);
+
+                                //callback
+                                if (cb)
+                                    cb(doc);
+                            } else {
+                                //no world
+                                this._refresh({})
+                            }
+                        })
 
                     }
+
+
+                }
             },
             $update: function () {
-                 //this.$components = [this._updateCard()]
+                //this.$components = [this._updateCard()]
             },
             _updateComps: function () {
                 //console.log(this._worldInfo);
-               
+
             },
             _updateCard: function () {
                 let desc = this._worldInfo;
@@ -995,7 +957,7 @@ class IndexApp {
                     });
                 }
 
-                if(desc.info.title !== 'Need to repair!'){
+                if (desc.info.title !== 'Need to repair!') {
                     userGUI.push({
                         $type: "a",
                         class: "mdc-button mdc-button--raised mdc-card__action ",
@@ -1005,13 +967,13 @@ class IndexApp {
                         onclick: function (e) {
                             self.checkForManualSettings();
                             window.location.pathname = "/" + desc.userAlias + '/' + desc.worldName
-    
+
                             //self.refresh();
                         }
                     });
-                } 
-                    
-                
+                }
+
+
 
                 let protoID = {}
 
@@ -1020,26 +982,26 @@ class IndexApp {
 
                     let protoIDComp = {
 
-                     $type: 'div',
-                     $components: [
+                        $type: 'div',
+                        $components: [
 
-                    {
-                        $type: "span",
-                        class: "mdc-card__subtitle mdc-theme--text-secondary-on-background",
-                        $text: 'proto: '
-                    },
-                    {
-                        $type: "input",
-                        type: "text",
-                        disabled: "",
-                        style: "font-size:18px",
-                        value: desc.worldName.split('/')[0]
+                            {
+                                $type: "span",
+                                class: "mdc-card__subtitle mdc-theme--text-secondary-on-background",
+                                $text: 'proto: '
+                            },
+                            {
+                                $type: "input",
+                                type: "text",
+                                disabled: "",
+                                style: "font-size:18px",
+                                value: desc.worldName.split('/')[0]
+                            }
+                        ]
                     }
-                ]
-            }
 
-                Object.assign(protoID, protoIDComp)
-                    
+                    Object.assign(protoID, protoIDComp)
+
                 }
 
                 if (desc.type == 'proto') {
@@ -1070,7 +1032,7 @@ class IndexApp {
 
                 online.push(onlineGUI);
 
-                if(!desc.info){
+                if (!desc.info) {
                     desc.info = {
                         imgUrl: "/defaults/worlds/webrtc/webimg.jpg",
                         text: "..no text",
@@ -1170,9 +1132,9 @@ class IndexApp {
 
         let db = _LCSDB.user(userPub);
 
-       var headerText = 'Worlds';
+        var headerText = 'Worlds';
 
-        if(worldType == 'state' && !worldName){
+        if (worldType == 'state' && !worldName) {
             headerText = 'All World States for ' + userAlias;
         } else {
             headerText = worldName ? 'States for ' + worldName : 'All Worlds Protos'
@@ -1194,133 +1156,112 @@ class IndexApp {
             $init: function () {
 
                 console.log('init lab...');
-                if(worldType == 'proto'){
+                if (worldType == 'proto') {
                     db.get('worlds')
-                    .map()
-                    .on((res,k)=>{
-                        console.log('From world: ', k);
-                        //let doc = document.querySelector('#'+ k);
-                        if(res){
-
-                       let cardID = userAlias + '_' + k;
-                       let doc = this._cards.filter(el=> el.$components[0].id == 'worldCard_'+ cardID)[0];
-       
-                        if(!doc) {
-                            doc = this._makeWorldCard(k, cardID);
-                            this._cards.push(doc);
-                        } 
-                    }
-       
-
-                    })
-                } else if(worldType == 'state') {
-                //get states
-
-                if(!worldName) {
-                    console.log('get states');
-                db.get('documents')
-                    .map()
-                    .on((res,k)=>{
-                        if( k !== 'id'){
+                        .map()
+                        .on((res, k) => {
                             console.log('From world: ', k);
+                            //let doc = document.querySelector('#'+ k);
+                            if (res) {
 
-                            let worldStatesInfo = Object.entries(res).filter(el=>el[0].includes('_info_vwf_json'));
-                            worldStatesInfo.map(el=>{
-                               
-                                let saveName = el[0].split('/')[2].replace('_info_vwf_json', "");
-
-                                let stateEntry = 'savestate_/' + k + '/' + saveName + '_vwf_json';
-                                    if (res[stateEntry]) {
-
-                                let cardID = userAlias + '_' + saveName + '_' + k;
-                                console.log(cardID, ' - ', el);
+                                let cardID = userAlias + '_' + k;
+                                let doc = this._cards.filter(el => el.$components[0].id == 'worldCard_' + cardID)[0];
 
-                                let doc = this._cards.filter(el=> el.$components[0].id == 'worldCard_'+ cardID)[0];
-       
-                                if(!doc) {
-                                    doc = this._makeWorldCard({protoName: k, stateName: saveName}, cardID);
+                                if (!doc) {
+                                    doc = this._makeWorldCard(k, cardID);
                                     this._cards.push(doc);
-                                } 
+                                }
                             }
 
+
+                        })
+                } else if (worldType == 'state') {
+                    //get states
+
+                    if (!worldName) {
+                        console.log('get states');
+                        db.get('documents')
+                            .map()
+                            .on((res, k) => {
+                                if (k !== 'id') {
+                                    console.log('From world: ', k);
+
+                                    let worldStatesInfo = Object.entries(res).filter(el => el[0].includes('_info_vwf_json'));
+                                    worldStatesInfo.map(el => {
+
+                                        let saveName = el[0].split('/')[2].replace('_info_vwf_json', "");
+
+                                        let stateEntry = 'savestate_/' + k + '/' + saveName + '_vwf_json';
+                                        if (res[stateEntry]) {
+
+                                            let cardID = userAlias + '_' + saveName + '_' + k;
+                                            console.log(cardID, ' - ', el);
+
+                                            let doc = this._cards.filter(el => el.$components[0].id == 'worldCard_' + cardID)[0];
+
+                                            if (!doc) {
+                                                doc = this._makeWorldCard({ protoName: k, stateName: saveName }, cardID);
+                                                this._cards.push(doc);
+                                            }
+                                        }
+
+                                    })
+                                    //let saveName = el.stateName.split('/')[2].replace('_info_vwf_json', "");
+
+                                }
+
                             })
-                            //let saveName = el.stateName.split('/')[2].replace('_info_vwf_json', "");
 
-                        }
-                       
-                        //let doc = document.querySelector('#'+ k);
-                    //    let doc = this._cards.filter(el=> el.$components[0].id == 'worldCard_'+ userAlias + '_' + k)[0];
-       
-                    //     if(!doc) {
-                    //         doc = this._makeWorldCard(k);
-                    //         this._cards.push(doc);
-                    //     } 
-       
-                    })
+                    } else {
 
-                } else {
+                        console.log('get states for ' + worldName);
+                        db.get('documents')
+                            .map((res, k) => { if (k == worldName) return res })
+                            .on((res, k) => {
+                                if (k !== 'id') {
+
+                                    console.log('From world: ', k);
+
+                                    let worldStatesInfo = Object.entries(res).filter(el => el[0].includes('_info_vwf_json'));
+                                    worldStatesInfo.map(el => {
+
+
+
+                                        let saveName = el[0].split('/')[2].replace('_info_vwf_json', "");
 
-                    console.log('get states for ' + worldName);
-                    db.get('documents')
-                        .map((res, k) => {if (k == worldName) return res})
-                        .on((res,k)=>{
-                            if( k !== 'id'){
-                              
-                                console.log('From world: ', k);
-    
-                                let worldStatesInfo = Object.entries(res).filter(el=>el[0].includes('_info_vwf_json'));
-                                worldStatesInfo.map(el=>{
-                                   
-                                  
-
-                                    let saveName = el[0].split('/')[2].replace('_info_vwf_json', "");
-
-                                    let stateEntry = 'savestate_/' + k + '/' + saveName + '_vwf_json';
-                                    if (res[stateEntry]) {
-
-                                    let cardID = userAlias + '_' + saveName + '_' + k;
-                                    console.log(cardID, ' - ', el);
-    
-                                    let doc = this._cards.filter(el=> el.$components[0].id == 'worldCard_'+ cardID)[0];
-           
-                                    if(!doc) {
-                                        doc = this._makeWorldCard({protoName: k, stateName: saveName}, cardID);
-                                        this._cards.push(doc);
-                                    } 
+                                        let stateEntry = 'savestate_/' + k + '/' + saveName + '_vwf_json';
+                                        if (res[stateEntry]) {
+
+                                            let cardID = userAlias + '_' + saveName + '_' + k;
+                                            console.log(cardID, ' - ', el);
+
+                                            let doc = this._cards.filter(el => el.$components[0].id == 'worldCard_' + cardID)[0];
+
+                                            if (!doc) {
+                                                doc = this._makeWorldCard({ protoName: k, stateName: saveName }, cardID);
+                                                this._cards.push(doc);
+                                            }
+
+                                        }
+
+
+                                    })
+                                    //let saveName = el.stateName.split('/')[2].replace('_info_vwf_json', "");
 
                                 }
+                            })
 
-    
-                                })
-                                //let saveName = el.stateName.split('/')[2].replace('_info_vwf_json', "");
-    
-                            }
-                            
-                           
-                            //let doc = document.querySelector('#'+ k);
-                        //    let doc = this._cards.filter(el=> el.$components[0].id == 'worldCard_'+ userAlias + '_' + k)[0];
-           
-                        //     if(!doc) {
-                        //         doc = this._makeWorldCard(k);
-                        //         this._cards.push(doc);
-                        //     } 
-           
-                        })
 
+                    }
 
                 }
 
-                }
-             
 
                 //this._refresh();
             },
             _makeWorldCard: function (worldID, cardID) {
                 //let cardID = userAlias + '_' + worldID//data[1].userAlias + '_' + data[1].worldName + '_' + data[0];
                 let card = self.createWorldCard(worldType, userAlias, userPub, worldID, cardID, 'min');
-                //card._refresh(data[1]);
-                //card._worldInfo = data[1];
-                //card._updateComps();
                 return {
                     $cell: true,
                     $type: "div",

+ 109 - 158
public/web/world-app.js

@@ -76,7 +76,7 @@ class WorldApp {
                 }
                 //console.log(data);
             },
-            $update: function(){},
+            $update: function () { },
             _updateComps: function () {
                 this.$components = [
                     {
@@ -127,12 +127,12 @@ class WorldApp {
         let space = this.worldName;
         let saveName = this.saveName;
 
-       
+
 
         let cardID = user.user + '_' + space + '_' + (saveName ? saveName : "");
         let cardWorldType = saveName ? 'state' : 'proto';
 
-        let worldNameInfo = saveName ? {protoName: space, stateName: saveName} : space
+        let worldNameInfo = saveName ? { protoName: space, stateName: saveName } : space
 
         let worldCardGUI = _app.indexApp.createWorldCard(cardWorldType, this.userAlias, userPub, worldNameInfo, cardID, "full", setWorldParameters); //createWorldCard(userAlias, userPub, worldName, id, type)
         let worldStatesGUI = [];
@@ -150,13 +150,13 @@ class WorldApp {
                 $components: [],
                 _worldInfo: {},
                 _refresh: function () {
-    
+
                     this._worldInfo = {
                         'userAlias': self.userAlias,
                         'worldName': self.saveName ? self.worldName + '/load/' + self.saveName : self.worldName,
                         'type': self.saveName ? 'saveState' : 'proto'
                     }
-    
+
                     //    let worldCard = document.querySelector('#worldCard');
                     //    if(worldCard){
                     //        this._worldInfo = worldCard._worldInfo;
@@ -168,15 +168,15 @@ class WorldApp {
                     }
                 },
                 $update: function () {
-    
+
                     let desc = this._worldInfo;
                     let userGUI = [];
-    
+
                     // if(!desc){
                     //     this.$components = [];
                     //     return
                     // }
-    
+
                     if (_LCSDB.user().is) {
                         if (_LCSDB.user().is.alias == desc.userAlias) {
                             userGUI.push(
@@ -214,11 +214,11 @@ class WorldApp {
                                         //self.refresh();
                                     }
                                 }
-    
+
                             );
-    
+
                             if (desc.type == 'proto') {
-                              
+
                                 userGUI.push(
                                     // {
                                     //     $type: "a",
@@ -229,8 +229,8 @@ class WorldApp {
                                     //         window.location.pathname = "/" + desc.userAlias + '/proto/' + desc.worldName + '/edit/index_vwf_yaml'
                                     //     }
                                     // },
-                                   
-                                       {
+
+                                    {
                                         $type: "a",
                                         class: "mdc-button ",
                                         $text: "Edit config",
@@ -239,7 +239,7 @@ class WorldApp {
                                             window.location.pathname = "/" + desc.userAlias + '/proto/' + desc.worldName + '/edit/index_vwf_config_yaml'
                                         }
                                     },
-                                    {$type: "br"},
+                                    { $type: "br" },
                                     {
                                         $type: "a",
                                         class: "mdc-button",
@@ -249,7 +249,7 @@ class WorldApp {
                                             window.location.pathname = "/" + desc.userAlias + '/proto/' + desc.worldName + '/edit/appui_js'
                                         }
                                     },
-                                   
+
                                     {
                                         $type: "a",
                                         class: "mdc-button",
@@ -268,11 +268,11 @@ class WorldApp {
                                             window.location.pathname = "/" + desc.userAlias + '/proto/' + desc.worldName + '/edit/index_vwf_html'
                                         }
                                     }
-                                
+
                                 );
-    
+
                                 userGUI.push(
-                                    {$type: "br"},
+                                    { $type: "br" },
                                     {
                                         $type: "a",
                                         class: "mdc-button mdc-button--raised mdc-card__action actionButton",
@@ -283,10 +283,10 @@ class WorldApp {
                                         }
                                     }
                                 );
-    
-    
+
+
                                 let proxyID = data.proxy;
-    
+
                                 userGUI.push(
                                     {
                                         $type: "div",
@@ -295,7 +295,7 @@ class WorldApp {
                                         _proxyNameField: null,
                                         $components:
                                             [
-      
+
                                                 window._app.widgets.inputTextFieldOutlined({
                                                     "id": 'proxyName',
                                                     "label": proxyID,
@@ -303,10 +303,10 @@ class WorldApp {
                                                     "type": "text",
                                                     "init": function () {
                                                         this._proxyNameField = new mdc.textField.MDCTextField(this);
-                                                        if(!proxyID){
+                                                        if (!proxyID) {
                                                             //document.querySelector('#proxyName').value = res;
                                                         } else {
-                                                            _app.helpers.getUserAlias(proxyID).then(res=>{
+                                                            _app.helpers.getUserAlias(proxyID).then(res => {
                                                                 document.querySelector('#proxyName').value = res;
                                                             })
                                                         }
@@ -324,20 +324,20 @@ class WorldApp {
                                                         //self.refresh();
                                                     }
                                                 }
-                                                
-                                               
+
+
                                             ]
                                     }
                                 )
-    
-    
-                                
+
+
+
                             }
-    
-    
+
+
                             if (desc.type == 'saveState') {
                                 userGUI.push(
-                                    {$type: "br"},
+                                    { $type: "br" },
                                     {
                                         $type: "a",
                                         class: "mdc-button mdc-button--raised mdc-card__action actionButton",
@@ -349,10 +349,10 @@ class WorldApp {
                                     }
                                 );
                             }
-    
-    
+
+
                         }
-    
+
                         if (desc.type == 'proto') {
                             let worldID = window._app.helpers.GenerateInstanceID().toString();
                             userGUI.push(
@@ -383,13 +383,13 @@ class WorldApp {
                                                     //self.refresh();
                                                 }
                                             }
-                                            
+
                                         ]
                                 }
                             )
                         } else if (desc.type == 'saveState') {
-    
-    
+
+
                             // userGUI.push(
                             //     {
                             //         $type: "a",
@@ -397,18 +397,18 @@ class WorldApp {
                             //         $text: "Clone",
                             //         onclick: function (e) {
                             //             //console.log('clone');
-    
+
                             //             //self.cloneWorldState(desc[0], desc[2]);
-    
+
                             //             //self.refresh();
                             //         }
                             //     })
                         }
-    
+
                     }
-    
-    
-    
+
+
+
                     this.$components = [
                         {
                             $type: "div",
@@ -417,7 +417,7 @@ class WorldApp {
                     ].concat(userGUI)
                 }
             }
-           
+
 
             document.querySelector("#aboutWorld")._actionsGUI = actionsGUI;
 
@@ -426,8 +426,8 @@ class WorldApp {
             let settings = data.settings;
             if (settings) {
                 if (settings.ar) {
-    
-                   let runWorldGUI = {
+
+                    let runWorldGUI = {
                         id: "runWorldGUI",
                         $type: "div",
                         $init: function () {
@@ -454,7 +454,7 @@ class WorldApp {
                                 for: 'input-forceReplace',
                                 $text: 'Edit mode'
                             },
-                            {$type: "div", style: "margin-top: 20px"},
+                            { $type: "div", style: "margin-top: 20px" },
                             _cellWidgets.switch({
                                 'id': 'arOnView',
                                 'init': function () {
@@ -470,21 +470,19 @@ class WorldApp {
                                 $text: 'Ar mode'
                             }
                         ]
-    
+
                     }
-    
-                document.querySelector("#aboutWorld")._runWorldGUI = runWorldGUI;
-                //document.querySelector("#aboutWorld")._refresh(worldCardGUI);
+
+                    document.querySelector("#aboutWorld")._runWorldGUI = runWorldGUI;
+                    //document.querySelector("#aboutWorld")._refresh(worldCardGUI);
                 }
             }
-    
-    
+
+
 
 
 
         }
-    
-       
 
 
         document.querySelector("#aboutWorld").$cell({
@@ -494,122 +492,75 @@ class WorldApp {
             _actionsGUI: {},
             _runWorldGUI: {},
             _worldsComps: {},
-            _refresh: function(comps){
+            _refresh: function (comps) {
                 this._worldsComps = comps
             },
-            $init: function(){
+            $init: function () {
                 //this._worldsComps = worldCardGUI; 
             },
-            $update: function(){
+            $update: function () {
                 this.$components = [
-                {
-                    $type: "div",
-                    class: "mdc-layout-grid",
-                    $components: [
-                        {
-                            $type: "div",
-                            class: "mdc-layout-grid__inner",
-                            $components: [
-                                {
-                                    $type: "div",
-                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
-                                    $components: [
-                                        {
-                                            $type: "h1",
-                                            class: "mdc-typography--headline4",
-                                            $text: self.worldName + ' by ' + self.userAlias
-                                        }
-                                    ]
-                                },
-                                {
-                                    $type: "div",
-                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-4",
-                                    $components: [
-                                        //worldCardGUI,
-                                        this._worldsComps,
-                                        { $type: 'p' },
-                                        this._runWorldGUI
-                                    ]
-                                },
-                                {
-                                    $type: "div",
-                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
-                                    $components: [
-                                        this._actionsGUI
-                                    ]
-                                },
-                                // {
-                                //     $type: "div",
-                                //     class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
-                                //     $components: [
-                                //     ].concat(worldStatesGUI)
-                                // },
-                            ]
-                        }
-                    ]
-                }
-            ]
-        }
+                    {
+                        $type: "div",
+                        class: "mdc-layout-grid",
+                        $components: [
+                            {
+                                $type: "div",
+                                class: "mdc-layout-grid__inner",
+                                $components: [
+                                    {
+                                        $type: "div",
+                                        class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
+                                        $components: [
+                                            {
+                                                $type: "h1",
+                                                class: "mdc-typography--headline4",
+                                                $text: self.worldName + ' by ' + self.userAlias
+                                            }
+                                        ]
+                                    },
+                                    {
+                                        $type: "div",
+                                        class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-4",
+                                        $components: [
+                                            //worldCardGUI,
+                                            this._worldsComps,
+                                            { $type: 'p' },
+                                            this._runWorldGUI
+                                        ]
+                                    },
+                                    {
+                                        $type: "div",
+                                        class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
+                                        $components: [
+                                            this._actionsGUI
+                                        ]
+                                    },
+                                    // {
+                                    //     $type: "div",
+                                    //     class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
+                                    //     $components: [
+                                    //     ].concat(worldStatesGUI)
+                                    // },
+                                ]
+                            }
+                        ]
+                    }
+                ]
+            }
         })
 
         document.querySelector("#aboutWorld")._refresh(worldCardGUI);
-       
-
 
-        var info = {};
 
 
-        // if (!saveName) {
-        //     info = await _app.getAllProtoWorldsInfoForUser(user.user, space) //await _app.getWorldInfo(user, space);
-        // } else {
-        //     let loadName = space + "/load/" + saveName;
-        //     info = await _app.getAllStateWorldsInfoForUser(user.user, space, loadName) //await _app.getStateInfo(user, space, saveName);
-        // }
-
-        
-        // worldCardGUI._worldInfo = info;
-        // worldCardGUI.$update();
-       
-        //worldCardGUI._refresh(info);
-        //worldCardGUI._updateComps();
-        
-        //document.querySelector("#aboutWorld")._refreshWorldComps(info);
-
-      
-        ///STATES FIX!!!
-
-    //     let worldStatesComp = this.createWorldStatesGUI();
-
-    //     document.querySelector("#worldStates").$cell({
-    //         id: 'worldStates',
-    //         $cell: true,
-    //         $type: "div",
-    //         $components: [worldStatesComp]
-    //     //     $update: function(){
-    //     //         this.$components = [
-    //     //         {}
-            
-    //     //     ]
-    //     // }
-    // })
-
-    if (!saveName) {
-        _app.indexApp.allWorldsStatesForUser(user.user, space, 'worldStates')
-    }
+        var info = {};
 
-        // if (!saveName) {
-        //     let statesData = await _app.getAllStateWorldsInfoForUser(user.user, space) //await _app.getSaveStates(user, space);
-        //     //let worldStates = this.createWorldStatesGUI();
-        //     let worldStates = document.querySelector("#worldStatesGUI");
-        //     worldStates._states = statesData;
-        //     worldStates._updateComps();
-        //     worldStatesComp.$components.push(worldStates);
-        // }
+        if (!saveName) {
+            _app.indexApp.allWorldsStatesForUser(user.user, space, 'worldStates')
+        }
 
     }
-
-
-
 }
 
 export { WorldApp }

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä