Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
.autoRedirect 2.83 KiB
<html>
  <head>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script type="text/javascript">
    function UrlExists(url, cb){
        jQuery.ajax({
            url:      url,
            dataType: 'text',
            type:     'GET',
            cache:    false,
            complete:  function(xhr){
                if(typeof cb === 'function')
                cb.apply(this, [xhr.status]);
            }
        });
    }

    // define URLs
    var internalURL = 'https://r3-core.pages.uni.lu/howto-cards-internal';
    var externalURL = 'https://r3.pages.uni.lu/howto-cards';

    UrlExists(internalURL+'/index.html', function(status){
        var s = window.location.href;
        var pathArray = s.split('?');

        // cut the query if it exists
        if (pathArray.length > 1) {
            sub = pathArray[1];
        } else {
            sub = '';
        }

        if(status === 200){
            // internal pages
            if (sub.length > 0) {
                UrlExists(internalURL+'/stable/internal/'+sub, function(status){
                    if (status == 200) { // if sub-card is internal in the internal directory and exists
                        window.location.href = internalURL+'/stable/internal/'+sub;
                    } else {
                        UrlExists(internalURL+'/stable/external/'+sub, function(status){
                            if (status == 200) { // if sub-card is internal in the external directory and exists
                                window.location.href = internalURL+'/stable/external/'+sub;
                            } else {
                                window.location.href = internalURL+'/404.html';
                            }
                        });
                    }
                });
            } else {
                UrlExists(internalURL+'/stable', function(status){
                    if (status == 200) { // if card is internal and exists
                        window.location.href = internalURL+'/stable';
                    } else {
                        window.location.href = internalURL+'/404.html';
                    }
                });
            }
        // external pages
        } else {
            if (sub.length > 0) { sub = 'external/'+sub; }
            UrlExists(externalURL+'/stable/'+sub, function(status){
                if (status == 200) { // if sub-car is internal and exists
                    window.location.href = externalURL+'/stable/'+sub;
                } else {
                    window.location.href = externalURL+'/404.html';
                }
            });
        }
    });
    </script>
  </head>
  <body>
    <p>
      Please follow to <a href="https://r3.pages.uni.lu/howto-cards/stable">https://r3.pages.uni.lu/howto-cards/stable</a>!
    </p>
  </body>
</html>