PageSourceSearch

https://www.maerkteundtrends.de/mt-public-author-v2080.js?v=2

js maerkteundtrends.de collected 2026-10-04 20:02:25 UTC 6,597 bytes, 55 lines download raw bytes

1/* V2080 · Öffentliche Beiträge machen das Autorenprofil sichtbar.
2   - Bestätigungsdialog vor dem ersten öffentlichen Beitrag (Server verlangt die Bestätigung).
3   - Schalter „Öffentliches Profil“ in Mein Konto. Alle Werte werden serverseitig gespeichert. */
4(function(){
5 if(window.__mtPubAuthor2080)return;window.__mtPubAuthor2080=1;
6 var CSS='.mtpa-bg{position:fixed;inset:0;z-index:2147483100;background:rgba(5,12,22,.72);display:flex;align-items:center;justify-content:center;padding:16px}'+
7 '.mtpa{max-width:480px;width:100%;background:#0f2233;color:#fff;border:1px solid rgba(255,255,255,.14);border-radius:16px;box-shadow:0 24px 60px rgba(0,0,0,.5);padding:24px;font:15px/1.5 inherit}'+
8 '.mtpa h2{margin:0 0 10px;font-size:20px;color:#ffca28}.mtpa p{margin:0 0 18px;color:#e6edf3}.mtpa .b{display:flex;gap:10px;flex-wrap:wrap;justify-content:flex-end}'+
9 '.mtpa button{cursor:pointer;border-radius:10px;padding:10px 16px;font-weight:700;border:1px solid rgba(255,255,255,.25);background:transparent;color:#fff}.mtpa button.y{background:#ffca28;color:#0d1b2a;border-color:#ffca28}'+
10 '.mtpp{margin:0 0 20px;padding:22px}.mtpp h2{margin:0 0 6px}.mtpp label{display:flex;gap:10px;align-items:flex-start;margin:10px 0;cursor:pointer}.mtpp small{opacity:.75;display:block}.mtpp .msg{min-height:20px;font-size:13px;margin-top:6px}.mtpp .sub label{margin-left:28px;font-size:14px}';
11 function css(){if(document.getElementById('mtpaCss'))return;var s=document.createElement('style');s.id='mtpaCss';s.textContent=CSS;document.head.appendChild(s)}
12 function dialog(){return new Promise(function(res){css();var bg=document.createElement('div');bg.className='mtpa-bg';
13  bg.innerHTML='<div class="mtpa" role="dialog" aria-modal="true" aria-labelledby="mtpaH"><h2 id="mtpaH">Dein Beitrag wird öffentlich sichtbar</h2><p>Mit diesem öffentlichen Beitrag werden dein Anzeigename, dein @Benutzername und dein Profilbild bzw. deine Initialen als Autor angezeigt. Dein Profil ist über diesen Beitrag erreichbar. Private Konto-, Watchlist- und Depotdaten bleiben geschützt.</p><div class="b"><button type="button" data-a="back">Zurück zur Sichtbarkeit</button><button type="button" class="y" data-a="ok">Öffentlich veröffentlichen</button></div></div>';
14  function done(v){bg.remove();res(v)}
15  bg.addEventListener('click',function(e){var a=e.target&&e.target.getAttribute&&e.target.getAttribute('data-a');if(a)done(a==='ok');else if(e.target===bg)done(false)});
16  document.addEventListener('keydown',function k(e){if(e.key==='Escape'){document.removeEventListener('keydown',k);if(bg.isConnected)done(false)}});
17  document.body.appendChild(bg);bg.querySelector('.y').focus()})}
18 var of=window.fetch.bind(window);
19 window.fetch=function(input,init){
20  var u=typeof input==='string'?input:(input&&input.url)||'';
21  var m=(init&&init.method)||(input&&input.method)||'GET';
22  if(!/\/api\/members\/post(\?|$)/.test(u.replace(location.origin,''))||String(m).toUpperCase()!=='POST'||!init||typeof init.body!=='string')return of(input,init);
23  return of(input,init).then(function(r){
24   if(r.status!==409)return r;
25   return r.clone().json().catch(function(){return{}}).then(function(j){
26    if(!j||j.code!=='PUBLIC_PROFILE_CONFIRM_REQUIRED')return r;
27    return dialog().then(function(ok){
28     if(!ok)return new Response(JSON.stringify({error:'Nicht veröffentlicht. Du kannst die Sichtbarkeit jetzt ändern.',code:'PUBLIC_PROFILE_CANCELLED'}),{status:409,headers:{'Content-Type':'application/json'}});
29     var b;try{b=JSON.parse(init.body)}catch(_){return r}
30     b.confirm_public_profile=true;
31     return of(input,Object.assign({},init,{body:JSON.stringify(b)}));
32    });
33   });
34  });
35 };
36 /* Mein Konto → Öffentliches Profil */
37 if(!/^\/mein-konto/.test(location.pathname))return;
38 function api(body){return of('/api/members/'+(body?'profile':'me'),{method:body?'POST':'GET',credentials:'same-origin',headers:body?{'Content-Type':'application/json'}:{},body:body?JSON.stringify(body):undefined}).then(function(r){return r.json().catch(function(){return{}}).then(function(j){j.__s=r.status;return j})})}
39 var host=document.createElement('section');host.id='mtPublicProfile';host.className='card mtpp';
40 function msg(t,bad){var m=host.querySelector('.msg');if(m){m.textContent=t;m.style.color=bad?'#e5484d':''}}
41 function render(p){var pp=p.public_profile||{};
42  host.innerHTML='<h2>Öffentliches Profil</h2><label><input type="checkbox" data-k="public_profile_enabled"'+(pp.enabled?' checked':'')+'><span><b>Mein Profil darf über meine öffentlichen Beiträge gefunden werden</b><small>Wenn du öffentliche Beiträge veröffentlichst, sehen Besucher deinen Anzeigenamen, @Benutzernamen und dein öffentliches Profil. Private Daten bleiben geschützt.</small></span></label>'+
43  '<div class="sub"'+(pp.enabled?'':' hidden')+'><label><input type="checkbox" data-k="public_avatar_visible"'+(pp.avatar_visible!==false?' checked':'')+'> Profilbild öffentlich zeigen</label><label><input type="checkbox" data-k="public_bio_visible"'+(pp.bio_visible!==false?' checked':'')+'> Kurzbeschreibung öffentlich zeigen</label><label><input type="checkbox" data-k="public_interests_visible"'+(pp.interests_visible!==false?' checked':'')+'> Interessen öffentlich zeigen</label></div>'+
44  (pp.enabled&&p.username?'<small>Dein öffentliches Profil: <a href="/mitglied/'+encodeURIComponent(p.username)+'">/mitglied/'+String(p.username).replace(/[<>&"]/g,'')+'</a></small>':'')+'<div class="msg" role="status"></div>'}
45 function save(body,box){api(body).then(function(j){
46  if(j.code==='PUBLIC_POSTS_EXIST'){
47   if(confirm(j.error+'\n\nOK = alle öffentlichen Beiträge auf „Nur Community“ umstellen.\nAbbrechen = nichts ändern.'))return save(Object.assign({},body,{demote_public_posts:true}),box);
48   box.checked=true;return msg('Nichts geändert.')}
49  if(j.__s>=400||j.error){box.checked=!box.checked;return msg(j.error||'Speichern fehlgeschlagen.',true)}
50  render(j.profile||{});msg('Gespeichert.')})}
51 host.addEventListener('change',function(e){var k=e.target.getAttribute('data-k');if(!k)return;var b={};b[k]=e.target.checked;save(b,e.target)});
52 function mount(n){var head=document.querySelector('.account-head');
52if(!head){if((n||0)<80)setTimeout(function(){mount((n||0)+1)},100);return}
53  api().then(function(j){if(!j.profile)return;css();render(j.profile);var after=document.getElementById('mtCommunitySettings')||head;after.insertAdjacentElement('afterend',host)})}
54 if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',function(){mount(0)});else mount(0);
55})();

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.