THUẬT NGỮ

6,304 thuật ngữ

';} function prepareOpen(opts){var list=ITEMS.filter(function(x){return !currentMode||x.module===currentMode;});catsFor(list);stylesFor(list);filterKind=(opts.filter==='category'||opts.filter==='style')?opts.filter:'all';filterTabs.forEach(function(b){b.classList.toggle('is-active',b.getAttribute('data-dpm-extlib-filter')===filterKind);});cat.classList.toggle('is-hidden',filterKind!=='category');styleSel.classList.toggle('is-hidden',filterKind!=='style');preview.classList.remove('is-open');listView.style.display='block';render();} function refreshRemote(done){ if(!IS_RECEIVER){done();return;} grid.innerHTML='
Đang lấy mẫu mới nhất từ Kho mẫu nguồn…
'; var body=new URLSearchParams();body.set('action','dpm_template_library_remote_items');body.set('nonce',AJAX_NONCE); fetch(AJAX_URL,{method:'POST',credentials:'same-origin',headers:{'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'},body:body.toString()}) .then(function(r){return r.json();}).then(function(r){if(r&&r.success&&r.data&&Array.isArray(r.data.items)){ITEMS=r.data.items;if(window.DPMTemplateLibrary)window.DPMTemplateLibrary.items=ITEMS;}done();}) .catch(function(){done();}); } function open(mode,opts){opts=opts||{};currentMode=String(mode||'');saveBookmark();search.value='';cat.value='';styleSel.value='';root.classList.add('is-open');root.setAttribute('aria-hidden','false');refreshRemote(function(){prepareOpen(opts);});} document.getElementById('dpm-extlib-close').addEventListener('click',close);root.addEventListener('click',function(e){if(e.target===root)close();});document.getElementById('dpm-extlib-back').addEventListener('click',function(){preview.classList.remove('is-open');listView.style.display='block';currentItem=null;});search.addEventListener('input',render);cat.addEventListener('change',render);styleSel.addEventListener('change',render);filterTabs.forEach(function(b){b.addEventListener('click',function(){setFilterKind(this.getAttribute('data-dpm-extlib-filter'));});}); document.getElementById('dpm-extlib-use').addEventListener('click',function(){if(!currentItem)return;if(insertHtml(currentItem.html,false))close();else alert('Không tìm thấy vùng soạn thảo để chèn mẫu.');}); document.getElementById('dpm-extlib-replace').addEventListener('click',function(){if(!currentItem)return;if(!confirm('Thay toàn bộ nội dung đang soạn bằng tài liệu mẫu này?'))return;if(insertHtml(currentItem.html,true))close();else alert('Không tìm thấy vùng soạn thảo để thay nội dung.');}); try{ var pendingRaw=localStorage.getItem('dpm_template_pending_insert'); if(pendingRaw){ var pending=JSON.parse(pendingRaw); if(pending&&pending.html&&(!pending.time||Date.now()-pending.time<3600000)){ var pendingAttempts=0; var applyPending=function(){ pendingAttempts++; var replacePending=(pending.mode==='edit')||!!pending.replaceAll; if(insertHtml(pending.html,replacePending)){ try{localStorage.removeItem('dpm_template_pending_insert');}catch(e){} try{ var ed=activeEditor(); if(ed){ed.save();ed.fire('change');} }catch(e){} return; } if(pendingAttempts<30)setTimeout(applyPending,300); }; setTimeout(applyPending,250); } } }catch(e){} window.addEventListener('message',function(ev){ var d=ev&&ev.data?ev.data:null; if(!d||d.type!=='dpm-template-insert'||typeof d.html!=='string')return; if(TRUSTED_ORIGIN&&ev.origin!==TRUSTED_ORIGIN&&ev.origin!==window.location.origin)return; if(insertHtml(d.html,!!d.replaceAll)){ try{if(ev.source&&ev.source.postMessage)ev.source.postMessage({type:'dpm-template-inserted',id:d.id||''},'*');}catch(e){} } }); function openSite(){ saveBookmark(); try{window.open("https:\/\/ngoaingu.gioi.top\/?dpm_template_library=1",'dpm_template_library_site');} catch(e){location.href="https:\/\/ngoaingu.gioi.top\/?dpm_template_library=1";} } window.DPMTemplateLibrary={open:open,close:close,openSite:openSite,siteUrl:"https:\/\/ngoaingu.gioi.top\/?dpm_template_library=1",items:ITEMS,refresh:function(cb){refreshRemote(function(){if(typeof cb==='function')cb(ITEMS);});}}; })();