1const mainlocation = window.location.href; 2 3if(mainlocation.includes("media")){ 4 5const tree=document.querySelector('#media__tree'); 6 7 8const inputfield=document.createElement('input'); 9inputfield.id="addnamespace"; 10//inputfield.outerHTML+="<br>"; 11inputfield.style.width="150px"; 12inputfield.placeholder="enter namespace"; 13 14const addnamespace=document.createElement('button'); 15//addnamespace.outerHTML="<br>"; 16addnamespace.innerText="Add"; 17//addnamespace.href="#"; 18addnamespace.style.width="50px"; 19addnamespace.addEventListener('click', function(){ 20 21 let url=window.location.href; 22 let index=url.indexOf("doku.php"); 23 index=index+8; 24 let remove=url.substring(index); 25 let newurl=url.replace(remove,""); 26 let location=document.getElementsByClassName("panelHeader")[1].childNodes[1].childNodes[1].innerHTML; 27 if(location!="[root]"){ 28 newurl=newurl+"?id=start&do=media&ns="+location+":"+document.getElementById("addnamespace").value; 29 30 window.location.href=newurl; 31 }else{ 32 alert("Cant create in root!"); 33 } 34}); 35 36 37inputfield.addEventListener("keypress", function(event) { 38 // If the user presses the "Enter" key on the keyboard 39 if (event.key === "Enter") { 40 // Cancel the default action, if needed 41 event.preventDefault(); 42 // Trigger the button element with a click 43 44 let url=window.location.href; 45 let index=url.indexOf("doku.php"); 46 index=index+8; 47 let remove=url.substring(index); 48 let newurl=url.replace(remove,""); 49 let location=document.getElementsByClassName("panelHeader")[1].childNodes[1].childNodes[1].innerHTML; 50 if(location!="[root]"){ 51 newurl=newurl+"?id=start&do=media&ns="+location+":"+document.getElementById("addnamespace").value; 52 53 window.location.href=newurl; 54 }else{ 55 alert("Cant create in root!"); 56 } 57 } 58}); 59 60tree.prepend(addnamespace); 61tree.prepend(inputfield); 62//inputfield.outerHTML+="<br>"; 63} 64