
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

// This file must be webpacked because it contains .css imports

// Load jquery and jquery-ui
var $ = require('jquery');
require('jquery-ui');
window.$ = window.jQuery = $;
require('jquery-ui');

// Load styling
require('jquery-ui/themes/smoothness/jquery-ui.min.css');
require('../css/widgets.min.css');

const widgets = require('./index');
console.info('jupyter-js-widgets loaded successfully');

const manager = new widgets.EmbedManager();

// Magic global widget rendering function:
function renderInlineWidgets(element) {
  var element = element || document;
  var tags = element.querySelectorAll('script.jupyter-widgets');
  for (var i=0; i!=tags.length; ++i) {
    var tag = tags[i];
    var widgetStateObject = JSON.parse(tag.innerHTML);
    var widgetContainer = document.createElement('div');
    widgetContainer.className = 'widget-area';
    manager.display_widget_state(widgetStateObject, widgetContainer).then(function() {
        tag.parentElement.insertBefore(widgetContainer, tag);
    });
  }
}

// Module exports
exports.manager = manager;
exports.renderInlineWidgets = renderInlineWidgets;

// Set window globals
window.manager = manager;

window.onload = renderInlineWidgets;

@@ -615,19 +615,17 @@
 idgets(e
-lem
+v
 ent) %7B%0A 
@@ -640,21 +640,26 @@
 ment = e
-lemen
+vent.targe
 t %7C%7C doc
@@ -1272,16 +1272,32 @@
 dow.
-on
+addEventListener('
 load
- =
+',
  ren
@@ -1292,30 +1292,31 @@
 ('load', renderInlineWidgets
+)
 ;%0A

Use addEventListener('load' instead of onload