Skip to content

Commit

Permalink
new method
Browse files Browse the repository at this point in the history
  • Loading branch information
tsolakoua authored Dec 18, 2023
1 parent 798299e commit f551876
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions overrides/main.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
{#-
This file was automatically generated - do not edit
-#}

{% extends "base.html" %}
{% block extrahead %}
<script>
if (window.location.hostname === 'amadeus4dev.github.io') {
console.log('first script');
const path = window.location.pathname;
const redirectPattern = /^\/([^/]+)/;
const redirectUrl = path.replace(redirectPattern, 'https://developers.amadeus.com/self-service/apis-docs/guides/$1');
document.write(`<meta http-equiv="refresh" content="0;url=${redirectUrl}" />`);
}
</script>
{% endblock %}

{% block scripts %}
<script>
// Event listener for link clicks
window.addEventListener('DOMContentLoaded', (event) => {
console.log('Script loaded');

// Initial redirection logic
if (window.location.hostname === 'amadeus4dev.github.io' || window.location.hostname === 'developer.amadeus.com') {
console.log('Initial redirection');
const path = window.location.pathname;
const redirectPattern = /^\/([^/]+)/;
const redirectUrl = path.replace(redirectPattern, 'https://developers.amadeus.com/self-service/apis-docs/guides/$1');
window.location.href = redirectUrl;
}

// Event listener for link clicks
document.body.addEventListener('click', function (event) {
var target = event.target;
console.log('we are in the second script');
if (target.tagName === 'A') {
console.log('we are in the first if from second script');
var href = target.getAttribute('href');
if (href.includes('developers.amadeus.com')) {
console.log('we are in the second if from second script');
event.preventDefault();
console.log('Link click redirection');
window.location.href = href;
}
}
Expand Down

0 comments on commit f551876

Please sign in to comment.