app.rhinogram.com Open in urlscan Pro
18.245.46.111  Public Scan

URL: https://app.rhinogram.com/widget/embed.js?id=e47bf6d5-dabf-4802-a389-596a6647701
Submission: On March 04 via manual from IN — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

// Example <script id="rhinogram-embed" src="http://localhost:3000/widget/embed.js?id=123&orgId=1"></script>

var iframe;
var div;
var domain;
var styled = false;

function initWidget() {
  var script = document.querySelector('#rhinogram-embed');

  if (!script || !script.src) {
    console.error('Rhinogram widget error: Embed code not found.');

    return;
  }

  domain = getDomain(script.src);
  var webFormId = getParameterByName('id', script.src);

  if (!webFormId) {
    console.error('Rhinogram widget error: Please supply a webFormId');

    return;
  }

  iframe = document.createElement('iframe');
  div = document.createElement('div');
  div.setAttribute('class', 'rhinogram-widget-container');
  iframe.setAttribute('class', 'rhinogram-widget');
  iframe.setAttribute('scrolling', 'no');
  iframe.setAttribute('frameborder', 0);
  iframe.setAttribute('seamless', 'seamless');

  div.appendChild(iframe);
  document.body.appendChild(div);

  iframe.addEventListener('load', function() {
    iframe.contentWindow.postMessage('loaded', '*');
  })
  iframe.src = domain + '/index.html?webFormId=' + webFormId;
}

//Code changed as IE doesn't support the previous code. This works on all browsers.
function getDomain(url) {
  var a = document.createElement('a');
  a.href = url;
  return a.protocol + '//' + a.host + '/widget';
}

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 '';

  return decodeURIComponent(results[2].replace(/\+/g, ' '));
}

function initializeIframeResize() {
  iFrameResize({}, '.rhinogram-widget');
}

function addStyles() {
  styled = true;
  var link = document.createElement('link');
  link.rel = 'stylesheet';
  link.type = 'text/css';
  link.href = domain + '/style.css';
  document.head.appendChild(link);
}

window.addEventListener('message', function(e) {

/**
 * Because the initial size of the WidgetTrigger button is dependent upon the rendered size of its contents,
 * we need to initialize styles after the first message is received. This allows us to avoid other edgecases
 */

  if (e.data && e.data.rhinogram && !styled) {
    addStyles();
  };

  if (e.data && e.data.rhinogram) {
    div.style.width = e.data.rhinogram.width + 'px';
    div.style.height = e.data.rhinogram.height + 'px';
    iframe.style.width = e.data.rhinogram.width + 'px';
    iframe.style.height = e.data.rhinogram.height + 'px';
    div.classList.add('rhinogram-widget--' + e.data.rhinogram.position);
  }
});

document.addEventListener('DOMContentLoaded', initWidget, false);