Skip to content

Commit

Permalink
update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
tsolakoua authored Dec 18, 2023
1 parent dca8a8e commit 24c680e
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion overrides/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,35 @@
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}" />`);
}

// Event listener for link clicks
window.addEventListener('DOMContentLoaded', (event) => {
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.startsWith('https://developers.amadeus.com')) {
console.log('we are in the second if from second script');
event.preventDefault();
window.location.href = href;
}
}
});
});
</script>
{% endblock %}

{% block scripts %}
<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}" />`);
}
// Event listener for link clicks
window.addEventListener('DOMContentLoaded', (event) => {
document.body.addEventListener('click', function (event) {
Expand All @@ -34,4 +58,4 @@
});
});
</script>
{% endblock %}
{% endblock %}

0 comments on commit 24c680e

Please sign in to comment.