'use strict';dotclear.dbCommentsCount=(icon)=>{dotclear.jsonServicesGet('getCommentsCount',(data)=>{if(data.ret===dotclear.dbCommentsCount_Counter){return;}
const nbLabel=icon.querySelector('span.db-icon-title');if(nbLabel){nbLabel.textContent=data.ret;}
dotclear.dbCommentsCount_Counter=data.ret;});};dotclear.dbPostsCount=(icon)=>{dotclear.jsonServicesGet('getPostsCount',(data)=>{if(data.ret===dotclear.dbPostsCount_Counter){return;}
const nbLabel=icon.querySelector('span.db-icon-title');if(nbLabel){nbLabel.textContent=data.ret;}
dotclear.dbPostsCount_Counter=data.ret;});};dotclear.dbStoreUpdate=(store,icon)=>{dotclear.jsonServicesPost('checkStoreUpdate',(data)=>{if(!data.check){return;}
icon.setAttribute('href',`${icon.getAttribute('href')}#update`);for(const img of icon.querySelectorAll('img')){img.setAttribute('src',img.getAttribute('src').replaceAll(/([^/]+)(\..*)$/g,'$1-update$2'));}
const label=icon.querySelector('.db-icon-title');if(label){label.innerHTML=`${label.innerHTML}<br>${data.ret}`;}
dotclear.badge(icon.parentNode,{id:`mu-${store}`,value:data.nb,icon:true,type:'info',});},{store},);};dotclear.ready(()=>{const formQuickEntry=document.getElementById('quick-entry');if(formQuickEntry){Object.assign(dotclear,dotclear.getData('dotclear_quickentry'));function quickPost(status){if(typeof dotclear.ToolBar==='function'&&dotclear.contentTb.getMode()==='wysiwyg'){dotclear.contentTb.syncContents('iframe');}
formQuickEntry.querySelector('p.info')?.remove();formQuickEntry.querySelector('p.error')?.remove();dotclear.jsonServicesPost('quickPost',(data)=>{let msg=`<p class="info">${dotclear.msg.entry_created} - <a href="index.php?process=Post&id=${data.id}">${dotclear.msg.edit_entry}</a>`;if(data.status===dotclear.post_published){msg+=` - <a href="${data.url}">${dotclear.msg.view_entry}</a>`;}
msg+='</p>';formQuickEntry.append(dotclear.htmlToNode(msg));formQuickEntry.reset();document.getElementById('post_content').dispatchEvent(new Event('change',{bubbles:true}));if(typeof dotclear.ToolBar==='function'&&dotclear.contentTb.getMode()==='wysiwyg'){dotclear.contentTb.syncContents('textarea');}},{post_title:formQuickEntry.querySelector('#post_title').value,post_content:formQuickEntry.querySelector('#post_content').value,cat_id:formQuickEntry.querySelector('#cat_id').value,post_status:status,post_format:formQuickEntry.querySelector('#post_format').value,post_lang:formQuickEntry.querySelector('#post_lang').value,new_cat_title:formQuickEntry.querySelector('#new_cat_title').value,new_cat_parent:formQuickEntry.querySelector('#new_cat_parent').value,},(error)=>{formQuickEntry.append(dotclear.htmlToNode(`<p class="error"><strong>${dotclear.msg.error}</strong> ${error}<button class="close-notice">${dotclear.msg.close_notice}</button></p>`,),);},);}
if(typeof dotclear.ToolBar==='function'){dotclear.contentTb=new dotclear.ToolBar(formQuickEntry.querySelector('#post_content'));dotclear.contentTb.switchMode(formQuickEntry.querySelector('#post_format').value);}
formQuickEntry.querySelector('input[name=save]')?.addEventListener('click',(event)=>{quickPost(dotclear.post_pending);event.preventDefault();return false;});const savePublish=formQuickEntry.querySelector('input[name=save-publish]');if(savePublish){const btn=dotclear.htmlToNode(`<input type="submit" value="${savePublish.value}" name="save-and-publish">`);savePublish.remove();formQuickEntry.querySelector('input[name=save]').after(btn);btn.addEventListener('click',(event)=>{quickPost(dotclear.post_published);event.preventDefault();return false;});}
const title=document.querySelector('#quick h3');if(title){const siblings=title.parentNode.querySelectorAll(':not(h3)');dotclear.toggleWithLegend(title,siblings,{legend_click:true,user_pref:'dcx_quick_entry',});}}
dotclear.outgoingLinks('#doc-and-support a');dotclear.jsonServicesGet('checkCoreUpdate',(data)=>{if(data.check){document.querySelector('#content h2').after(dotclear.htmlToNode(data.ret));dotclear.outgoingLinks('#ajax-update a');}});const iconPlugins=document.querySelector('#dashboard-main #icons p #icon-process-plugins-fav');if(iconPlugins){dotclear.dbStoreUpdate('plugins',iconPlugins);}
const iconThemes=document.querySelector('#dashboard-main #icons p #icon-process-blog_theme-fav');if(iconThemes){dotclear.dbStoreUpdate('themes',iconThemes);}
dotclear.jsonServicesGet('checkNewsUpdate',(data)=>{if(!data.check){return;}
if(!document.getElementById('dashboard-boxes')){document.getElementById('dashboard-main').append(dotclear.htmlToNode('<div id="dashboard-boxes"></div>'));}
if(!document.querySelector('#dashboard-boxes div.db-items')){document.getElementById('dashboard-boxes').prepend(dotclear.htmlToNode('<div class="db-items"></div>'));}
document.querySelector('#dashboard-boxes div.db-items').prepend(dotclear.htmlToNode(data.ret));dotclear.outgoingLinks('#ajax-news a');});const iconComments=document.querySelector('#dashboard-main #icons p #icon-process-comments-fav');if(iconComments){dotclear.dbCommentsCount(iconComments);dotclear.dbCommentsCount_Timer=setInterval(dotclear.dbCommentsCount,60*1000,iconComments);}
const iconPosts=document.querySelector('#dashboard-main #icons p #icon-process-posts-fav');if(iconPosts){dotclear.dbPostsCount(iconPosts);dotclear.dbPostsCount_Timer=setInterval(dotclear.dbPostsCount,600*1000,iconPosts);}
if(dotclear.data.noDragDrop){return;}
Object.assign(dotclear,dotclear.getData('dotclear_dragndrop'));const set_positions=(sel,id)=>{const list=jQuery(sel).sortable('toArray').join();dotclear.jsonServicesPost('setDashboardPositions',()=>{},{id,list});};const init_positions=(sel,id)=>{jQuery(sel).sortable({cursor:'move',opacity:0.5,delay:200,distance:10,tolerance:'pointer',update(){set_positions(sel,id);},start(){document.getElementById(sel)?.classList.add('sortable-area');},stop(){document.getElementById(sel)?.classList.remove('sortable-area');},});};const reset_positions=(sel)=>{jQuery(sel).sortable('destroy');};const areas=[['#dashboard-main','main_order'],['#dashboard-boxes','boxes_order'],['#db-items','boxes_items_order'],['#db-contents','boxes_contents_order'],];const dragndrop=document.getElementById('dragndrop');const dragndropLabel=document.getElementById('dragndrop-label');dragndrop?.addEventListener('click',(event)=>{if(event.target.checked){for(const element of areas)init_positions(element[0],element[1]);dragndrop.setAttribute('title',dotclear.dragndrop_on);dragndropLabel.textContent=dotclear.dragndrop_on;return;}
for(const element of areas)reset_positions(element[0]);dragndrop.setAttribute('title',dotclear.dragndrop_off);dragndropLabel.textContent=dotclear.dragndrop_off;});});