PageSourceSearch

https://french-stream.net/js/fss-comments-u41.js

js french-stream.net collected 2026-10-10 00:23:11 UTC 11,016 bytes, 188 lines download raw bytes

1(function(){
2  function esc(s){ return String(s).replace(/[<>&"]/g,function(c){return {'<':'&lt;','>':'&gt;','&':'&amp;','"':'&quot;'}[c];}); }
3  function label(n,show){ var body=n>1?('les '+n+' réponses'):'la réponse'; return (show?'Afficher ':'Masquer ')+body; }
4  function idOf(li){ var m=(li.id||'').match(/comments-tree-item-(\d+)/); return m?m[1]:null; }
5  function depth(li){ var d=0,p=li.parentNode; while(p){ if(p.nodeType===1&&p.classList&&p.classList.contains('comments-tree-item'))d++; p=p.parentNode; } return d; }
6  function hasAncestorItem(node){ var p=node.parentNode; while(p){ if(p.nodeType===1&&p.classList&&p.classList.contains('comments-tree-item'))return true; p=p.parentNode; } return false; }
7  function _fssMember(){ try{ var m=(document.cookie||'').match(/(?:^|;\s*)dle_user_id=(\d+)/); if(m&&parseInt(m[1],10)>0)return true; }catch(e){} return !!document.getElementById('add-comm-form'); }
8  var canReply=(typeof window.dle_login_hash==='string'&&window.dle_login_hash.length>2)&&_fssMember();
9
10  function speedupEditor(){
11    var $=window.jQuery||window.$; if(!$) return;
12    if($.fx){ var prev=$.fx.off; $.fx.off=true; setTimeout(function(){ try{ $.fx.off=prev; }catch(e){} },1600); }
13    var t=0,iv=setInterval(function(){ t++; try{ var el=$('[id^="dlefastreplycomments"]'); if(el&&el.length){ el.stop(true,true).show(); } }catch(_){} if(t>55) clearInterval(iv); },30);
14  }
15  function addReply(li){
16    if(li.getAttribute('data-fssr')) return;
17    li.setAttribute('data-fssr','1');
18    if(!canReply||typeof window.dle_reply!=='function') return;
19    var id=idOf(li); if(!id) return;
20    var host=document.getElementById('comment-id-'+id)||li;
21    if(host.querySelector('.fss-reply-btn')) return;
22    var ind=depth(li);
23    var b=document.createElement('a');
24    b.href='#'; b.className='fss-reply-btn';
25    b.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true"><path d="M10 9V5l-7 7 7 7v-4c5 0 8 1.5 10 5-1-5-4-10-10-10z"/></svg>Répondre';
26    b.addEventListener('click',function(e){ e.preventDefault(); try{ window.dle_reply(id,ind,'1'); }catch(_){} speedupEditor(); });
27    var tgt=host.querySelector('.comm-right')||host.querySelector('.comm-item')||host;
28    tgt.appendChild(b);
29  }
30
31  var _loaded=false;
32  function fmtPremium(pd){
33    try{
34      if(pd.getAttribute('data-fssp')) return;
35      var d=(pd.textContent||'').replace(/\s+/g,' ').trim();
36      if(!d) return;
37      if(/^Depuis\s/i.test(d)){ pd.setAttribute('data-fssp','1'); return; }
38      var dm=d.match(/(\d{1,2})\.(\d{1,2})\.(\d{4})/);
39      var rd=dm?new Date(parseInt(dm[3],10),parseInt(dm[2],10)-1,parseInt(dm[1],10)):null;
40      if(rd&&!isNaN(rd.getTime())){
41        var now2=new Date();
42        var days2=Math.floor((now2-rd)/86400000); if(days2<0)days2=0;
43        var mo2=(now2.getFullYear()-rd.getFullYear())*12+(now2.getMonth()-rd.getMonth());
44        if(now2.getDate()<rd.getDate())mo2=mo2-1; if(mo2<0)mo2=0;
45        var rel;
46        if(days2<1)rel="aujourd'hui";
47        else if(mo2<1)rel=days2+(days2===1?' jour':' jours');
48        else if(mo2<12)rel=mo2+' mois';
49        else{var yy2=Math.floor(mo2/12);rel=yy2+(yy2===1?' an':' ans');}
50        pd.textContent='Depuis '+rel;
51        pd.setAttribute('data-fssp','1');
52        return;
53      }
54      var annee='';
55      if(/^Premium\s+Depuis/i.test(d)) annee=d.split(' ').pop();
56      else if(d.indexOf('.')>=0) annee=d.split('.').pop();
57      else if(/^\d{4}$/.test(d)) annee=d;
58      if(/^\d{4}$/.test(annee)){ pd.textContent='Depuis '+annee; pd.setAttribute('data-fssp','1'); }
59    }catch(e){}
60  }
61  function formatPremiums(){
62    if(!_loaded) return;
63    var pds=document.querySelectorAll('.premium-date');
64    for(var j=0;j<pds.length;j++){ fmtPremium(pds[j]); }
65  }
66
67  function parentCard(ol){
68    var li=ol.parentNode; if(!li||!li.children) return null;
69    var ch=li.children;
70    for(var i=0;i<ch.length;i++){ var el=ch[i]; if((el.id&&el.id.indexOf('comment-id-')===0)||(el.classList&&el.classList.contains('comm-item'))){ return el.querySelector('.comm-item')||el; } }
71    return null;
72  }
73  function authorOf(card){
74    if(!card) return '';
75    var st=card.querySelectorAll('strong');
76    for(var i=0;i<st.length;i++){ var t=(st[i].textContent||'').replace(/\s+/g,' ').trim(); var m=t.match(/^Par\s+(.+)$/i); if(m&&m[1].trim()) return m[1].trim(); }
77    var ca=card.querySelector('.comm-author'); if(ca){ var tt=(ca.textContent||'').replace(/\s+/g,' ').trim(); if(tt) return tt; }
78    return '';
79  }
80  function markReply(li){
81    if(li.getAttribute('data-fssrep')) return;
82    var ol=li.parentNode;
83    if(!ol||!ol.classList||!ol.classList.contains('comments-tree-list')) return;
84    var pcard=parentCard(ol);
85    if(!pcard) return;
86    var pa=authorOf(pcard);
87    if(!pa) return;
88    var id=idOf(li);
89    var myCard=(id&&document.getElementById('comment-id-'+id))||li.querySelector('.comm-item')||li;
90    var pd=myCard.querySelector('.premium-date');
91    if(!pd) return;
92    li.setAttribute('data-fssrep','1');
93    var ps=pd.previousSibling;
94    while(ps&&ps.nodeType===3&&!(ps.textContent||'').trim()) ps=ps.previousSibling;
95    if(ps&&ps.nodeType===3) ps.textContent=' ';
96    pd.setAttribute('data-fssp','1');
97    pd.classList.add('fss-inreply');
98    pd.innerHTML='en réponse à <b style="color:#fff!important;font-weight:600">'+esc(pa)+'</b>';
99  }
100
101  function collapse(ol){
102    if(ol.getAttribute('data-fssc')) return;
103    if(!hasAncestorItem(ol)) return;
104    ol.setAttribute('data-fssc','1');
105    var n=ol.querySelectorAll('li.comments-tree-item').length;
106    if(!n) return;
107    var tg=document.createElement('button');
108    tg.type='button'; tg.className='fss-toggle frtg';
109    tg.innerHTML='<span class="fss-tg-ic"><svg viewBox="0 0 24 24" width="17" height="17" aria-hidden="true"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"/></svg></span><span class="fss-tg-txt">'+label(n,true)+'</span><span class="fss-tg-arrow">&#9660;</span>';
110    ol.classList.add('fss-collapsed');
111    var slot=parentCard(ol);
112    if(slot){ var wrap=document.createElement('div'); wrap.className='fss-toggle-wrap'; wrap.appendChild(tg); slot.appendChild(wrap); }
113    else ol.parentNode.insertBefore(tg,ol);
114    tg.addEventListener('click',function(){
115      var collapsed=ol.classList.contains('fss-collapsed');
116      if(collapsed){
117        ol.classList.remove('fss-collapsed');
118        ol.classList.add('fss-anim');
119        setTimeout(function(){ ol.classList.remove('fss-anim'); },420);
120        tg.classList.add('open');
121        tg.querySelector('.fss-tg-txt').textContent=label(n,false);
122      } else {
123        ol.classList.add('fss-collapsed');
124        tg.classList.remove('open');
125        tg.querySelector('.fss-tg-txt').textContent=label(n,true);
126      }
127    });
128  }
129
130  function run(){
131    var it=document.querySelectorAll('li.comments-tree-item');
132    for(var i=0;i<it.length;i++){ try{ addReply(it[i]); }catch(e){} try{ markReply(it[i]); }catch(e){} }
133    var ols=document.querySelectorAll('ol.comments-tree-list');
134    for(var k=0;k<ols.length;k++){ try{ collapse(ols[k]); }catch(e){} }
135    formatPremiums();
136  }
137
138  var _mo=null,_deb=null;
139  function observe(){
140    var target=document.getElementById('dle-comments-list')||document.getElementById('comments');
141    if(!target||!window.MutationObserver) return;
142    function schedule(){ clearTimeout(_deb); _deb=setTimeout(function(){ if(_mo)_mo.disconnect(); try{ run(); }catch(e){} if(_mo)_mo.observe(target,{childList:true,subtree:true}); },120); }
143    _mo=new MutationObserver(schedule);
144    _mo.observe(target,{childList:true,subtree:true});
145  }
146
147  function init(){ run(); observe(); }
148  if(document.readyState==='loading') document.addEventListener('DOMContentLoaded',init); else init();
149  if(document.readyState==='complete'){ _loaded=true; formatPremiums(); }
150  else window.addEventListener('load',function(){ _loaded=true; formatPremiums(); });
151  window.fssCommentsRefresh=run;
152})();
153(function(){
154  function hid(){var h=location.hash||"";var m=h.match(/comment-id-(\d+)/)||h.match(/comments-tree-item-(\d+)/)||h.match(/#comment(\d+)/);return m?m[1]:null;}
155  function nid(){var f=document.getElementById("dle-comments-form");if(f){var p=f.post_id||(f.elements&&f.elements.post_id);if(p&&p.value&&/^\d+$/.test(p.value))return p.value;}var q=(location.search||"").match(/newsid=(\d+)/);if(q)return q[1];var m=(location.pathname||"").match(/(?:^|\/)(\d{3,})[-_,.]/);if(m)return m[1];if(window.dle_news_id)return String(window.dle_news_id);return null;}
156  function ucs(){var m=(location.search||"").match(/[?&]cstart=(\d+)/);return m?parseInt(m[1],10):0;}
157  function tgt(id){return document.getElementById("comment-id-"+id)||document.getElementById("comments-tree-item-"+id);}
158  function L(){return document.getElementById("dle-comments-list");}
159  function paint(el){if(!el)return;var c=(el.querySelector&&el.querySelector(".comm-item"))||el;try{c.style.transition="box-shadow .45s ease";c.style.boxShadow="0 0 0 2px #f48625,0 0 24px rgba(244,134,37,.6)";c.style.borderRadius="8px";setTimeout(function(){try{c.style.boxShadow="";}catch(e){}},3200);}catch(e){}}
160  function expand(el){var p=el,h=0;while(p&&p!==document.body&&h++<60){if(p.classList&&p.classList.contains("fss-collapsed"))p.classList.remove("fss-collapsed");p=p.parentElement;}}
161  function reveal(id){var n=0;var iv=setInterval(function(){n++;var el=tgt(id);if(el){expand(el);if(n>=7){clearInterval(iv);try{el.scrollIntoView({block:"center",behavior:"smooth"});}catch(e){try{el.scrollIntoView();}catch(_){}}paint(el);}}else if(n>14){clearInterval(iv);}},240);}
162  var _busy=false;
163  function seek(retry){
164    var id=hid();if(!id)return;
165    var el=tgt(id);if(el){reveal(id);return;}
166    if(_busy)return;
167    var news=nid();if(!news)return;
168    if(typeof window.CommentsPage!=="function"){if((retry||0)<25)setTimeout(function(){seek((retry||0)+1);},300);return;}
169    var uc=ucs();var cands=[];function add(v){if(v>1&&cands.indexOf(v)<0)cands.push(v);}
170    add(uc);for(var pg=2;pg<=25;pg++)add(pg);
171    if(!cands.length)return;
172    var el0=L();if(!el0)return;var orig=el0.innerHTML;_busy=true;var i=0;
173    function go(){
174      if(i>=cands.length){_busy=false;var ll=L();if(ll)ll.innerHTML=orig;if(tgt(id))reveal(id);return;}
175      var cs=cands[i++];
176      try{window.CommentsPage(cs,news,location.href);}catch(e){_busy=false;var l2=L();if(l2)l2.innerHTML=orig;return;}
177      var w=0,iv=setInterval(function(){
178        w+=120;var e=tgt(id);
179        if(e){clearInterval(iv);_busy=false;reveal(id);return;}
180        if(w>=2400){clearInterval(iv);go();}
181      },120);
182    }
183    go();
184  }
185  function boot(){if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",function(){setTimeout(function(){seek(0);},300);});else setTimeout(function(){seek(0);},300);}
186  boot();
187  window.addEventListener("hashchange",function(){_busy=false;seek(0);});
188})();

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.