Nikolay Suslov 4 lat temu
rodzic
commit
500563f222

+ 174 - 74
public/app.js

@@ -193,6 +193,7 @@ class App {
     let config = localStorage.getItem('lcs_config');
     let langConfig = localStorage.getItem('krestianstvo_locale');
     let manualConfig = localStorage.getItem('lcs_app_manual_settings');
+    let lcsappConfig = localStorage.getItem('lcs_app');
 
     localStorage.clear();
 
@@ -205,17 +206,24 @@ class App {
     if (manualConfig)
       localStorage.setItem('lcs_app_manual_settings', manualConfig);
 
+    if (lcsappConfig)
+      localStorage.setItem('lcs_app', lcsappConfig);
+
   }
 
   initUser() {
 
     function recall() {
-      _LCSDB.user().recall({ sessionStorage: 1 })
+      _LCSDB.user().recall({ sessionStorage: 1 }, res=>{
+        console.log('User is: ', _LCSDB.user().is);
+        if(_LCSDB.user().is)
+          _app.helpers.checkUserCollision();
+
+      });
     }
 
     setTimeout(
       recall, 1000)
-
   }
 
 
@@ -565,6 +573,7 @@ class App {
 
         if (_LCSDB.user().is) {
 
+
           let adminComponents = [];
 
           document.querySelector("#admin").$cell({
@@ -713,10 +722,28 @@ class App {
     window._app.hideProgressBar();
     window._app.hideUIControl();
 
+    import('/web/header.js').then(res => {
+      let gui = new res.Header();
+      gui.init();
+    })
+
     _LCSDB.on('auth',
       async function (ack) {
         if (ack.sea.pub) {
-          document.querySelector("#profile")._refresh("User alias: " + _LCSDB.user().is.alias); //+' pub: ' + this.db.user().is.pub;
+
+          _app.helpers.checkUserCollision();
+
+          let alias = _LCSDB.user().is.alias;
+          let pub = _LCSDB.user().is.pub;
+          document.querySelector("#profile")._refresh(
+            {
+              user: {
+                alias: alias,
+                pub: pub
+              }
+            }
+            
+            ); //+' pub: ' + this.db.user().is.pub;
           //document.querySelector("#profile").$update();
         }
       })
@@ -956,12 +983,12 @@ class App {
     let userProfile = {
       $type: 'div',
       id: "profile",
-      _status: "",
-      _refresh: function(status){
-        this._status = status;
+      _user: {},
+      _refresh: function(data){
+        this._user = data.user;
       },
       $init: function () {
-        this._status = "user is not signed in..."
+        this._user = {alias: "", pub:""}
       },
       $update: function () {
 
@@ -982,10 +1009,15 @@ class App {
                               class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
                               $components: [
                                 {
-                                  $type: "h4",
-                                  class: "mdc-typography--headline4",
-                                  $text: this._status //"Profile for: " + this.db.user().is.alias
-                                }
+                                  $type: "h5",
+                                  class: "mdc-typography--headline4 unselectable",
+                                  $text:  "User alias: " + this._user.alias //"Profile for: " + this.db.user().is.alias
+                                },
+                                {
+                                  $type: "h5",
+                                  class: "mdc-typography--headline5 unselectable",
+                                  $text: "User public key: " + this._user.pub//"Profile for: " + this.db.user().is.alias
+                                },
                               ]
                           },
                           {
@@ -997,7 +1029,12 @@ class App {
                                 class: "mdc-typography",
                                 $text: 'Load my world\'s protos:' //"Profile for: " + this.db.user().is.alias
                               },
-                              dragDropWorldsArea, _app.widgets.emptyDiv, loadEmpty
+                              dragDropWorldsArea, _app.widgets.emptyDiv, 
+                              {
+                                $text: 'or'
+                              },
+                              _app.widgets.p,
+                              loadEmpty
                             ]
                         },
                         {
@@ -1011,6 +1048,10 @@ class App {
                             },
                             dragDropProxyArea,
                             _app.widgets.emptyDiv,
+                            {
+                              $text: 'or'
+                            },
+                            _app.widgets.p,
                             loadDefaultsProxy
                           ]
                       }
@@ -1026,7 +1067,7 @@ class App {
             {
               $type: "h3",
               class: "mdc-typography--headline3",
-              $text: this._status //"Profile for: " + this.db.user().is.alias
+              $text: "user is not signed in..." //"Profile for: " + this.db.user().is.alias
             },
             _app.widgets.divider
           ]
@@ -1076,6 +1117,8 @@ class App {
 
         if (_LCSDB.user().is) {
 
+          _app.helpers.checkUserCollision();
+
           if (_LCSDB.user().is.alias == user) {
 
             var worldType = 'worlds';
@@ -1651,7 +1694,8 @@ class App {
 
     if (revs) {
       for (const res of Object.values(revs)) {
-        result.push(parseInt(res.revision));
+        if(res)
+          result.push(parseInt(res.revision));
       }
       return result
 
@@ -2224,81 +2268,135 @@ class App {
 
   // SUPPORT of DELETE USER WORLDS & SAVE STATES (experimental)
   // TODO: manual garbage collection
+  async deleteWorldState(worldName, stateName) {
 
-  async deleteWorldState(worldName, indexState) {
+    //let pathName = 'savestate_/' + worldName+ '/' + this._worldName.stateName + '_info_vwf_json';
+  let db = _LCSDB.user();
 
-    let revs = (await _LCSDB.user().get('documents').get(worldName).get(indexState).get('revs').promOnce()).data;
-    if (revs) {
-      for (const el of Object.keys(revs)) {
-        if (el !== '_') {
-          let doc = (await _LCSDB.user().get('documents').get(worldName).get(indexState).get('revs').get(el).promOnce()).data;
-          for (const rev of Object.keys(doc)) {
-            if (rev !== '_') {
-              await _LCSDB.user().get('documents').get(worldName).get(indexState).get('revs').get(el).get(rev).put(null).promOnce();
-            }
-          }
-          await _LCSDB.user().get('documents').get(worldName).get(indexState).get('revs').get(el).put(null).promOnce();
-        }
-      }
-    }
+  let stateEntryInfo = 'savestate_/' + worldName + '/' + stateName + '_info_vwf_json';
+  let stateEntry = 'savestate_/' + worldName + '/' + stateName + '_vwf_json';
 
-    // clear all state params
-    let stateDoc = (await _LCSDB.user().get('documents').get(worldName).get(indexState).promOnce()).data;
-    for (const state of Object.keys(stateDoc)) {
-      if (state !== '_' && state !== 'revs') {
-        await _LCSDB.user().get('documents').get(worldName).get(indexState).get(state).put(null).promOnce();
-      }
-    }
+  db.get('documents').get(worldName).get(stateEntry).get('revs').once().map().once((res,k)=>{
+    db.get('documents').get(worldName).get(stateEntry).get('revs').get(k).put(null);
+    //console.log(k, ' - ', res);
+  });
 
-    await _LCSDB.user().get('documents').get(worldName).get(indexState).get('revs').put(null).promOnce();
-    await _LCSDB.user().get('documents').get(worldName).get(indexState).put(null).promOnce();
+  db.get('documents').get(worldName).get(stateEntryInfo).put(null, res=>{
+    let id = 'worldCard_' + _LCSDB.user().is.alias + '_' + worldName + '_' + stateName;
+    let doc = document.querySelector('#' + id);
+    if(doc)
+      doc._refresh({})
 
-  }
+  });
+  db.get('documents').get(worldName).get(stateEntry).get('revs').put(null,res=>{
+    db.get('documents').get(worldName).get(stateEntry).put(null);
+  });
+
+}
+
+  // async deleteWorldState_old(worldName, indexState) {
+
+  //   let revs = await _LCSDB.user().get('documents').get(worldName).get(indexState).get('revs').once().then();
+  //   if (revs) {
+  //     for (const el of Object.keys(revs)) {
+  //       if (el !== '_') {
+  //         let doc = (await _LCSDB.user().get('documents').get(worldName).get(indexState).get('revs').get(el).promOnce()).data;
+  //         for (const rev of Object.keys(doc)) {
+  //           if (rev !== '_') {
+  //             await _LCSDB.user().get('documents').get(worldName).get(indexState).get('revs').get(el).get(rev).put(null).promOnce();
+  //           }
+  //         }
+  //         await _LCSDB.user().get('documents').get(worldName).get(indexState).get('revs').get(el).put(null).promOnce();
+  //       }
+  //     }
+  //   }
+
+  //   // clear all state params
+  //   let stateDoc = (await _LCSDB.user().get('documents').get(worldName).get(indexState).promOnce()).data;
+  //   for (const state of Object.keys(stateDoc)) {
+  //     if (state !== '_' && state !== 'revs') {
+  //       await _LCSDB.user().get('documents').get(worldName).get(indexState).get(state).put(null).promOnce();
+  //     }
+  //   }
+
+  //   await _LCSDB.user().get('documents').get(worldName).get(indexState).get('revs').put(null).promOnce();
+  //   await _LCSDB.user().get('documents').get(worldName).get(indexState).put(null).promOnce();
+
+  // }
 
   async deleteWorld(name, type) {
 
+    let self = this;
+
     if (type == 'proto') {
 
       let worldName = name;
       //TODO check for states (ask for deleting all states first...)
       //delete states
 
-      let documents = (await _LCSDB.user().get('documents').promOnce()).data;
-      if (documents) {
-        let states = (await _LCSDB.user().get('documents').get(worldName).promOnce()).data;
-        if (states) {
-          for (const st of Object.keys(states)) {
-            if (st !== '_') {
-              if (states[st]) {
-                await this.deleteWorldState(worldName, st);
-              }
+      let db = _LCSDB.user();
 
-            }
-          }
-        }
-      }
+      db.get('documents').once().map((res,k)=> {if(k == worldName) return res}).once((res,k)=>{
 
-      let worldFiles = (await _LCSDB.user().get('worlds').get(worldName).promOnce()).data;
-      if (worldFiles) {
-        for (const el of Object.keys(worldFiles)) {
-          if (el !== '_') {
-            let doc = (await _LCSDB.user().get('worlds').get(worldName).get(el).promOnce()).data;
-            if (doc) {
-              if (doc.file) {
-                for (const fEl of Object.keys(doc)) {
-                  if (fEl !== '_') {
-                    await _LCSDB.user().get('worlds').get(worldName).get(el).get(fEl).put(null).promOnce();
-                  }
-                }
-                await _LCSDB.user().get('worlds').get(worldName).get(el).put(null).promOnce();
-              } else {
-                await _LCSDB.user().get('worlds').get(worldName).get(el).put(null).promOnce()
-              }
-            }
-          }
-        }
+        
+        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', "");
+              console.log(saveName);
+              self.deleteWorldState(worldName, saveName)
+              //let stateEntry = 'savestate_/' + k + '/' + saveName + '_vwf_json';
+        })
       }
 
+
+      })
+
+      db.get('worlds').get(worldName).put(null,res=>{
+        let id = 'worldCard_' + _LCSDB.user().is.alias + '_' + worldName + '_';
+        let doc = document.querySelector('#' + id);
+        if(doc)
+          doc._refresh({})
+      })
+
+
+      // let documents = (await _LCSDB.user().get('documents').promOnce()).data;
+      // if (documents) {
+      //   let states = (await _LCSDB.user().get('documents').get(worldName).promOnce()).data;
+      //   if (states) {
+      //     for (const st of Object.keys(states)) {
+      //       if (st !== '_') {
+      //         if (states[st]) {
+      //           await this.deleteWorldState(worldName, st);
+      //         }
+
+      //       }
+      //     }
+      //   }
+      // }
+
+      // let worldFiles = (await _LCSDB.user().get('worlds').get(worldName).promOnce()).data;
+      // if (worldFiles) {
+      //   for (const el of Object.keys(worldFiles)) {
+      //     if (el !== '_') {
+      //       let doc = (await _LCSDB.user().get('worlds').get(worldName).get(el).promOnce()).data;
+      //       if (doc) {
+      //         if (doc.file) {
+      //           for (const fEl of Object.keys(doc)) {
+      //             if (fEl !== '_') {
+      //               await _LCSDB.user().get('worlds').get(worldName).get(el).get(fEl).put(null).promOnce();
+      //             }
+      //           }
+      //           await _LCSDB.user().get('worlds').get(worldName).get(el).put(null).promOnce();
+      //         } else {
+      //           await _LCSDB.user().get('worlds').get(worldName).get(el).put(null).promOnce()
+      //         }
+      //       }
+      //     }
+      //   }
+      // }
+
       //  this.db.user().get('worlds').get(worldName).map((res, index) => {
 
       //       if(typeof res == 'object'){
@@ -2314,7 +2412,7 @@ class App {
       //       }
       //  })
 
-      await _LCSDB.user().get('worlds').get(worldName).put(null).promOnce();
+      //await _LCSDB.user().get('worlds').get(worldName).put(null).promOnce();
 
     } else if (type == 'state') {
 
@@ -2323,8 +2421,10 @@ class App {
 
       let stateEntryInfo = 'savestate_/' + worldName + '/' + stateName + '_info_vwf_json';
       let stateEntry = 'savestate_/' + worldName + '/' + stateName + '_vwf_json';
-      await this.deleteWorldState(worldName, stateEntryInfo);
-      await this.deleteWorldState(worldName, stateEntry);
+
+      await this.deleteWorldState(worldName, stateName);
+      // await this.deleteWorldState(worldName, stateEntryInfo);
+      // await this.deleteWorldState(worldName, stateEntry);
     }
 
     let noty = new Noty({

+ 15 - 0
public/helpers.js

@@ -430,6 +430,21 @@ class Helpers {
 
     }
 
+   checkUserCollision(){
+
+     //TODO: Fix for using hashids instead users aliases with pubs sorted by time of registration
+
+        _app.helpers.getUserPub(_LCSDB.user().is.alias).then(res=>{
+            if(_LCSDB.user().is.pub !== res){
+              if(window.confirm("ERROR: User name collision. Try to delete user collision?")) {
+                _LCSDB.user().delete();
+                window.reload();
+            }
+            }
+          })
+
+    }
+
     async getUserAlias(userPub) {
 
         let user = await (new Promise(res=>_LCSDB.user(userPub).get('alias').once(res)));

+ 42 - 238
public/lib/index.css

@@ -97,187 +97,19 @@ input {
 }
 */
 
-.vwf-properties {
-  background-color: #DCC;
-}
-
-.vwf-methods {
-  background-color: #CDC;
-}
-
-.vwf-events {
-  background-color: #CCD;
-}
-
-.vwf-root {
-  background-color: #CCC;
-}
-
-.vwf-root .vwf-node:nth-child(odd) {
-  background-color: #BCC;
-}
-
-.vwf-root .vwf-node:nth-child(even) {
-  background-color: #CBC;
-}
-
-.vwf-orphanage {
-  background-color: #CCC;
-}
-
-.vwf-orphanage .vwf-node:nth-child(odd) {
-  background-color: #BCC;
-}
-
-.vwf-orphanage .vwf-node:nth-child(even) {
-  background-color: #CBC;
-}
-
-.vwf-children {
-  background-color: #CCC;
-}
-
-.vwf-children .vwf-node:nth-child(odd) {
-  background-color: #BCC;
-}
-
-.vwf-children .vwf-node:nth-child(even) {
-  background-color: #CBC;
-}
-
-.vwf-children .vwf-children {
-  background-color: #AAA;
-}
-
-.vwf-children .vwf-children .vwf-node:nth-child(odd) {
-  background-color: #9AA;
-}
-
-.vwf-children .vwf-children .vwf-node:nth-child(even) {
-  background-color: #A9A;
-}
-
-.vwf-children .vwf-children .vwf-children {
-  background-color: #888;
-}
-
-.vwf-children .vwf-children .vwf-children .vwf-node:nth-child(odd) {
-  background-color: #788;
-}
-
-.vwf-children .vwf-children .vwf-children .vwf-node:nth-child(even) {
-  background-color: #878;
-}
-
-.vwf-children .vwf-children .vwf-children .vwf-children {
-  background-color: #666;
-}
-
-.vwf-children .vwf-children .vwf-children .vwf-children .vwf-node:nth-child(odd) {
-  background-color: #566;
-}
-
-.vwf-children .vwf-children .vwf-children .vwf-children .vwf-node:nth-child(even) {
-  background-color: #656;
-}
-
-.vwf-scripts {
-  background-color: #CDD;
-}
-
-/*
-.vwf-properties, .vwf-methods, .vwf-events, .vwf-children, .vwf-scripts {
-  padding: 0;
-}
-*/
-
-/*
-.vwf-properties > .vwf-label, .vwf-methods > .vwf-label, .vwf-events > .vwf-label, .vwf-children > .vwf-label, .vwf-scripts> .vwf-label {
-  margin: 0;
-  padding: 8px 5px 5px 5px;
-  font-size: 12px;
-  font-weight: bold;
-}
-
-*/
-
-.vwf-properties > .vwf-label {
-  background-color: #CBB;
-}
-
-.vwf-methods > .vwf-label {
-  background-color: #BCB;
-}
-
-.vwf-events > .vwf-label {
-  background-color: #BBC;
-}
-
-.vwf-children > .vwf-label {
-  background-color: #BBB;
-}
-
-.vwf-scripts > .vwf-label {
-  background-color: #BCC;
-}
 
-.vwf-node > .vwf-label {
-  padding-left: 3px;
-  padding-bottom: 5px;
-}
-
-.vwf-label {
-  margin: 0;
-  padding: 2px 5px 2px 5px;
-  font-size: 18px;
-  font-family: Verdana, Arial, Helvetica, sans-serif;
-}
-
-.vwf-attribute {
-  font-size: 14px;
-}
 
 #vwf-root {
   position:absolute;
   z-index:-1;
 }
 
-#vwf-root > .vwf-label > .vwf-attribute {
-  font-size: 18px;
-}
-
-.vwf-node {
-  padding: 10px;
-}
-
 #vwf-root>div, #vwf-root>canvas {
   margin-left: auto;
   margin-right: auto;
   display: block;
 }
 
-.vwf-control-slider, .vwf-control-roll-slider, .vwf-control-pitch-slider, .vwf-control-yaw-slider, .vwf-control-x-slider, .vwf-control-y-slider, .vwf-control-z-slider, .vwf-control-r-slider, .vwf-control-g-slider, .vwf-control-b-slider {
-    display: inline-block;
-    width: 15em;
-    margin-left: 1ex;
-}
-
-.vwf-activeCamera-dropdown {
-    display: inline-block;
-    width: 15em;
-    margin-left: 1ex;
-}
-
-.vwf-roll-value, .vwf-pitch-value, .vwf-yaw-value, .vwf-r-value, .vwf-g-value, .vwf-b-value, .vwf-a-value {
-    display: inline-block;
-    width: 2em;
-}
-
-.vwf-x-value, .vwf-y-value, .vwf-z-value {
-    display: inline-block;
-    width: 4em;
-}
-
 .vwf-err {
     border: 2px solid red;
     font: 14px Arial;
@@ -349,75 +181,6 @@ text-shadow: 0px 0px 0 rgba(0, 0, 0, 0.3);
 }
 */
 
-.pace {
-  -webkit-pointer-events: none;
-  pointer-events: none;
-  -webkit-user-select: none;
-  -moz-user-select: none;
-  user-select: none;
-}
-
-.pace .pace-activity {
-  display: block;
-  position: fixed;
-  z-index: 2000;
-  top: 0;
-  right: 0;
-  width: 300px;
-  height: 300px;
-  background: #6c96f7;
-  -webkit-transition: -webkit-transform 0.3s;
-  transition: transform 0.3s;
-  -webkit-transform: translateX(100%) translateY(-100%) rotate(45deg);
-  transform: translateX(100%) translateY(-100%) rotate(45deg);
-  pointer-events: none;
-}
-
-.pace.pace-active .pace-activity {
-  -webkit-transform: translateX(50%) translateY(-50%) rotate(45deg);
-  transform: translateX(50%) translateY(-50%) rotate(45deg);
-}
-
-.pace .pace-activity::before,
-.pace .pace-activity::after {
-    position: absolute;
-    bottom: 30px;
-    left: 50%;
-    display: block;
-    border: 5px solid #fff;
-    border-radius: 50%;
-    content: '';
-}
-
-.pace .pace-activity::before {
-    margin-left: -40px;
-    width: 80px;
-    height: 80px;
-    border-right-color: rgba(0, 0, 0, .2);
-    border-left-color: rgba(0, 0, 0, .2);
-    -webkit-animation: pace-rotation 3s linear infinite;
-    animation: pace-rotation 3s linear infinite;
-}
-
-.pace .pace-activity::after {
-    bottom: 50px;
-    margin-left: -20px;
-    width: 40px;
-    height: 40px;
-    border-top-color: rgba(0, 0, 0, .2);
-    border-bottom-color: rgba(0, 0, 0, .2);
-    -webkit-animation: pace-rotation 1s linear infinite;
-    animation: pace-rotation 1s linear infinite;
-}
-
-@-webkit-keyframes pace-rotation {
-  0% { -webkit-transform: rotate(0deg); }
-  100% { -webkit-transform: rotate(359deg); }
-}
-@keyframes pace-rotation {
-  0% { transform: rotate(0deg); }
-  100% { transform: rotate(359deg); }
-}
 
 #incompatibleBrowser {
     visibility: hidden;
@@ -477,4 +240,45 @@ text-shadow: 0px 0px 0 rgba(0, 0, 0, 0.3);
 
 .drag {
   border: 5px solid rgba(195, 0, 0, 0.751);
-}
+}
+
+a.link-in-text {
+  outline: none;
+  text-decoration: none;
+  color: inherit;
+  border-bottom: 1px solid;
+}
+
+
+a.link-in-text:link {
+  border-bottom: 1px solid;
+}
+
+
+
+a.link-in-text:visited {
+  border-bottom: 1px solid;
+}
+
+
+a.link-in-text:focus {
+  border-bottom: 2px solid; 
+  
+}
+
+a.link-in-text:hover {   
+  border-bottom: 2px solid; 
+}
+
+a.link-in-text:active {
+  
+  border-bottom: 1px solid; 
+}
+
+.unselectable {
+  -moz-user-select: text;
+  -khtml-user-select: text;
+  -webkit-user-select: text;
+  -ms-user-select: text;
+  user-select: text;
+ }

+ 158 - 0
public/lib/widgets.js

@@ -1106,6 +1106,164 @@ Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contribu
         }
 
 
+        getLoginGUI(){
+
+            let loginGUI =
+            {
+                $type: "div",
+                id: "loginGUI",
+                //style:"background-color: #efefef",
+                class: "mdc-layout-grid mdc-layout-grid--align-left",
+                _alias: null,
+                _pass: null,
+                _passField: null,
+                _aliasField: null,
+                _initData: function () {
+                    this._alias = '';
+                    this._pass = '';
+                    // if (window.sessionStorage.getItem('alias')) {
+                    //     this._alias = window.sessionStorage.getItem('alias')
+                    // }
+                    // if (window.sessionStorage.getItem('tmp')) {
+                    //     this._pass = window.sessionStorage.getItem('tmp')
+                    // }
+                },
+                $init: function () {
+                    this._initData();
+                },
+                $update: function () {
+    
+                    this.$components = [
+                        {
+                            $type: "div",
+                            class: "mdc-layout-grid__inner",
+                            $components: [
+                                {
+                                    $type: "div",
+                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
+                                    $components: [
+                                        {
+                                            $type: "span",
+                                            class: "mdc-typography--headline5",
+                                            $text: "Login: "
+                                        },
+                                        window._app.widgets.inputTextFieldOutlined({
+                                            "id": 'aliasInput',
+                                            "label": "Login",
+                                            "value": this._alias,
+                                            "type": "text",
+                                            "init": function () {
+                                                this._aliasField = new mdc.textField.MDCTextField(this);
+                                            }
+                                        }),
+                                    ]
+                                },
+                                {
+                                    $type: "div",
+                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
+                                    $components: [
+                                        {
+                                            $type: "span",
+                                            class: "mdc-typography--headline5",
+                                            $text: "Password: "
+                                        },
+                                        window._app.widgets.inputTextFieldOutlined({
+                                            "id": 'passwordInput',
+                                            "label": "Password",
+                                            "value": this._pass,
+                                            "type": "password",
+                                            "init": function () {
+                                                this._passField = new mdc.textField.MDCTextField(this);
+                                            }
+                                        }),
+                                    ]
+                                },
+                                {
+                                    $type: "div",
+                                    class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
+                                    $components: [
+                                        window._app.widgets.buttonRaised(
+                                            {
+                                                "label": 'Sign UP',
+                                                "onclick": function (e) {
+                                                    e.preventDefault();
+    
+                                                    let alias = this._aliasField.value;
+                                                    let pass = this._passField.value
+    
+                                                    if (pass.length < 7) {
+                                                        new Noty({
+                                                            text: "Your passphrase needs to be longer than 7 letters",
+                                                            timeout: 2000,
+                                                            theme: 'mint',
+                                                            layout: 'bottomRight',
+                                                            type: 'error'
+                                                        }).show();
+                                                    } else {
+                                                        //
+                                                        _LCSDB.user().create(alias, pass,
+                                                            function (ack) {
+                                                                if (!ack.wait) { }
+                                                                if (ack.err) {
+                                                                    console.log(ack.err)
+                                                                    return ack.err
+                                                                };
+                                                                if (ack.pub) {
+                                                                    let userObj = {
+                                                                        'alias': alias,
+                                                                        'pub': ack.pub
+                                                                    };
+                                                                    _LCSDB.get('users').get(alias).put(userObj);
+    
+                                                                }
+                                                                _LCSDB.user().auth(alias, pass);
+                                                            });
+    
+                                                    }
+                                                }
+                                            }),
+                                        _app.widgets.space,
+                                        window._app.widgets.buttonRaised(
+                                            {
+                                                "label": 'Sign IN',
+                                                "onclick": function (e) {
+                                                    e.preventDefault();
+                                                    let alias = this._aliasField.value;
+                                                    let pass = this._passField.value
+                                                    _app.helpers.authUser(alias, pass);
+                                                    // _LCSDB.user().auth.call(_LCSDB, alias, pass
+                                                    // //     , function(ack) {
+    
+                                                    // //     if (ack.err) {
+                                                    // //         new Noty({
+                                                    // //             text: ack.err,
+                                                    // //             timeout: 2000,
+                                                    // //             theme: 'mint',
+                                                    // //             layout: 'bottomRight',
+                                                    // //             type: 'error'
+                                                    // //         }).show();
+    
+                                                    // //     }
+                                                    //  //}
+                                                    //  );
+                                                }
+                                            })
+    
+    
+    
+                                    ]
+                                }
+    
+                            ]
+                        }
+                    ]
+                }
+    
+            }
+            return loginGUI
+        }
+
+
       }
 
    export { Widgets }

+ 9 - 2
public/vwf/view/editor-new.js

@@ -1095,11 +1095,18 @@ define([
 
                         )
 
-                        let saveGUI = document.querySelector('#saveGUI');
-                        saveGUI.$components = userGUI.concat(saveGUI.$components);
+                        // let saveGUI = document.querySelector('#saveGUI');
+                        // saveGUI.$components = userGUI.concat(saveGUI.$components);
                         //document.querySelector('#fileName').value = 'world' + _app.helpers.randId();
 
+                    } else {
+                        userGUI.push(
+                            self.widgets.getLoginGUI()
+                        );
                     }
+                    
+                    let saveGUI = document.querySelector('#saveGUI');
+                    saveGUI.$components = userGUI.concat(saveGUI.$components);
                 },
                 $update: function () {
                 },

+ 4 - 1
public/web/header.js

@@ -14,8 +14,11 @@ class Header {
 
     init() {
 
-        let rootDoc = _app.indexApp.entry == 'index' ? document.querySelector('#indexPage') : document.querySelector('#app');
+        var rootDoc = document.body
+        if(_app.indexApp){
+            rootDoc = _app.indexApp.entry == 'index' ? document.querySelector('#indexPage') : document.querySelector('#app');
         //let rootDoc = document.querySelector('#app');
+        } 
 
         let el = document.createElement("div");
         el.setAttribute("id", "header");

+ 1 - 40
public/web/index-app.css

@@ -31,39 +31,6 @@ background: linear-gradient(0deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5) ), url(
 }
 
 
-a.link-in-text {
-  outline: none;
-  text-decoration: none;
-  color: inherit;
-  border-bottom: 1px solid;
-}
-
-
-a.link-in-text:link {
-  border-bottom: 1px solid;
-}
-
-
-
-a.link-in-text:visited {
-  border-bottom: 1px solid;
-}
-
-
-a.link-in-text:focus {
-  border-bottom: 2px solid; 
-  
-}
-
-a.link-in-text:hover {   
-  border-bottom: 2px solid; 
-}
-
-a.link-in-text:active {
-  
-  border-bottom: 1px solid; 
-}
-
 /* 
 border-bottom: 1px solid; 
 background: rgb(237, 237, 237);
@@ -82,10 +49,4 @@ background: rgb(217, 217, 217);
   margin: 3px
 }
 
-.unselectable {
-  -moz-user-select: text;
-  -khtml-user-select: text;
-  -webkit-user-select: text;
-  -ms-user-select: text;
-  user-select: text;
- }
+

+ 43 - 162
public/web/index-app.js

@@ -102,7 +102,7 @@ class IndexApp {
         entry.setAttribute("id", 'app');
         document.body.appendChild(entry);
 
-        let divs = ['appGUI', 'userLobby', 'main', 'worldsGUI', 'lab'];
+        let divs = ['appGUI', 'userLobby', 'worldsGUI'];
         divs.forEach(el => {
             let appEl = document.createElement("div");
             appEl.setAttribute("id", el);
@@ -224,7 +224,7 @@ class IndexApp {
             $components: [],
             _comps: [],
             _refresh: function(){
-                this.$components = this._comps.concat([userGUI,  self.getLoginGUI(), _app.widgets.divider, self.getLookWorlds()]);
+                this.$components = this._comps.concat([userGUI,  _app.widgets.getLoginGUI(), _app.widgets.divider, self.getLookWorlds()]);
             },
             $init: function () {
                 //this._comps = self.initUserGUI()
@@ -414,6 +414,7 @@ class IndexApp {
         } else {
             _LCSDB.on('auth', function (ack) {
                 if (ack.sea.pub) {
+                    _app.helpers.checkUserCollision();
                     self.authGUI();
                 }
                 console.log(_LCSDB.user().is);
@@ -544,166 +545,6 @@ class IndexApp {
         return lookWorlds
     }
 
-    getLoginGUI(){
-
-        let self = this;
-
-        let loginGUI =
-        {
-            $type: "div",
-            id: "loginGUI",
-            //style:"background-color: #efefef",
-            class: "mdc-layout-grid mdc-layout-grid--align-left",
-            _alias: null,
-            _pass: null,
-            _passField: null,
-            _aliasField: null,
-            _initData: function () {
-                this._alias = '';
-                this._pass = '';
-                // if (window.sessionStorage.getItem('alias')) {
-                //     this._alias = window.sessionStorage.getItem('alias')
-                // }
-                // if (window.sessionStorage.getItem('tmp')) {
-                //     this._pass = window.sessionStorage.getItem('tmp')
-                // }
-            },
-            $init: function () {
-                this._initData();
-            },
-            $update: function () {
-
-                this.$components = [
-                    {
-                        $type: "div",
-                        class: "mdc-layout-grid__inner",
-                        $components: [
-                            {
-                                $type: "div",
-                                class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
-                                $components: [
-                                    {
-                                        $type: "span",
-                                        class: "mdc-typography--headline5",
-                                        $text: "Login: "
-                                    },
-                                    window._app.widgets.inputTextFieldOutlined({
-                                        "id": 'aliasInput',
-                                        "label": "Login",
-                                        "value": this._alias,
-                                        "type": "text",
-                                        "init": function () {
-                                            this._aliasField = new mdc.textField.MDCTextField(this);
-                                        }
-                                    }),
-                                ]
-                            },
-                            {
-                                $type: "div",
-                                class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
-                                $components: [
-                                    {
-                                        $type: "span",
-                                        class: "mdc-typography--headline5",
-                                        $text: "Password: "
-                                    },
-                                    window._app.widgets.inputTextFieldOutlined({
-                                        "id": 'passwordInput',
-                                        "label": "Password",
-                                        "value": this._pass,
-                                        "type": "password",
-                                        "init": function () {
-                                            this._passField = new mdc.textField.MDCTextField(this);
-                                        }
-                                    }),
-                                ]
-                            },
-                            {
-                                $type: "div",
-                                class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
-                                $components: [
-                                    window._app.widgets.buttonRaised(
-                                        {
-                                            "label": 'Sign UP',
-                                            "onclick": function (e) {
-                                                e.preventDefault();
-
-                                                let alias = this._aliasField.value;
-                                                let pass = this._passField.value
-
-                                                if (pass.length < 7) {
-                                                    new Noty({
-                                                        text: "Your passphrase needs to be longer than 7 letters",
-                                                        timeout: 2000,
-                                                        theme: 'mint',
-                                                        layout: 'bottomRight',
-                                                        type: 'error'
-                                                    }).show();
-                                                } else {
-                                                    //
-                                                    _LCSDB.user().create(alias, pass,
-                                                        function (ack) {
-                                                            if (!ack.wait) { }
-                                                            if (ack.err) {
-                                                                console.log(ack.err)
-                                                                return ack.err
-                                                            };
-                                                            if (ack.pub) {
-                                                                let userObj = {
-                                                                    'alias': alias,
-                                                                    'pub': ack.pub
-                                                                };
-                                                                _LCSDB.get('users').get(alias).put(userObj);
-
-                                                            }
-                                                            _LCSDB.user().auth(alias, pass);
-                                                        });
-
-                                                }
-                                            }
-                                        }),
-                                    _app.widgets.space,
-                                    window._app.widgets.buttonRaised(
-                                        {
-                                            "label": 'Sign IN',
-                                            "onclick": function (e) {
-                                                e.preventDefault();
-                                                let alias = this._aliasField.value;
-                                                let pass = this._passField.value
-                                                _app.helpers.authUser(alias, pass);
-                                                // _LCSDB.user().auth.call(_LCSDB, alias, pass
-                                                // //     , function(ack) {
-
-                                                // //     if (ack.err) {
-                                                // //         new Noty({
-                                                // //             text: ack.err,
-                                                // //             timeout: 2000,
-                                                // //             theme: 'mint',
-                                                // //             layout: 'bottomRight',
-                                                // //             type: 'error'
-                                                // //         }).show();
-
-                                                // //     }
-                                                //  //}
-                                                //  );
-                                            }
-                                        })
-
-
-
-                                ]
-                            }
-
-                        ]
-                    }
-                ]
-            }
-
-        }
-        return loginGUI
-    }
-
-
 
 
     refresh() {
@@ -868,6 +709,8 @@ class IndexApp {
                         if(worldType == 'proto') {
 
                             db.get('worlds').get(this._worldName).path('info_json').on((res)=>{
+                                if(res){
+
                                 console.log(res);
     
                                let worldDesc = JSON.parse(res);
@@ -893,10 +736,15 @@ class IndexApp {
                                 //callback
                                 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){
+
+                                
                                 console.log(res);
     
                                let worldDesc = JSON.parse(res);
@@ -922,6 +770,7 @@ class IndexApp {
                                 //callback
                                 if(cb)
                                    cb(doc);
+                            }
                             })
 
                         }
@@ -932,6 +781,7 @@ class IndexApp {
 
                 if(worldType == 'proto') {
                      db.get('worlds').get(this._worldName).on((res)=>{
+                         if(res){
                          console.log(res);
 
                         let worldDesc = JSON.parse(res['info_json']);
@@ -963,6 +813,10 @@ class IndexApp {
                          //callback
                          if(cb)
                             cb(doc);
+                        } else {
+                            //no world
+                            this._refresh({})
+                        }
                      })
 
                     } else if (worldType == 'state') {
@@ -971,6 +825,9 @@ class IndexApp {
                  
 
                         db.get('documents').get(this._worldName.protoName).path(pathNameInfo).on((res)=>{
+                            if(res){
+
+                            
                             console.log(res);
                            let worldDesc = JSON.parse(res);
                         
@@ -998,6 +855,10 @@ class IndexApp {
                             //callback
                             if(cb)
                                cb(doc);
+                        } else {
+                            //no world
+                            this._refresh({})
+                        }
                         })
 
                         // let pathNameState = 'savestate_/' + this._worldName.protoName+ '/' + this._worldName.stateName + '_vwf_json';
@@ -1280,6 +1141,8 @@ class IndexApp {
                     .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];
        
@@ -1287,7 +1150,9 @@ class IndexApp {
                             doc = this._makeWorldCard(k, cardID);
                             this._cards.push(doc);
                         } 
+                    }
        
+
                     })
                 } else if(worldType == 'state') {
                 //get states
@@ -1304,6 +1169,10 @@ class IndexApp {
                             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);
 
@@ -1313,6 +1182,7 @@ class IndexApp {
                                     doc = this._makeWorldCard({protoName: k, stateName: saveName}, cardID);
                                     this._cards.push(doc);
                                 } 
+                            }
 
                             })
                             //let saveName = el.stateName.split('/')[2].replace('_info_vwf_json', "");
@@ -1336,12 +1206,19 @@ class IndexApp {
                         .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);
     
@@ -1351,11 +1228,15 @@ class IndexApp {
                                         doc = this._makeWorldCard({protoName: k, stateName: saveName}, cardID);
                                         this._cards.push(doc);
                                     } 
+
+                                }
+
     
                                 })
                                 //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];