Skip to content

giantmonkey/gomus-public-iframe-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

gomus-public-iframe-example

Example of handling go~mus public routes

Schema

go_url

Code

Include the following code into your page:

  function getParameterByName(name, url) {
      if (!url) {
          url = window.location.href;
      }
      name = name.replace(/[\[\]]/g, "\\$&");
      var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)");
      var results = regex.exec(url);
  
      if (!results) return null;
      if (!results[2]) return '';
  
      var resultUrl = decodeURIComponent(results[2].replace(/\+/g, " "));
      
      var urlObject = new URL(resultUrl);
      var domainRegex = new RegExp("^([a-z0-9-]+\\.)?gomus\\.(de|cloud|lu|at)$");
  
      if (!domainRegex.test(urlObject.hostname)) {
          return null; // or an appropriate error value.
      }
      
      return resultUrl;
  }


  var el = document.getElementById('go_marker');
  var go_url = getParameterByName('go_url');

  if ((typeof(el) != 'undefined' && el != null) && (typeof(go_url) != 'undefined' && go_url != null)) {
    // get the go url
    var go_url_arr = go_url.split("/");
    var go_url_base = go_url_arr[0] + "//" + go_url_arr[2]

    // create the iframe in pure javascript
    var ifrm = document.createElement('iframe');

    ifrm.setAttribute('id', 'go_ifrm');
    ifrm.setAttribute('csp', "\"object-src 'none'\"");
    ifrm.setAttribute('allow', "camera "+go_url_base+"; microphone "+go_url_base);

    // insert into exisiting element
    el.appendChild(ifrm);

    // assign url
    ifrm.setAttribute('src', go_url);

    // set frameborder
    ifrm.setAttribute('frameborder', 'none');

    // set allowtransparency
    ifrm.setAttribute('allowtransparency', 'true');

    // assign width
    ifrm.setAttribute('width', '100%');
    ifrm.setAttribute('height', '800');
  }

Add an iframe container div into your page:

  <div id="go_marker"></div>

About

Example of handling go~mus public routes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages