Skip to content
Snippets Groups Projects
Select Git revision
  • 5475ba6b933b20330350eb1a41df68381020efab
  • master default
  • renovate/junit-jupiter-engine.version
  • renovate/selenium.version
  • renovate/testcontainer.version
  • demo
  • v1_8_1
  • v2.18.1
  • v2.18.0
  • v2.17.2
  • v2.17.1
  • v2.17.0
  • v2.16.1
  • v2.16.0
  • v2.15.1
  • v2.15.0
  • v2.14.0
  • v2.13.0
  • v2.12.0
  • v2.11.0
  • v2.10.0
  • v2.9.2
  • v2.9.1
  • v2.9.0
  • v2.8.0
  • testPipeline2
  • v2.7.0
27 results

main.js

Blame
  • main.js 3.22 KiB
    $(document).ready(function()
    {
        $('#button-logout').click(function()
        {
            document.getElementById('logout-form').submit();
        });
    
        $('#globalAccountSelect').click(function()
        {
            fetchAndShowModal(this, 'globalAccountSelectModalOnDemand', '#modalGlobalAccountSelect');
            enableAccountSelectHotKeys();
        });
    
        $('.sidenav').sidenav();
    
        $('.modal').modal();
    
        if($("#modalBackupReminder").length)
        {
            $('#modalBackupReminder').modal('open');
        }
    
        if($("#whatsNewModelContainer").length)
        {
            fetchAndShowModal(document.getElementById('whatsNewModelContainer'), 'whatsNewModelContainer', '#modalWhatsNew');
        }
    
        if($("#modalMigration").length)
        {
            $('#modalMigration').modal('open');
        }
    
        $('.tooltipped').tooltip();
    
        $('select').formSelect();
    
        if($("#login-password").length)
        {
            document.getElementById("login-password").focus();
        }
    
        $("#buttonSearch").click(function()
        {
            document.getElementById("navbarSearchForm").submit();
        });
    
        $("#buttonClearSearch").click(function()
        {
            document.getElementById("search").value = "";
        });
    
        $('.notification-clear').click(function()
        {
            document.getElementById(this.dataset.id).style.display = "none";
        });
    
        $('.hint-clear').click(function()
        {
            document.getElementById(this.dataset.id).style.display = "none";
    
            $.ajax({
                type: 'GET',
                url: $(this).attr('data-url'),
                data: {}
            });
        });
    });
    
    function fetchAndShowModal(item, containerID, modalID)
    {
        let modal = $(modalID).modal();
        if(modal.isOpen)
        {
            return;
        }
    
        $.ajax({
            type: 'GET',
            url: $(item).attr('data-url'),
            data: {},
            success: function(data)
            {
                $('#' + containerID).html(data);
                $(modalID).modal();
                $(modalID).modal('open');
            }
        });
    }
    
    function addClass(element, className)
    {
        if(element != null)
        {
            if(!element.classList.contains(className))
            {
                element.classList.add(className);
            }
        }
    }
    
    function removeClass(element, className)
    {
        if(element != null)
        {
            if(element.classList.contains(className))
            {
                element.classList.remove(className);
            }
        }
    }
    
    function rgb2hex(rgb)
    {
        let rgba = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+\.{0,1}\d*))?\)$/).slice(1);
        let convertedParts = rgba.map((n, i) => (i === 3 ? Math.round(parseFloat(n) * 255) : parseFloat(n))
                .toString(16)
                .padStart(2, '0')
                .replace('NaN', ''));
    
        return '#' + convertedParts.join('');
    }
    
    function validateLoginForm()
    {
        let passwordInput = document.getElementById('login-password');
        passwordInput.value = passwordInput.value.trim();
    }
    
    function enableAccountSelectHotKeys()
    {
        Mousetrap.bind(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], function(e)
        {
            if(areHotKeysEnabled())
            {
                let accountItem = document.querySelector('.global-account-select-option[data-account-index="' + e.key + '"]');
                if(accountItem !== null)
                {
                    accountItem.click();
                }
            }
        });
    }