Skip to content

Commit

Permalink
remove dom listener
Browse files Browse the repository at this point in the history
  • Loading branch information
tsolakoua authored Dec 18, 2023
1 parent 24c680e commit 05aea04
Showing 1 changed file with 11 additions and 37 deletions.
48 changes: 11 additions & 37 deletions overrides/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,24 @@
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) {
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;
}
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');
var href = target.getAttribute('href');
if (href.startsWith('https://developers.amadeus.com')) {
console.log('we are in the second if');
event.preventDefault();
window.location.href = href;
}
});
}
});
</script>
{% endblock %}

0 comments on commit 05aea04

Please sign in to comment.