1 2window.onload = function () { 3 if (document.getElementById("merkzettel-wrap")) { 4 if (!document.querySelector('[type="application/ld+json"]')) { 5 return; 6 } 7 const ldJsonArr = document.querySelectorAll('[type="application/ld+json"]'); 8 var ldJson = false; 9 ldJsonArr.forEach(function (ldJsonText){ 10 let tmp = JSON.parse(ldJsonText.text); 11 if (!Array.isArray(tmp) && ['Place','Restaurant','Event','Hotel','Offer'].some(function (r) { 12 return tmp['@type'].includes(r) 13 })) { 14 ldJson = tmp; 15 } 16 }); 17 if (ldJson) { 18 async function fetchEntries() { 19 const response = await fetch('/?type=2021041206', { 20 method: "GET", 21 mode: "same-origin", 22 cache: "no-cache", 23 credentials: "same-origin", 24 headers: { 25 "Content-Type": "application/json", 26 }, 27 redirect: "follow", 28 referrerPolicy: "no-referrer" 29 }); 30 return response.json(); 31 } 32 async function addEntry(ldJson) { 33 const response = await fetch('/?type=2021041201&no_cache=1', { 34 method: "POST", 35 mode: "same-origin", 36 cache: "no-cache", 37 credentials: "same-origin", 38 headers: { 39 'Content-Type': 'application/x-www-form-urlencoded', 40 'Accept': 'application/json' 41 }, 42 redirect: "follow", 43 referrerPolicy: "no-referrer", 44 body: "itemData="+encodeURIComponent(JSON.stringify(ldJson)) 45 }); 46 return response.json(); 47 } 48 async function removeEntry(id) { 49 const response = await fetch('/?type=2021041202&no_cache=1', { 50 method: "POST", 51 mode: "same-origin", 52 cache: "no-cache", 53 credentials: "same-origin", 54 headers: { 55 'Content-Type': 'application/x-www-form-urlencoded', 56 'Accept': 'application/json' 57 }, 58 redirect: "follow", 59 referrerPolicy: "no-referrer", 60 body: encodeURI("id="+id) 61 }); 62 return response.json(); 63 } 64 var id = ldJson['@type'][0] + "_" + ldJson['identifier']; 65 fetchEntries().then((planerEntries) => { 66 var isInPlaner = (Object.keys(planerEntries.ids).indexOf(id) != -1) ? true : false; 67 if (isInPlaner) { 68 document.getElementById('removeToMerkzettel')?.classList.remove("hidden"); 69 } else { 70 document.getElementById('addToMerkzettel')?.classList.remove("hidden"); 71 } 72 document.getElementById('addToMerkzettel').addEventListener('click', function (e) { 73 e.preventDefault(); 74 addEntry(ldJson).then((data) => { 75 document.getElementById('addToMerkzettel')?.classList.add("hidden"); 76 document.getElementById('removeToMerkzettel')?.classList.remove("hidden"); 77 }); 78 }); 79 document.getElementById('removeToMerkzettel').addEventListener('click', function (e) { 80 e.preventDefault(); 81 removeEntry(id).then((data) => { 82 document.getElementById('removeToMerkzettel')?.classList.add("hidden"); 83 document.getElementById('addToMerkzettel')?.classList.remove("hidden"); 84 }); 85 }); 86 }); 87 } 88 } 89}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.