
{% extends "base.html" %}

{% block extrahead %}
{{ super() }}
<script type="text/javascript">
    if ( window !== window.parent ) {
        // The page is in an iframe
        window.addEventListener("DOMContentLoaded", function externalLinks() {
            var anchors = document.getElementsByTagName("a");
            for (var i = 0; i < anchors.length; i++) {
                    if (anchors[i].hostname !== window.location.hostname) {
                        anchors[i].setAttribute("target", "_blank");
                        anchors[i].setAttribute("rel", "noopener");
                    }
                    // Handle 'Open in SWAN' badges in the parent JupyterLab window
                    if (anchors[i].hostname == 'cern.ch' && anchors[i].pathname == '/swanserver/cgi-bin/go') {
                        const projectUrl = new URLSearchParams(anchors[i].search).get('projurl');
                        if (projectUrl) {
                                anchors[i].onclick = () => {
                                window.parent.postMessage(projectUrl,'*');
                                //  Skip redirecting the iframe page to the link 
                                return false;
                            }
                        }
                    }
            }
        }); 
    }
</script>
{% endblock %}

{% block styles %}
{{ super() }}
<link rel="stylesheet" type="text/css" href="{{ 'css/fonts.css' | url }}" />
<link rel="stylesheet" type="text/css" href="{{ 'css/style.css' | url }}" />
{% endblock %}

