repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 446ed8234cb3d47d36c67502cb7c884ce31207ba:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 446ed8234cb3d47d36c67502cb7c884ce31207ba
Author: James Baicoianu 
Date:   Sun Jan 30 13:48:47 2022 -0800

    Allow updating websurface url dynamically

diff --git a/scripts/websurface.js b/scripts/websurface.js
index 32fba20c84711066a79f482aebc342a5be9e2974..
index ..43b61b40a9f3be0176061c5bde254b80b919a092 100644
--- a/scripts/websurface.js
+++ b/scripts/websurface.js
@@ -5,6 +5,7 @@ elation.require(['engine.things.generic'], function() {
       this.defineProperties({
         websurface_id: { type: 'string' },
         image_id: { type: 'string' },
+        url: { type: 'string', set: this.updateURL },
         color: { type: 'color', default: 0xffffff },
         hovercolor: { type: 'color', default: 0x009900 },
         activecolor: { type: 'color', default: 0x00ff00 }
@@ -27,6 +28,8 @@ elation.require(['engine.things.generic'], function() {
         // and hope that most sites are running both.

         this.url = url.replace(/^http:/, 'https:');
+      } else {
+        this.url = this.websurface_id;
       }

       // FIXME - binding of member functions should happen at object creation
@@ -78,7 +81,9 @@ elation.require(['engine.things.generic'], function() {
     }
     this.createObjectDOM = function() {
         var websurface = this.room.websurfaces[this.properties.websurface_id];
-        if (websurface) {
+        if (!websurface) {
+          websurface = {};
+        }
           var width = websurface.width || 1024,
               height = websurface.height || 768,
               border = elation.utils.any(websurface.border, true);
@@ -103,7 +108,6 @@ elation.require(['engine.things.generic'], function() {

           this.iframe = iframe;
           this.domobj = obj;
-        }
     }
     this.activate = function() {
       if (!this.active) {
@@ -167,6 +171,11 @@ setTimeout(elation.bind(this, function() {
         this.objects['3d'].remove(this.domobj);
       }
     }
+    this.updateURL = function() {
+      if (this.iframe) {
+        this.iframe.src = this.url;
+      }
+    }
   }, elation.engine.things.janusbase);
 });

-----END OF PAGE-----