﻿(function (){
function qs(selector){
return document.querySelector(selector);
}
function getPdeBadgeCounts(){
if(window.PDE_BADGE&&window.PDE_BADGE.counts){
return window.PDE_BADGE.counts;
}
if(window.PDE_UNIFIED_HEADER&&window.PDE_UNIFIED_HEADER.badges){
return window.PDE_UNIFIED_HEADER.badges;
}
return null;
}
function getPdeBadgePrivateMessagesCount(){
var counts=getPdeBadgeCounts();
var count;
if(! counts||typeof counts.private_messages==='undefined'){
return null;
}
count=Number(counts.private_messages);
return Number.isNaN(count) ? null:count;
}
function getPdeBadgeGroupMessagesCount(){
var counts=getPdeBadgeCounts();
var count;
if(! counts||typeof counts.chat_groups==='undefined'){
return null;
}
count=Number(counts.chat_groups);
return Number.isNaN(count) ? null:count;
}
function mountAccount(){
var source=qs('#pde-header-score-source');
var target=qs('#pde-unified-header-account');
var account;
var guestHint;
if(! source||! target){
return;
}
account =
source.querySelector('.pde-member-menu') ||
source.querySelector('.score-box') ||
source.firstElementChild;
if(! account){
return;
}
guestHint=account.querySelector('.pde-member-menu__guest-hint');
if(guestHint){
guestHint.remove();
}
if(! target.contains(account) ){
target.innerHTML='';
target.appendChild(account);
}
source.hidden=true;
}
function mountSearch(){
var source=qs('#pde-header-search-source');
var target=qs('#pde-unified-search-panel');
var search;
if(! source||! target){
return;
}
search=source.querySelector('.pde-recherche');
if(! search){
return;
}
if(! target.contains(search) ){
target.innerHTML='';
target.appendChild(search);
}
source.hidden=true;
}
function focusSearchInput(root){
var input;
if(! root){
return;
}
input=root.querySelector('.pde-input');
if(! input){
return;
}
try {
input.focus({ preventScroll: true });
} catch(error){
input.focus();
}
if(typeof input.select==='function'){
input.select();
}
window.requestAnimationFrame(function (){
try {
input.focus({ preventScroll: true });
} catch(error){
input.focus();
}});
window.setTimeout(function (){
try {
input.focus({ preventScroll: true });
} catch(error){
input.focus();
}}, 180);
}
function bindSearchToggle(){
var root=qs('#pde-unified-header-search');
var button=qs('#pde-unified-search-toggle');
if(! root||! button||button.dataset.bound==='1'){
return;
}
button.dataset.bound='1';
button.addEventListener('click', function (){
var isOpen=root.classList.toggle('is-open');
button.setAttribute('aria-expanded', isOpen ? 'true':'false');
if(isOpen){
focusSearchInput(root);
}});
document.addEventListener('click', function(event){
if(! root.classList.contains('is-open')||root.contains(event.target) ){
return;
}
root.classList.remove('is-open');
button.setAttribute('aria-expanded', 'false');
});
}
function bindMenuToggle(){
var customButton=qs('#pde-unified-menu-toggle');
if(! customButton||customButton.dataset.bound==='1'){
return;
}
customButton.dataset.bound='1';
customButton.addEventListener('click', function (){
toggleCustomMenu();
});
}
function getMenuIconName(link){
var value=(
(link.textContent||'') +
' ' +
(link.getAttribute('href')||'') +
' ' +
(link.parentElement ? link.parentElement.className:'')
).toLowerCase();
var icons=[
[ /accueil|home/, 'home' ],
[ /actualit|blog|article|news/, 'news' ],
[ /ressource|document|outil|fichier/, 'folder' ],
[ /crpe|concours|formation/, 'graduation' ],
[ /lecture|livre|biblioth/, 'book' ],
[ /r.seau|social|facebook|instagram/, 'globe' ],
[ /mouvement|mutation|carte|poste/, 'pin' ],
[ /communaut|forum|membre/, 'users' ],
[ /agenda|calendrier|.v.nement/, 'calendar' ],
[ /annonce/, 'megaphone' ],
[ /boutique|shop|produit/, 'bag' ],
[ /humour|blague|sourire/, 'smile' ],
[ /contact|message|mail/, 'mail' ],
[ /compte|profil|connexion/, 'user' ],
[ /recherche/, 'search' ]
];
var match=icons.find(function(item){
return item[0].test(value);
});
return match ? match[1]:'arrow';
}
function getMenuIconMarkup(name){
var paths={
home: '<path d="M3 11.5 12 4l9 7.5"/><path d="M5.5 10.5V20h5v-6h3v6h5v-9.5"/>',
news: '<rect x="4" y="4" width="16" height="16" rx="2"/><path d="M8 8h3v4H8zM14 8h3M14 11h3M8 15h9M8 18h6"/>',
folder: '<path d="M3 7.5h7l2-2h9v14H3z"/><path d="M3 10h18"/>',
graduation: '<path d="m3 9 9-5 9 5-9 5z"/><path d="M7 12v4c2.8 2.3 7.2 2.3 10 0v-4M21 9v6"/>',
book: '<path d="M4 5.5c3.2-.8 5.8-.2 8 2v12c-2.2-2.2-4.8-2.8-8-2zM20 5.5c-3.2-.8-5.8-.2-8 2v12c2.2-2.2 4.8-2.8 8-2z"/><path d="M7 9h2M15 9h2"/>',
globe: '<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c3 3.2 3 14.8 0 18M12 3c-3 3.2-3 14.8 0 18"/>',
pin: '<path d="M12 21s7-6.2 7-12a7 7 0 0 0-14 0c0 5.8 7 12 7 12z"/><circle cx="12" cy="9" r="2.3"/>',
users: '<circle cx="9" cy="9" r="3"/><circle cx="17" cy="10" r="2.3"/><path d="M3 20v-2c0-3 2.7-5 6-5s6 2 6 5v2M15 15c3.4-.4 6 1.3 6 4v1"/>',
calendar: '<rect x="4" y="5" width="16" height="16" rx="2"/><path d="M8 3v4M16 3v4M4 10h16M8 14h.01M12 14h.01M16 14h.01M8 18h.01M12 18h.01"/>',
megaphone: '<path d="M4 13v-3l13-5v13zM17 8c2 1 2 6 0 7M7 14l1.5 6h3L10 13"/>',
bag: '<path d="M5 8h14l1 13H4z"/><path d="M9 9V6a3 3 0 0 1 6 0v3"/>',
smile: '<circle cx="12" cy="12" r="9"/><path d="M8.5 10h.01M15.5 10h.01M8 14c2.2 3 5.8 3 8 0"/>',
mail: '<rect x="3" y="5" width="18" height="14" rx="2"/><path d="m4 7 8 6 8-6"/>',
user: '<circle cx="12" cy="8" r="4"/><path d="M4 21c.5-5 3.2-7 8-7s7.5 2 8 7"/>',
search: '<circle cx="10.5" cy="10.5" r="6.5"/><path d="m16 16 5 5"/>',
arrow: '<path d="M5 12h14M14 7l5 5-5 5"/>'
};
return '<span class="pde-menu-icon pde-menu-icon--' + name + '" aria-hidden="true"><svg viewBox="0 0 24 24">' + paths[name] + '</svg></span>';
}
function decorateMenuPanel(menu){
var topItems=Array.prototype.filter.call(menu.children, function(child){
return child.tagName==='LI';
});
topItems.forEach(function(item){
var link=item.querySelector(':scope > a');
var subMenu=item.querySelector(':scope > .sub-menu');
item.querySelectorAll(':scope > .cm-submenu-toggle').forEach(function(toggle){
toggle.remove();
});
if(subMenu&&link){
item.classList.add('pde-menu-section');
link.classList.add('pde-menu-section__title');
link.removeAttribute('href');
link.setAttribute('role', 'heading');
link.setAttribute('aria-level', '2');
subMenu.querySelectorAll('a').forEach(function(childLink){
if(! childLink.querySelector('.pde-menu-icon') ){
childLink.insertAdjacentHTML('afterbegin', getMenuIconMarkup(getMenuIconName(childLink) ));
}});
}else if(link){
item.classList.add('pde-menu-standalone');
link.insertAdjacentHTML('afterbegin', getMenuIconMarkup(getMenuIconName(link) ));
}});
}
function buildMenuPanel(){
var source =
qs('#cm-mobile-menu') ||
qs('.cm-mobile-nav-container .cm-mobile-menu') ||
qs('#cm-primary-nav > ul') ||
qs('.cm-primary-nav > ul');
var target=qs('#pde-unified-menu-nav');
var clone;
if(! source||! target||target.children.length){
return;
}
clone=source.cloneNode(true);
clone.removeAttribute('id');
clone.classList.remove('cm-mobile-menu--open');
clone.classList.add('pde-unified-menu-list');
decorateMenuPanel(clone);
target.appendChild(clone);
}
function fitMenuPanelToViewport(){
var nav=qs('#pde-unified-menu-nav');
var menu=nav ? nav.querySelector('.pde-unified-menu-list'):null;
var styles;
var availableHeight;
var menuHeight;
var scale;
if(! nav||! menu||window.innerWidth > 782){
if(nav){
nav.style.removeProperty('--pde-menu-scale');
}
return;
}
nav.style.setProperty('--pde-menu-scale', '1');
styles=window.getComputedStyle(nav);
availableHeight =
nav.clientHeight -
parseFloat(styles.paddingTop||0) -
parseFloat(styles.paddingBottom||0);
menuHeight=menu.scrollHeight;
scale=menuHeight > availableHeight ? availableHeight / menuHeight:1;
nav.style.setProperty('--pde-menu-scale', Math.max(0.1, Math.min(1, scale) ).toFixed(4) );
}
function mountBarsIntoPage(){
var page=qs('#page');
var topBar=qs('#pde-unified-header-bar');
var logoBar=qs('#pde-unified-logo-bar');
if(! page||! topBar||! logoBar){
return;
}
if(topBar.parentNode!==page){
page.insertBefore(topBar, page.firstChild);
}
if(logoBar.parentNode!==page){
page.insertBefore(logoBar, topBar.nextSibling);
}}
function syncMobileHeaderBarWidth(){
var topBar=qs('#pde-unified-header-bar');
var logoBar=qs('#pde-unified-logo-bar');
var rect;
if(! topBar||! logoBar){
return;
}
if(! window.matchMedia||! window.matchMedia('(max-width: 782px)').matches){
topBar.style.removeProperty('left');
topBar.style.removeProperty('width');
topBar.style.removeProperty('max-width');
topBar.style.removeProperty('transform');
return;
}
rect=logoBar.getBoundingClientRect();
topBar.style.left=Math.round(rect.left) + 'px';
topBar.style.width=Math.round(rect.width) + 'px';
topBar.style.maxWidth=Math.round(rect.width) + 'px';
topBar.style.transform='none';
}
function tightenCommunityChatLayout(){
var body=document.body;
var page=qs('#page');
var topBar=qs('#pde-unified-header-bar');
var logoBar=qs('#pde-unified-logo-bar');
var frames;
function collapseNode(node){
if(! node||! node.style){
return;
}
node.style.marginTop='0';
node.style.marginBottom='0';
node.style.paddingTop='0';
node.style.paddingBottom='0';
node.style.borderTopWidth='0';
node.style.borderBottomWidth='0';
if('P'===node.tagName){
node.style.display='block';
}}
function normalizeFrameDocument(frame){
var doc;
var html;
var innerBody;
var topbar;
var content;
try {
doc=frame.contentDocument||(frame.contentWindow ? frame.contentWindow.document:null);
} catch(error){
doc=null;
}
if(! doc){
return;
}
html=doc.documentElement;
innerBody=doc.body;
topbar=doc.querySelector('.topbar');
content=doc.querySelector('#content');
if(html){
html.style.margin='0';
html.style.padding='0';
}
if(innerBody){
innerBody.style.margin='0';
innerBody.style.padding='0';
}
if(topbar){
topbar.style.marginTop='0';
}
if(content){
content.style.marginTop='0';
}}
if(! body||! body.classList.contains('pde-community-page') ){
return;
}
frames=document.querySelectorAll('iframe[src*="/ressources/communaute/app.php"], iframe[src*="ressources/communaute/app.php"]');
frames.forEach(function(frame){
var node=frame;
var availableHeight =
window.innerHeight -
(topBar ? topBar.offsetHeight:0) -
(logoBar ? logoBar.offsetHeight:0);
frame.style.display='block';
frame.style.width='100%';
frame.style.margin='0';
frame.style.border='0';
frame.style.verticalAlign='top';
if(availableHeight > 320){
frame.style.height=availableHeight + 'px';
}
while(node&&node!==page){
collapseNode(node);
node=node.parentElement;
}
if(! frame.dataset.pdeChatLayoutBound){
frame.addEventListener('load', function (){
tightenCommunityChatLayout();
normalizeFrameDocument(frame);
});
frame.dataset.pdeChatLayoutBound='1';
}
normalizeFrameDocument(frame);
});
}
function tightenRdvEmbedLayout(){
var frames=document.querySelectorAll('iframe[src*="/ressources/rdv"], iframe[src*="ressources/rdv"]'
);
function collapseNode(node){
if(! node||! node.style){
return;
}
node.style.marginTop='0';
node.style.marginBottom='0';
node.style.paddingTop='0';
node.style.paddingBottom='0';
node.style.borderTopWidth='0';
node.style.borderBottomWidth='0';
node.style.minHeight='0';
node.style.height='auto';
node.style.background='#fff';
if('P'===node.tagName){
node.style.display='block';
}}
function resizeFrame(frame, height){
var nextHeight=Number(height);
if(! nextHeight||Number.isNaN(nextHeight) ){
return;
}
frame.style.height=Math.max(nextHeight, 120) + 'px';
}
function normalizeFrameDocument(frame){
var doc;
var html;
var innerBody;
var wrapper;
var panel;
try {
doc=frame.contentDocument||(frame.contentWindow ? frame.contentWindow.document:null);
} catch(error){
doc=null;
}
if(! doc){
return;
}
html=doc.documentElement;
innerBody=doc.body;
wrapper=doc.querySelector('.wrapper');
panel=doc.querySelector('.panel');
if(html){
html.style.margin='0';
html.style.padding='0';
html.style.background='#fff';
}
if(innerBody){
innerBody.style.margin='0';
innerBody.style.padding='0';
innerBody.style.background='#fff';
}
if(wrapper){
wrapper.style.margin='0 auto';
wrapper.style.background='#fff';
}
if(panel){
panel.style.margin='0';
panel.style.background='#fff';
}
resizeFrame(
frame,
Math.max(innerBody ? innerBody.scrollHeight:0,
innerBody ? innerBody.offsetHeight:0,
html ? html.scrollHeight:0,
html ? html.offsetHeight:0
)
);
}
frames.forEach(function(frame){
var node=frame;
frame.style.display='block';
frame.style.width='100%';
frame.style.margin='0';
frame.style.border='0';
frame.style.verticalAlign='top';
while(node){
collapseNode(node);
if(node.id==='page' ||
node.classList.contains('entry-content') ||
node.classList.contains('cm-entry-content') ||
node.classList.contains('wp-block-group')
){
break;
}
node=node.parentElement;
}
if(! frame.dataset.pdeRdvLayoutBound){
frame.addEventListener('load', function (){
normalizeFrameDocument(frame);
});
frame.dataset.pdeRdvLayoutBound='1';
}
normalizeFrameDocument(frame);
});
}
function bindRdvEmbedMessages(){
if(window.pdeRdvEmbedMessagesBound){
return;
}
window.pdeRdvEmbedMessagesBound=true;
window.addEventListener('message', function(event){
var data=event&&event.data ? event.data:null;
if(! data||typeof data!=='object'){
return;
}
if(data.type==='pde-rdv-parent-refresh'&&typeof data.url==='string'){
window.location.replace(data.url);
return;
}
if(data.type!=='pde-rdv-height'){
return;
}
document
.querySelectorAll('iframe[src*="/ressources/rdv"], iframe[src*="ressources/rdv"]')
.forEach(function(frame){
if(frame.contentWindow!==event.source){
return;
}
frame.style.height=Math.max(Number(data.height)||0, 120) + 'px';
});
});
}
function normalizePrivateMessagesLabel(){
var counts=getPdeBadgeCounts();
if(! counts){
return;
}
syncPrivateMessagesBadge(Number(counts.private_messages)||0);
syncForumBadge(Number(counts.forum)||0);
}
function getCountLabel(count, singular, plural){
var total=typeof count==='number'&&! Number.isNaN(count) ? count:0;
var countText =
total > 0
? '<span class="pde-member-panel__count-badge is-active">' + total + '</span>'
: '<span class="pde-member-panel__count-badge">' + total + '</span>';
return countText + ' ' +(total===1 ? singular:plural);
}
function syncPrivateMessagesBadge(unreadCount){
var link=qs('[data-pde-account-action="private-messages"]');
var count=typeof unreadCount==='number' ? unreadCount:0;
var label=link ? link.children[1]:null;
var legacyBadge=qs('.pde-unified-header-bar__account .pde-unified-header-bar__badge');
if(legacyBadge){
legacyBadge.remove();
}
if(! link||! label){
return;
}
label.innerHTML=getCountLabel(count, 'message privé', 'messages privés');
}
function syncForumBadge(unreadCount){
var link=qs('[data-pde-account-action="forum"]');
var label=link ? link.children[1]:null;
var count=typeof unreadCount==='number' ? unreadCount:0;
if(label){
label.innerHTML=getCountLabel(count, 'sujet du forum non lu', 'sujets du forum non lus');
}}
function syncPrivateMessagesState(){
var centralizedPrivateCount=getPdeBadgePrivateMessagesCount();
if(centralizedPrivateCount!==null){
syncPrivateMessagesBadge(centralizedPrivateCount);
syncForumBadge(Number(getPdeBadgeCounts().forum)||0);
return Promise.resolve(centralizedPrivateCount);
}
return window
.fetch('/wp-json/pde/v1/badges', {
credentials: 'same-origin',
headers: { Accept: 'application/json' }})
.then(function(response){
if(! response.ok){
throw new Error('pde-badge unavailable');
}
return response.json();
})
.then(function(payload){
var counts=payload&&payload.counts ? payload.counts:null;
var count=counts&&typeof counts.private_messages!=='undefined' ? Number(counts.private_messages):null;
var forumCount=counts&&typeof counts.forum!=='undefined' ? Number(counts.forum):0;
if(count===null||Number.isNaN(count) ){
throw new Error('pde-badge private count missing');
}
window.PDE_BADGE=payload;
syncPrivateMessagesBadge(count);
syncForumBadge(forumCount);
})
.catch(function (){
});
}
function forceCommunityChatTab(){
var params=new URLSearchParams(window.location.search);
var forcedTab=params.get('chat_tab')||params.get('tab');
if(! forcedTab){
return;
}
document
.querySelectorAll('iframe[src*="/ressources/communaute/app.php"], iframe[src*="ressources/communaute/app.php"]')
.forEach(function(frame){
var src=frame.getAttribute('src');
var url;
if(! src){
return;
}
try {
url=new URL(src, window.location.origin);
url.searchParams.set('tab', forcedTab);
url.searchParams.set('embed', '1');
url.hash=forcedTab;
if(src!==url.toString()){
frame.setAttribute('src', url.toString());
}
frame.addEventListener('load',
function (){
try {
frame.contentWindow.postMessage({ type: 'pde-chat-open-tab', tab: forcedTab },
window.location.origin
);
} catch(error){
}},
{ once: true }
);
} catch(error){
}});
}
function setMenuState(open){
var customButton=qs('#pde-unified-menu-toggle');
var panel=qs('#pde-unified-menu-panel');
var backdrop=qs('#pde-unified-menu-backdrop');
if(! customButton||! panel||! backdrop){
return;
}
customButton.setAttribute('aria-expanded', open ? 'true':'false');
panel.hidden = ! open;
backdrop.hidden = ! open;
panel.setAttribute('aria-hidden', open ? 'false':'true');
panel.classList.toggle('is-open', open);
backdrop.classList.toggle('is-open', open);
if(open){
window.requestAnimationFrame(fitMenuPanelToViewport);
}}
function toggleCustomMenu(){
var panel=qs('#pde-unified-menu-panel');
if(! panel){
return;
}
buildMenuPanel();
setMenuState(! panel.classList.contains('is-open') );
}
function bindMenuDismiss(){
var backdrop=qs('#pde-unified-menu-backdrop');
var panel=qs('#pde-unified-menu-panel');
var closeButton=qs('#pde-unified-menu-close');
var startX=0;
var startY=0;
var deltaX=0;
var tracking=false;
if(! backdrop||! panel||backdrop.dataset.bound==='1'){
return;
}
backdrop.dataset.bound='1';
backdrop.addEventListener('click', function (){
setMenuState(false);
});
if(closeButton){
closeButton.addEventListener('click', function (){
setMenuState(false);
});
}
panel.addEventListener('click', function(event){
if(event.target.closest('a') ){
setMenuState(false);
}});
document.addEventListener('keydown', function(event){
if('Escape'===event.key){
setMenuState(false);
}});
panel.addEventListener('touchstart',
function(event){
if(! panel.classList.contains('is-open')||! event.touches.length){
return;
}
startX=event.touches[0].clientX;
startY=event.touches[0].clientY;
deltaX=0;
tracking=true;
panel.classList.add('is-dragging');
},
{ passive: true }
);
panel.addEventListener('touchmove',
function(event){
var currentX;
var currentY;
var translate;
if(! tracking||! event.touches.length){
return;
}
currentX=event.touches[0].clientX;
currentY=event.touches[0].clientY;
if(Math.abs(currentY - startY) > 32){
tracking=false;
panel.classList.remove('is-dragging');
panel.style.removeProperty('--pde-panel-swipe-offset');
return;
}
deltaX=currentX - startX;
if(deltaX < 0){
translate=Math.max(deltaX, -260);
panel.style.setProperty('--pde-panel-swipe-offset', translate + 'px');
}},
{ passive: true }
);
panel.addEventListener('touchend',
function (){
if(! tracking){
panel.classList.remove('is-dragging');
panel.style.removeProperty('--pde-panel-swipe-offset');
return;
}
tracking=false;
panel.classList.remove('is-dragging');
if(deltaX <=-110){
setMenuState(false);
}
panel.style.removeProperty('--pde-panel-swipe-offset');
},
{ passive: true }
);
}
function init(){
forceCommunityChatTab();
mountBarsIntoPage();
syncMobileHeaderBarWidth();
tightenCommunityChatLayout();
tightenRdvEmbedLayout();
bindRdvEmbedMessages();
mountSearch();
mountAccount();
buildMenuPanel();
normalizePrivateMessagesLabel();
syncPrivateMessagesState();
bindSearchToggle();
bindMenuToggle();
bindMenuDismiss();
setMenuState(false);
}
if(document.readyState==='loading'){
document.addEventListener('DOMContentLoaded', init);
}else{
init();
}
window.addEventListener('load', init);
window.addEventListener('resize', syncMobileHeaderBarWidth);
window.addEventListener('orientationchange', syncMobileHeaderBarWidth);
window.addEventListener('resize', fitMenuPanelToViewport);
window.addEventListener('orientationchange', fitMenuPanelToViewport);
window.addEventListener('resize', tightenCommunityChatLayout);
window.addEventListener('resize', tightenRdvEmbedLayout);
window.addEventListener('focus', syncPrivateMessagesState);
document.addEventListener('visibilitychange', function (){
if(document.visibilityState==='visible'){
syncPrivateMessagesState();
}});
}());
(function (){
function initCommentsUi(){
var commentsRoot=document.getElementById('comments');
if(!commentsRoot){
return;
}
var title=commentsRoot.querySelector('.comments-title');
if(title){
title.textContent='Commentaires';
}
commentsRoot.querySelectorAll('li.comment article.comment').forEach(function (comment){
if(comment.dataset.pdeCommentsReady==='1'){
return;
}
var content=comment.querySelector('.comment-content');
var meta=comment.querySelector('.comment-metadata');
if(!content||!meta){
return;
}
meta.querySelectorAll('a.comment-permalink, .comment-permalink').forEach(function (element){
element.remove();
});
meta.childNodes.forEach(function (node){
if(node.nodeType===3){
node.nodeValue=node.nodeValue.replace(/^[\sâ€¢|:-]+|[\sâ€¢|:-]+$/g, '');
}});
var footer=document.createElement('div');
footer.className='comment-footer';
footer.appendChild(meta);
comment.appendChild(footer);
comment.dataset.pdeCommentsReady='1';
});
commentsRoot.querySelectorAll('li.comment.bypostauthor .comment-author .fn span').forEach(function (badge){
var text=(badge.textContent||'').replace(/\s+/g, ' ').trim().toLowerCase();
if(/^auteur de l[â€™']article$/i.test(text)){
badge.remove();
}});
}
if(document.readyState==='loading'){
document.addEventListener('DOMContentLoaded', initCommentsUi);
}else{
initCommentsUi();
}})();