From f0bdc80a69f0b725348bbcce8ad3597fb1f9dc73 Mon Sep 17 00:00:00 2001
From: laurentheirendt <laurent.heirendt@uni.lu>
Date: Fri, 28 Jun 2019 13:51:34 +0200
Subject: [PATCH] add js to redirect

---
 .ci/.autoRedirect | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/.ci/.autoRedirect b/.ci/.autoRedirect
index abd039e0..7c6db074 100644
--- a/.ci/.autoRedirect
+++ b/.ci/.autoRedirect
@@ -1,6 +1,28 @@
 <html>
   <head>
-    <meta http-equiv="Refresh" content="0; url=https://r3.pages.uni.lu/labCards/stable" />
+    <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',
+            complete:  function(xhr){
+                if(typeof cb === 'function')
+                cb.apply(this, [xhr.status]);
+            }
+        });
+    }
+    UrlExists('https://r3-core.pages.uni.lu/labCards/index.html', function(status){
+        if(status === 200){
+            // internal pages
+            window.location.href = 'https://r3-core.pages.uni.lu/labCards/stable';
+        } else {
+            // external pages
+            window.location.href = 'https://r3.pages.uni.lu/labCards/stable';
+        }
+    });
+    </script>
   </head>
   <body>
     <p>
-- 
GitLab