Current File : /home/honehdyv/readbtooom.com/wp-content/plugins/autodescription/lib/js/c.min.js
'use strict';window.tsfC=function(){const a="undefined"!=typeof tsfCL10n&&tsfCL10n;let b=+(a.counterType||0);const c=()=>b,d={0:"tsf-counter-zero",1:"tsf-counter-one",2:"tsf-counter-two",3:"tsf-counter-three"},e=c=>{let e=c.e,f=tsf.decodeEntities(c.text),g=a.guidelines[c.field][c.type].chars,h=tsf.getStringLength(f),i="",j="";const k={bad:"tsf-count-bad",okay:"tsf-count-okay",good:"tsf-count-good",unknown:"tsf-count-unknown"};switch(h?h<g.lower?(i=k.bad,j=a.i18n.guidelines.short.farTooShort):h<g.goodLower?(i=k.okay,j=a.i18n.guidelines.short.tooShort):h>g.upper?(i=k.bad,j=a.i18n.guidelines.short.farTooLong):h>g.goodUpper?(i=k.okay,j=a.i18n.guidelines.short.tooLong):(i=k.good,j=a.i18n.guidelines.short.good):(i=k.unknown,j=a.i18n.guidelines.short.empty),b){case 3:j=`${h} &ndash; ${j}`;break;case 2:break;case 1:default:j=h;}e.innerHTML=j,e.classList.remove(...Object.values(k),...Object.values(d)),e.classList.add(i,d[b])},f=()=>{window.dispatchEvent(new CustomEvent("tsf-counter-updated"))},g=a=>{a&&++b,3<b&&(b=0),f()},h=()=>{g(!0);let a=".tsf-counter-wrap .tsf-ajax",c=0;tsf.resetAjaxLoader(a),tsf.setAjaxLoader(a),wp.ajax.post("tsf_update_counter",{nonce:tsf.l10n.nonces.edit_posts,val:b}).done(b=>{switch(b=tsf.convertJSONResponse(b),"success"===b.type&&(c=1),c){case 0:tsf.unsetAjaxLoader(a,!1);break;case 1:tsf.unsetAjaxLoader(a,!0);break;default:tsf.resetAjaxLoader(a);}}).fail(()=>{tsf.unsetAjaxLoader(a,!1)})},i=()=>document.querySelectorAll(".tsf-counter").forEach(a=>a.addEventListener("click",h)),j=()=>{i()};return Object.assign({load:()=>{document.body.addEventListener("tsf-onload",j)}},{updatePixelCounter:b=>{const c=b.e.parentElement;if(!c)return;const d=c.querySelector(".tsf-pixel-counter-bar"),e=c.querySelector(".tsf-pixel-counter-shadow");if(!d||!e)return;e.innerHTML=tsf.escapeString(tsf.decodeEntities(b.text));let f=e.offsetWidth,g="",h="",i="";const j=a.guidelines[b.field][b.type].pixels,k={bad:"tsf-pixel-counter-bad",okay:"tsf-pixel-counter-okay",good:"tsf-pixel-counter-good",unknown:"tsf-pixel-counter-unknown"};h=100*(f/j.goodUpper)+"%",f?f<j.lower?(g=k.bad,i=a.i18n.guidelines.long.farTooShort):f<j.goodLower?(g=k.okay,i=a.i18n.guidelines.long.tooShort):f>j.upper?(h=100*(j.upper/(f+2*(f-j.upper)/3))+"%",g=k.bad,i=a.i18n.guidelines.long.farTooLong):f>j.goodUpper?(g=k.okay,i=a.i18n.guidelines.long.tooLong,h="100%"):(g=k.good,i=a.i18n.guidelines.long.good):(g=k.unknown,h="100%",i=a.i18n.guidelines.long.empty);let l=a.i18n.pixelsUsed.replace(/%1\$d/g,f).replace(/%2\$d/g,j.goodUpper);l+=`<br>${i}`,d.classList.remove(...Object.values(k)),d.classList.add(g),d.querySelector(".tsf-pixel-counter-fluid").style.width=h,d.dataset.desc=l,d.setAttribute("aria-label",tsf.escapeString(l.replace(/(<([^>]+)?>?)/ig," "))),tsfTT.triggerUpdate(d)},updateCharacterCounter:e,triggerCounterUpdate:f,resetCounterListener:i,getCounterType:c},{counterClasses:d,l10n:a})}(),window.tsfC.load();