Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h2>Embedding both video indexer widgets and How to customize the widgets</h2>

<div class="sidebar">
  Video Id: <input type="text" value="4dc0aa32bf" id="videoId">
  Account Id: <input type="text" value="00000000-0000-0000-0000-000000000000" id="accountId">
  <h5>Insights Widgets Options:</h5>
  Iframe Window Title (if embeded as window/tab) : <input type="text" class="" name="title" id="title" value=""/>
  <div>
    <p>Insights to render on the widget:</p>
    <div>
      <input class="" type="checkbox" name="all" id="all" value="all" checked>
      <label for="all">All Widgets</label>
    </div> <br>
    <div>
          <input class="insights" type="checkbox" name="people" id="people" value="people">
          <label for="people">People</label>
    </div>
    <div> 
          <input class="insights" type="checkbox" name="people" id="keywords" value="keywords">
          <label for="keywords">Keywords</label>
    </div>
    <div>
          <input class="insights" type="checkbox" name="people" id="annotations" value="annotations">
          <label for="annotations">Annotations</label>
    </div>
    <div>
          <input class="insights" type="checkbox" name="brands" id="brands" value="brands">
          <label for="brands">Brands</label>
    </div>    
    <div>
          <input class="insights" type="checkbox" name="sentiments" id="sentiments" value="sentiments">
          <label for="sentiments">Sentiments</label>
    </div> 
    <div>
          <input class="insights" type="checkbox" name="sentiments" id="transcript" value="transcript">
          <label for="transcript">Transcript</label>
    </div>
    <div>
          <input class="insights" type="checkbox" name="search" id="search" value="search">
          <label for="search">Search</label>
    </div><br>
    <div>
      Insights Iframe Embed URL: <br>
      <input type="text" readonly style="width:100%" id="generatedInsightsUrl" value="https://www.videoindexer.ai/embed/insights/00000000-0000-0000-0000-000000000000/9a296c6ec3">
    </div>
  </div>
  <br>
  
  <h5>Player Widget Options:</h5>
        <div>
          <input type="checkbox" checked name="autoplay" id="autoplay" value="autoplay" >
          <label for="autoplay">Autoplay</label>
    </div> 
      <div>
          <input type="checkbox" name="captions" id="captions" value="showCaptions" >
          <label for="captions">Embed with captions toggled on</label>
    </div> 
    <div>
      <label for="lang">Default language:</label>
      <select name="lang" id="lang">
<option value="Arabic" >Arabic</option>
<option value="Chinese" >Chinese</option> 
<option value="English" >English</option>
<option value="French" >French</option>
<option value="German" >German</option>
<option value="Italian" >Italian</option>
<option value="Japanese" >Japanese</option>
<option value="Portuguese" >Portuguese</option>
<option value="Russian" >Russian</option>
<option value="Spanish" >Spanish</option>
<option value="Filipino" >Filipino</option>
<option value="Afrikaans" >Afrikaans</option>
<option value="Bangla" >Bangla</option>
<option value="Bosnian" >Bosnian</option>
<option value="Bulgarian" >Bulgarian</option>
<option value="Catalan" >Catalan</option>
<option value="Croatian" >Croatian</option>
<option value="Czech" >Czech</option>
<option value="Danish" >Danish</option>
<option value="Dutch" >Dutch</option>
<option value="Fijian" >Fijian</option>
<option value="Samoan" >Samoan</option>
<option value="Estonian" >Estonian</option>
<option value="Finnish" >Finnish</option>
<option value="Greek" >Greek</option>
<option value="Haitian" >Haitian</option>
<option value="Hebrew" >Hebrew</option>
<option value="Hindi" >Hindi</option>
<option value="Hungarian" >Hungarian</option>
<option value="Indonesian" >Indonesian</option>
<option value="Kiswahili" >Kiswahili</option>
<option value="Korean" >Korean</option>
<option value="Latvian" >Latvian</option>
<option value="Lithuanian" >Lithuanian</option>
<option value="Malagasy" >Malagasy</option>
<option value="Malay" >Malay</option>
<option value="Maltese" >Maltese</option>
<option value="Norwegian" >Norwegian</option>
<option value="Persian" >Persian</option>
<option value="Polish" >Polish</option>
<option value="Romanian" >Romanian</option>
<option value="Serbian" >Serbian</option> 
<option value="Serbian" >Serbian</option> 
<option value="Slovak" >Slovak</option>
<option value="Slovenian" >Slovenian</option>
<option value="Swedish" >Swedish</option>
<option value="Tamil" >Tamil</option>
<option value="Thai" >Thai</option>
<option value="Tongan" >Tongan</option>
<option value="Turkish" >Turkish</option>
<option value="Ukrainian" >Ukrainian</option>
<option value="Urdu" >Urdu</option>
<option value="Vietnamese" >Vietnamese</option>
<option value="Chinese" >Chinese</option>
      </select> 
    </div>
  <br>
        <div>
      Player Iframe Embed URL: <br>
      <input id="generatedPlayerUrl" type="text" readonly style="width:100%" value="https://www.videoindexer.ai/embed/player/00000000-0000-0000-0000-000000000000/4dc0aa32bf">
    </div>
</div>




<!-- EMBEDDED IFRAMES -->
<div class="iframes">
  <iframe width="560" height="315" src="https://www.videoindexer.ai/embed/player/00000000-0000-0000-0000-000000000000/4dc0aa32bf" frameborder="0" allowfullscreen></iframe>
  <iframe width="680" height="780" src="https://www.videoindexer.ai/embed/insights/00000000-0000-0000-0000-000000000000/4dc0aa32bf" frameborder="0" allowfullscreen></iframe>
  
<!-- MEDIATOR - INCHARGE OF CROSS IFRAMES COMMUNICATIONS -->
  <script src="https://breakdown.blob.core.windows.net/public/vb.widgets.mediator.js"></script>
</div>
              
            
!

CSS

              
                * {
  font-family: "Arial";
}
input {
  box-sizing: border-box;
}
iframe {
  display: inline-block;
  vertical-align: top;
}

.sidebar {
  padding:10px;
  width: 700px;
  background-color: #eee;
  height: auto;
  display: inline-block;
}

.iframes {
  vertical-align: top;
  height: 100vh;
  display: inline-block;
}
              
            
!

JS

              
                (function(){
  var baseInsightsUrl = "https://www.videoindexer.ai/embed/insights/";
  var basePlayerInsightsUrl = "https://www.videoindexer.ai/embed/player/";
  var videoIdInput = $("#videoId");
  var accountIdInput = $("#accountId");
  var insightsInputs = $(".insights");
  var titleEl = $('input[name="title"]');
  var generatedInsightsUrlEl = $("#generatedInsightsUrl");
  var generatedPlayerInsightsUrlEl = $("#generatedPlayerUrl");
  var insightsWidgetUrlParams = {};
  var playerInsightsWidgetUrlParams = {autoplay:false};
  var widgetsToRender = [];
  var allWidgets = $('input[name="all"]');
  var captionsCheckbox = $("#captions");
  var autoplayCheckbox = $("#autoplay");
  var langSelect = $("#lang");
  
  // Register listeners
  titleEl.on("keyup", modifyInsightsUrl);
  insightsInputs.on("change", modifyInsightsUrl);
  allWidgets.on("change", toggleUncheckAll);
  captionsCheckbox.on("change", modifyPlayerUrl);
  autoplayCheckbox.on("change", modifyPlayerUrl);
  langSelect.on("change",modifyPlayerUrl);
  videoIdInput.on("keyup", function() {
    var id  = videoIdInput.val();
    var accountId  = accountIdInput.val();
    generateUrlFromParams(insightsWidgetUrlParams, baseInsightsUrl, generatedInsightsUrlEl, accountId, id);
    generateUrlFromParams(playerInsightsWidgetUrlParams, basePlayerInsightsUrl, generatedPlayerInsightsUrlEl, accountId, id);
  });
  
  accountIdInput.on("keyup", function() {
    var id  = videoIdInput.val();
    var accountId  = accountIdInput.val();
    generateUrlFromParams(insightsWidgetUrlParams, baseInsightsUrl, generatedInsightsUrlEl, accountId, id);
    generateUrlFromParams(playerInsightsWidgetUrlParams, basePlayerInsightsUrl, generatedPlayerInsightsUrlEl, accountId , id);
  });
  // Init
  toggleUncheckAll();
  
  // Utils Functions
  function modifyPlayerUrl() {
    var $this = $(this);
    var value = $this.val();
    
    
    if($this.attr("type") === "checkbox") {
      if($this.is(":checked")) {
        playerInsightsWidgetUrlParams[$this.val()] = true;
      } else {
        playerInsightsWidgetUrlParams[$this.val()] = false;
      }
    } 
    if($this.prop("id") === "lang") {
      if(value!=="English") {
        playerInsightsWidgetUrlParams.captions=value;
      } else {
        delete playerInsightsWidgetUrlParams.captions;
      }
    }
    console.log(playerInsightsWidgetUrlParams);
    generateUrlFromParams(playerInsightsWidgetUrlParams, basePlayerInsightsUrl, generatedPlayerInsightsUrlEl , accountIdInput.val() , videoIdInput.val());
  }
  
  function modifyInsightsUrl() {
    var $this = $(this);
    var value = $this.val();
    var title = titleEl.val();
    insightsWidgetUrlParams = {};
    
    if(title) {
      insightsWidgetUrlParams["title"] = title;  
    }
    
    if($this.attr("type") === "checkbox") {
      if($this.is(":checked")) {
        
        widgetsToRender.push(value); 
      } else {
        remove(widgetsToRender, value); 
      }
    }
    
    
    if(widgetsToRender.length) {
      insightsWidgetUrlParams.widgets = widgetsToRender.join(",");
    }
    
    generateUrlFromParams(insightsWidgetUrlParams, baseInsightsUrl, generatedInsightsUrlEl, accountIdInput.val() , videoIdInput.val());
    console.log(insightsWidgetUrlParams);
  }
  
  function toggleUncheckAll(){

    insightsInputs.each(function() {
          if(allWidgets.is(':checked')) {
            delete insightsWidgetUrlParams.widgets;
            widgetsToRender.length = 0;
            if($(this).attr("type") === "checkbox") {
              $(this).prop({"checked": false, "disabled":true});
            }
          } else {
            if($(this).attr("type") === "checkbox") {
               
               $(this).prop({"checked": false, "disabled":false});
            }
          }
    });
    
    generateUrlFromParams(insightsWidgetUrlParams, baseInsightsUrl, generatedInsightsUrlEl, accountIdInput.val(), videoIdInput.val());
  }
  
  function remove(array, element) {
      const index = array.indexOf(element);

      if (index !== -1) {
          array.splice(index, 1);
      }
  }
  
  function generateUrlFromParams(obj, baseUrl, el, accountId , id) {
     var objKeys = Object.keys(obj);
     var urlParams = objKeys.length ? "?" : "";
     for(key in obj) {
       if(obj.hasOwnProperty(key)) {
         urlParams += key + "=" + obj[key];
         if(key !== objKeys[objKeys.length - 1]) {
           urlParams += "&";
         }
       }
     }
    el.val(baseUrl + accountId + "/" + id + "/" + urlParams);
  }
  
}())
              
            
!
999px

Console