Skip to content
Snippets Groups Projects
Verified Commit f9974faf authored by Laurent Heirendt's avatar Laurent Heirendt :airplane:
Browse files

remove autoredirect

parent b1a971ad
No related branches found
No related tags found
No related merge requests found
<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]);
}
});
}
function GetShortcutDestination() {
var s = window.location.href;
var pathArray = s.split('?');
// Cut the query if it exists
if (pathArray.length > 1) {
return pathArray[1];
} else {
return '';
}
}
function RedirectTo(newLocation) {
document.location.replace(newLocation);
}
// Pick the shortcut link destination from URL, like: `category:subcategory:card-name`
var sub = GetShortcutDestination();
// Define URLs
var internalPortalURL = 'https://r3-core.pages.uni.lu/howto-cards-internal';
var externalPortalURL = 'https://r3.pages.uni.lu/howto-cards';
// First, check whether internal pages are accessible...
var internalIndexURL = internalPortalURL + '/index.html';
UrlExists(internalIndexURL, function(status){
if(status === 200){
// If the internal pages are accessible, try to redirect into correct page
if (sub.length > 0) {
var internalCardURL = internalPortalURL + '/stable/internal/cards/' + sub;
UrlExists(internalCardURL, function(status){
if (status == 200) { // The sub-card is internal, and is accessible
RedirectTo(internalCardURL);
} else {
UrlExists(internalPortalURL + '/stable/external/cards/' + sub, function(status){
if (status == 200) { // if sub-card is internal in the external directory and exists
RedirectTo(internalPortalURL + '/stable/external/cards/' + sub);
} else {
RedirectTo(internalPortalURL + '/stable/404.html');
}
});
}
});
} else {
// The user did not request specific card, redirect him just to the stable index
var internalPortalIndexURL = internalPortalURL + '/stable';
var internalPortal404URL = internalPortalURL + '/stable/404.html';
UrlExists(internalPortalIndexURL, function(status){
if (status == 200) { // if page is accessible
RedirectTo(internalPortalIndexURL);
} else {
RedirectTo(internalPortal404URL);
}
});
}
} else {
// The internal pages are not accessible, therefore the user is redirected into correct external page
if (sub.length > 0) {
sub = 'external/cards/' + sub;
}
var externalPortalCardURL = externalPortalURL + '/stable/' + sub;
var externalPortal404URL = externalPortalURL + '/stable/404.html';
UrlExists(externalPortalURL + '/stable/' + sub, function(status){
if (status == 200) { // if sub-card is internal and exists
RedirectTo(externalPortalCardURL);
} else {
RedirectTo(externalPortal404URL);
}
});
}
});
</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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment