<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<!-- Vendor Styles -->
<!--
    <link href="{{ url_for('static', filename='vendor/bokehjs/css/bokeh.css') }}" rel="stylesheet">
    <link href="{{ url_for('static', filename='vendor/bokehjs/css/continuum.css') }}" rel="stylesheet">
    <link href="{{ url_for('static', filename='vendor/bokehjs/vendor/bootstrap/css/bootstrap.css') }}" rel="stylesheet">    
-->
{% if include_js %}
    {% for jsfile in jsfiles %}
    <script type="text/javascript" src="{{jsfile}}"></script>
    {% endfor %}
    {% for jsfile in hemfiles %}
    <script type="text/javascript" src="{{jsfile}}"></script>
    {% endfor %}
{% endif %}
  
</head>
<body>
  <p>content</p>

{% 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>
