/* eslint-disable */
'use strict';

// Load the embedding script controller/embed.js and css files
// This is needed for backward compatibility, while old user
// still use this file to load embedded infographic

var jsClient = '03aaeeb0';
var cssClient = '096331a5';

(function() {
  // --- functions to create js and css elements ---//
  function includeJS(filePath, type) {
    // Make sure we didn't duplicate any of the previously included files
    if (document.getElementById(filePath)) {
      return;
    }

    var docHead = document.getElementsByTagName('head')[0];
    var src = filePath;
    var newTag = {};

    if (type === 'js') {
      newTag = document.createElement('script');
      newTag.type = 'text/javascript';
      newTag.src = src;
      newTag.async = true;
    } else {
      // we shouldn't be getting anything else than js
      newTag = document.createElement('link');
      newTag.rel = 'stylesheet';
      newTag.type = 'text/css';
      newTag.href = src;
      newTag.media = 'all';
      newTag.async = true;
    }

    newTag.id = filePath; // add it so that we can check the next time easily
    docHead.appendChild(newTag);
  }

  var geniallys = document.getElementsByClassName('genially-embed');

  // Check if DOM has geniallys
  if (!geniallys.length) {
    return;
  }

  // load js
  includeJS(
    'https://d3usyxos00s4ty.cloudfront.net/view/static/js/main.' +
      jsClient +
      '.js',
    'js'
  );

  // load css
  includeJS(
    'https://d3usyxos00s4ty.cloudfront.net/view/static/css/main.' +
      cssClient +
      '.css',
    'css'
  );
})();
