site_kpu/js/process.min.62060bb247f4de2b6dde45903668fefb68d792f365587605177b1227c0cf43588701edaca0cb40e2c8e2789bd5ce67c1d2a215b9fb258c3496a7cd25e7cb5fdf.js
2024-05-23 20:26:03 +00:00

1 line
1,003 B
JavaScript

if(typeof auth!="undefined"){var viewsCollection=db.collection("views"),update_views,update_likes,likesCollection=db.collection("likes");function numberWithCommas(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}function toggleLoaders(e){var t,s,n=e.className;if(n=="")return;t=n.split(" ");for(s in t)e.classList.toggle(t[s])}update_views=function(e,t){viewsCollection.doc(t).onSnapshot(t=>{var n=t.data();n?e.innerText=numberWithCommas(n.views):e.innerText=0,toggleLoaders(e)})},update_likes=function(e,t){likesCollection.doc(t).onSnapshot(t=>{var n=t.data();n?e.innerText=numberWithCommas(n.likes):e.innerText=0,toggleLoaders(e)})},auth.signInAnonymously().then(()=>{var e,t,n,s,o=document.querySelectorAll("span[id^='views_']");for(n in o)e=o[n],t=e.id?e.id.replaceAll("/","-"):e.id,t&&update_views(e,t);s=document.querySelectorAll("span[id^='likes_']");for(n in s)e=s[n],t=e.id?e.id.replaceAll("/","-"):e.id,t&&update_likes(e,t)}).catch(e=>{var t=e.code,n=e.message;console.error(t,n)})}