{% extends "base.html" %}
{% block left_pannel %}override{% endblock %}

{% block content %}

{%if not current_user.is_authenticated %}
    <button class="unselected" onclick="location.href = '/login';">login</button>
{% else %}
<table>
    <tr>
        <td width="20%" height="90%"><iframe id="iframe" src="{{url_for('static', filename='logs/custom.txt')}}" width="100%" height="100%"></iframe></td>
        <td width="80%"><iframe src="/novnc/vnc.html?resize=scale&path=novnc/websockify&view_only" width="100%" height="100%" frameborder="0"></iframe></td>
    </tr>
</table>

<script>
    var myIframe = document.getElementById('iframe');

    myIframe.addEventListener("load", async () => {
        myIframe.contentDocument.body.innerHTML = myIframe.contentDocument.body.innerHTML + '<style>html{color:white;}</style>';
        await delay(2000);
        document.getElementById('iframe').contentWindow.location.reload();
    });
    
    window.setInterval(function() {
        document.getElementById('iframe').contentWindow.scrollTo(0, myIframe.contentDocument.body.scrollHeight);
    }, 500);
    
</script>

{% endif %}

{%endblock %}