<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <!-- Vendor Styles -->
    <!--
    <link href="{{ url_for('static', filename='css/bokeh.css') }}" rel="stylesheet">
    -->
</head>
<body>
  <p>content</p>

  <h1>  other injection types </h1>
  <ul>
    <li><a href="/bokeh/generate_embed/onload">Onload</a></li>
    <li><a href="/bokeh/generate_embed/delay">delay</a></li>
    <li><a href="/bokeh/generate_embed/double_delay">double_delay</a></li>
    <li><a href="/bokeh/generate_embed/direct">direct</a></li>
    <li><a href="/bokeh/generate_embed/static">static</a></li>
    <li><a href="/bokeh/generate_embed/static_double">static_double</a></li>
  </ul>

{% if not plot_scr %}
  <script type="text/javascript">

    (function () {
      window.injectF = function() {
      injectFGeneral("{{docid}}", "{{docapikey}}", "{{modelid}}");
    };
        window.injectFGeneral = function(docid, docapi_key, modelid) {
            var scr = document.createElement("script");

            var sa = function(name,val){
                console.log(name,val);
                scr.setAttribute(name, val);};
            sa('src',"http://localhost:5006/bokeh/embed.js");

            sa('bokeh_plottype',"serverconn");
            sa('bokeh_docid', docid);
            sa('bokeh_ws_conn_string',"ws://localhost:5006/bokeh/sub" );
            sa('bokeh_docapikey', docapi_key);
            sa('bokeh_root_url',"http://localhost:5006" );
            sa('bokeh_modelid', modelid);
            sa('bokeh_modeltype',"Plot" );

            document.body.appendChild(scr);};
        console.log("end of script tag injection");
    }())
  </script>
{% endif %}

{% if delay %}
  <h1> delayed injection </h1>
  <h2> the script should appear in 5 seconds </h2>
  <script type="text/javascript">
      setTimeout(injectF, 5000);
  </script>
{% endif %}


{% if double_delay %}
  <h1> delayed injection </h1>
  <h2> the script should appear in 5 seconds </h2>
  <script type="text/javascript">
      setTimeout(function () {
          injectFGeneral("{{docid}}","{{docapikey}}", "{{plot2._id}}");}, 5000);
      setTimeout(injectF, 2000);
  </script>
{% endif %}

{% if onload %}
  <h1>onload injection </h1>
  <script type="text/javascript">
        var addOnload = function(func){
            if (window.attachEvent){
                window.attachEvent('onload', func);}
            else {
                window.addEventListener('load', func, false);}};
        console.log(document.readyState);
        addOnload(injectF);
  </script>
{% endif %}

{% if direct %}
  <h1>direct injection </h1>
  <script type="text/javascript">
    injectF();
  </script>
{% endif %}
{% if plot_scr %}
  <h1> static injection </h1>
  {{plot_scr|safe}}
{% endif %}


</body>
</html>
