Add: js script for external link confirmation
This commit is contained in:
parent
e747d28d63
commit
a0aba71291
1 changed files with 29 additions and 0 deletions
29
archivist/static/js/confirm_external_links.js
Normal file
29
archivist/static/js/confirm_external_links.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// static/js/confirm_external_links.js
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
var externalLinks = document.querySelectorAll("a[href^='http']:not([href*='" + window.location.host + "'])");
|
||||||
|
|
||||||
|
for (var i = 0; i < externalLinks.length; i++) {
|
||||||
|
externalLinks[i].addEventListener("click", function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
var confirmationModal = new bootstrap.Modal(document.getElementById('externalLinkConfirmationModal'), {
|
||||||
|
keyboard: false
|
||||||
|
});
|
||||||
|
|
||||||
|
var externalLink = document.getElementById('externalLink');
|
||||||
|
var externalLinkShow = document.getElementById('externalLinkShow');
|
||||||
|
var originalLink = this.href;
|
||||||
|
|
||||||
|
externalLink.setAttribute('href', originalLink);
|
||||||
|
|
||||||
|
externalLinkShow.innerText = "URL: " + this.href;
|
||||||
|
|
||||||
|
confirmationModal.show();
|
||||||
|
|
||||||
|
externalLink.addEventListener('click', function () {
|
||||||
|
confirmationModal.hide();
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in a new issue