diff --git a/input/static/dropdown/js/otrs_link.js b/input/static/dropdown/js/otrs_link.js index 778bb43..3420e9f 100644 --- a/input/static/dropdown/js/otrs_link.js +++ b/input/static/dropdown/js/otrs_link.js @@ -1,19 +1,25 @@ window.addEventListener("load", function() { -(function($) { - $(function() { + (function($) { + $(function() { - let otrs_link = document.querySelector(".field-otrs > div > p.url > a").href; - console.log(otrs_link); - alert(otrs_link); + // let linkElement = document.querySelector(".field-otrs > div > p.url > a"); + let linkElement = document.querySelector(".field-otrs p.url a"); + if (!linkElement) { + console.error("OTRS-Link not found!"); + return; + } - let otrs_link_pret = otrs_link.replace(/%3B/g, ";"); - let otrs_link_pretty = otrs_link_pret.replace(/%3D/g, "="); - - console.log(otrs_link_pretty); - - document.querySelector(".field-otrs > div > p.url > a").href = otrs_link_pretty; - + let otrs_link = linkElement.href; + //console.log("Original link:", otrs_link); + //alert("Original link: " + otrs_link); - }); -})(django.jQuery); + // Ersetze %3B mit ; und %3D mit = + let otrs_link_pretty = otrs_link.replace(/%3B/g, ";").replace(/%3D/g, "="); + + //console.log("Modified link:", otrs_link_pretty); + linkElement.href = otrs_link_pretty; + + }); + })(django.jQuery); }); +