'use strict';dotclear.dbStoreUpdate=(store,url)=>{if(url.length){dotclear.jsonServicesPost('checkStoreUpdate',(data)=>{if(data.new){if(data.check){if(data.nb){const form=document.getElementById('force-checking');form?.replaceWith(dotclear.htmlToNode(`<p class="info"><a href="${url}" title="${data.ret}">${data.ret}</a></p>`),);}}else{const target=document.querySelector('#force-checking p');target?.prepend(dotclear.htmlToNode(`<span class="info">${data.ret}</span>`));}}},{store},);}};dotclear.ready(()=>{for(const theme of document.querySelectorAll('.module-sshot:not(.current-theme .module-sshot)')){const img=theme.querySelector('img');img?.addEventListener('click',(event)=>{const details=event.currentTarget.parentNode.parentNode.querySelector('details');details.open=details.open?null:'true';});}
const search=document.querySelector('.modules-search');if(search){const searchInput=search.querySelector(':scope input[name=m_search]');const searchSubmit=search.querySelector(':scope input[type=submit]');const condSubmit=()=>{if(searchInput.value.length<2){searchSubmit.classList.add('disabled');searchSubmit.setAttribute('disabled','true');}else{searchSubmit.classList.remove('disabled');searchSubmit.removeAttribute('disabled');}};condSubmit();searchInput?.addEventListener('keyup',()=>{condSubmit();});}
for(const helper of document.querySelectorAll('.checkboxes-helpers')){dotclear.checkboxesHelpers(helper);}
for(const action of document.querySelectorAll('.modules-form-actions')){const rxActionType=/^[^[]+/;const rxActionValue=/([^[]+)\]$/;const checkboxes=action.querySelectorAll(':scope input[type=checkbox]');for(const submit of action.querySelectorAll(':scope input[type=submit]')){submit?.addEventListener('click',(event)=>{const keyword=event.currentTarget?.name;if(!keyword){return true;}
const maction=keyword.match(rxActionType);const action=maction?maction[0]:'';const mvalues=keyword.match(rxActionValue);if(mvalues){const module=mvalues[1];if(action==='delete'){if(globalThis.confirm(dotclear.msg.confirm_delete_theme.replace('%s',module)))return true;event.preventDefault();return false;}}else{let checked=false;if(checkboxes.length>0){for(const checkbox of checkboxes){if(checkbox.checked){checked=true;break;}}
if(!checked){if(dotclear.debug){alert(dotclear.msg.no_selection);}
event.preventDefault();return false;}}
if(action==='delete'){if(globalThis.confirm(dotclear.msg.confirm_delete_themes))return true;event.preventDefault();return false;}}
return true;});}}
dotclear.dbStoreUpdate('themes',dotclear.getData('module_update_url'));});