1/* dachlast.de â Teilen & Einbetten (share.js) 2 Additiv: liest die vorhandenen Formularfelder, kodiert den Rechenstand in die URL 3 (?ma=â¦&mo=â¦), stellt ihn beim Laden wieder her und triggert die Berechnung. 4 Baut auÃerdem einen "Teilen"-Button (bei den Ergebnissen) und einen 5 "Einbetten"-Block (iframe-Snippet) ein. Ãndert die Rechenlogik NICHT. */ 6(function(){ 7 "use strict"; 8 var EMBED=/[?&]embed=1/.test(location.search); 9 // Feld-ID -> kurzer URL-Schlüssel 10 var MAP=[ 11 ["marke","ma"],["modell","mo"],["jahr","ja"], 12 ["zmarke","zm"],["zmodell","zt"],["zgewicht","zg"], 13 ["breite","br"],["hoehe","ho"],["gewicht","ge"],["traeger","tr"], 14 ["tempo","sp"],["strecke","st"] 15 ]; 16 var $=function(id){return document.getElementById(id);}; 17 function typActive(){ var h=$("b-hart"); return (h&&/(^|\s)on(\s|$)/.test(h.className))?"h":"s"; } 18 19 function readParams(){ 20 var p=new URLSearchParams(); 21 MAP.forEach(function(m){ var e=$(m[0]); if(e&&e.value!==""&&e.value!=null) p.set(m[1],e.value); }); 22 // Zelttyp nur mitgeben, wenn manuell (keine Modellwahl) relevant 23 p.set("ty",typActive()); 24 return p; 25 } 26 function buildUrl(){ return location.origin+location.pathname+"?"+readParams().toString(); } 27 28 function setSel(id,val){ 29 var e=$(id); if(!e||val==null||val==="") return; 30 e.value=val; e.dispatchEvent(new Event("change",{bubbles:true})); 31 } 32 function setInp(id,val){ 33 var e=$(id); if(!e||val==null||val==="") return; 34 e.value=val; e.dispatchEvent(new Event("input",{bubbles:true})); e.dispatchEvent(new Event("change",{bubbles:true})); 35 } 36 function restore(){ 37 var p=new URLSearchParams(location.search); 38 if(![].some.call(MAP,function(m){return p.has(m[1]);})) return; // nichts wiederherzustellen 39 // Auto (Kaskade marke -> modell) 40 setSel("marke",p.get("ma")); 41 setSel("modell",p.get("mo")); 42 setSel("jahr",p.get("ja")); 43 // Zelttyp (Button) vor manuellen Feldern 44 var ty=p.get("ty"); 45 if(ty==="h" && $("b-hart")) $("b-hart").click(); 46 else if(ty==="s" && $("b-soft")) $("b-soft").click(); 47 // Zelt (Kaskade zmarke -> zmodell) 48 setSel("zmarke",p.get("zm")); 49 setSel("zmodell",p.get("zt")); 50 setSel("zgewicht",p.get("zg")); 51 // Manuelle ZeltmaÃe / Route 52 setInp("breite",p.get("br")); setInp("hoehe",p.get("ho")); 53 setInp("gewicht",p.get("ge")); setInp("traeger",p.get("tr")); 54 setInp("tempo",p.get("sp")); setInp("strecke",p.get("st")); 55 // Berechnen 56 var go=$("go"); if(go) setTimeout(function(){ go.click(); },120); 57 } 58 59 function toast(msg){ 60 var t=document.createElement("div"); 61 t.textContent=msg; 62 t.style.cssText="position:fixed;left:50%;bottom:26px;transform:translateX(-50%);background:#222;color:#fff;padding:10px 16px;border-radius:8px;font:14px sans-serif;z-index:99999;opacity:0;transition:opacity .2s"; 63 document.body.appendChild(t); requestAnimationFrame(function(){t.style.opacity="1";}); 64 setTimeout(function(){t.style.opacity="0";setTimeout(function(){t.remove();},250);},1800); 65 } 66 function doShare(){ 67 var url=buildUrl(); 68 try{ history.replaceState(null,"",url); }catch(e){} 69 if(navigator.share){ navigator.share({title:"Dachzelt-Rechner â mein Ergebnis",url:url}).catch(function(){}); return; } 70 if(navigator.clipboard&&navigator.clipboard.writeText){ navigator.clipboard.writeText(url).then(function(){toast("Link kopiert â teilbar");},function(){prompt("Link kopieren:",url);}); } 71 else prompt("Link kopieren:",url); 72 } 73 74 function injectShareBtn(){ 75 var res=$("res"); if(!res||$("dl-share")) return; 76 var b=document.createElement("button"); 77 b.id="dl-share"; b.type="button"; b.textContent="ð Ergebnis teilen / Link kopieren"; 78 b.style.cssText="margin:10px 0 0;padding:.55em 1em;border:1px solid var(--line,#8883);border-radius:8px;background:var(--card,#8881);color:inherit;cursor:pointer;font-weight:600"; 79 b.addEventListener("click",doShare); 80 res.appendChild(b); 81 } 82 function injectEmbed(){ 83 if(EMBED) return; 84 var host=document.getElementById("allwerk"); if(!host||document.getElementById("dl-embed")) return; 85 var snippet='<iframe src="https://dachlast.de/?embed=1" width="100%" height="1100" style="border:0;max-width:820px" title="Dachzelt- & Dachlast-Rechner von dachlast.de" loading="lazy"></iframe>'; 86 var d=document.createElement("details"); d.id="dl-embed"; d.style.cssText="margin:16px 0;border:1px solid var(--line,#8883);border-radius:10px;padding:10px 14px"; 87 d.innerHTML='<summary style="cursor:pointer;font-weight:600">Diesen Rechner auf deiner Seite einbetten</summary>' 88 +'<p style="font-size:.9rem;color:var(--muted,#888);margin:.6em 0">
88Kostenlos für Blogs & Foren. Einfach den Code kopieren und einfügen:</p>' 89 +'<textarea id="dl-embcode" readonly rows="3" style="width:100%;font:12px monospace;padding:8px;border-radius:6px;border:1px solid var(--line,#8883);background:var(--bg,#fff);color:inherit"></textarea>' 90 +'<button id="dl-embcopy" type="button" style="margin-top:8px;padding:.5em 1em;border:1px solid var(--line,#8883);border-radius:8px;background:var(--card,#8881);color:inherit;cursor:pointer;font-weight:600">Code kopieren</button>'; 91 host.appendChild(d); 92 var ta=d.querySelector("#dl-embcode"); ta.value=snippet; 93 d.querySelector("#dl-embcopy").addEventListener("click",function(){ 94 ta.select(); 95 if(navigator.clipboard) navigator.clipboard.writeText(snippet).then(function(){toast("Einbett-Code kopiert");}); 96 else { document.execCommand&&document.execCommand("copy"); toast("Einbett-Code kopiert"); } 97 }); 98 } 99 100 function init(){ injectShareBtn(); injectEmbed(); } 101 if(document.readyState==="complete"||document.readyState==="interactive"){ setTimeout(init,0); } 102 else document.addEventListener("DOMContentLoaded",init); 103 // Wiederherstellung erst nach Rechner-Initialisierung 104 window.addEventListener("load",function(){ setTimeout(restore,400); }); 105})();
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.