$(function()
{
    const $ = window.$ == undefined ? parent.$ : window.$;
    const windowHeight   = $(window).height();
    let   headerHeight   = parseInt($('#header').height());
    let   mainNavbar     = parseInt($('#mainNavbar').height());
    let   mainMenuHeight = parseInt($('#mainMenu').css('padding-top')) + parseInt($('#mainMenu').css('padding-bottom'));
    let   appTabsHeight  = parseInt($('#appTabs').height());
    let   appsBarHeight  = parseInt($('#appsBar').height());
    let   tabsHeight     = parseInt($('#fileTabs .tabs-navbar').height());

    headerHeight   = headerHeight ? headerHeight : 0;
    appsBarHeight  = appsBarHeight ? appsBarHeight : 0;
    tabsHeight     = tabsHeight ? tabsHeight : 0;
    appTabsHeight  = appTabsHeight ? appTabsHeight : 0;
    mainMenuHeight = mainMenuHeight ? mainMenuHeight : 0;
    mainNavbar     = mainNavbar ? mainNavbar : 0;

    const iframeHeight = windowHeight - headerHeight - appsBarHeight - tabsHeight - appTabsHeight - mainMenuHeight - mainNavbar;
    $('#arrangePipeline').css('height', iframeHeight);

    window.addEventListener('message', (event) =>
    {
        const origin = event.origin.replace('https://', 'http://');
        const gitUrl = serverUrl.replace('https://', 'http://');
        if(origin == gitUrl)
        {
            if(event.data.type == 'execution-start')
            {
                window.removeEventListener('message', function(){});
                setTimeout(function()
                {
                    loadPage($.createLink('job', 'browse', 'repoID=' + repoID));
                }, 2000)
            }
        }
    })
});
