blowfish/public/js/page.min.0e49973b4ad0a382c7c6012d8bff8226316642daabc4f8a20477bd08674f3da6e2fa993bc20ad4f51e7c5bb68e6f913a207a7c4fe37ea0e7b806894afce0a64e.js

1 line
2.3 KiB
JavaScript
Raw Normal View History

2022-12-31 09:35:21 -06:00
var liked_page=!1,id,viewed,id_likes,liked;typeof auth!="undefined"&&(id=oid&&oid.replaceAll("/","-"),viewed=localStorage.getItem(id),viewed||auth.signInAnonymously().then(()=>{var e=db.collection("views").doc(id);localStorage.setItem(id,!0),e.get().then(e=>{e.exists?db.collection("views").doc(id).update({views:firebase.firestore.FieldValue.increment(1)}):db.collection("views").doc(id).set({views:1})}).catch(e=>{console.log("Error getting document:",e)})}).catch(e=>{var t=e.code,n=e.message;console.error(t,n)}),id_likes=oid_likes&&oid_likes.replaceAll("/","-"),liked=localStorage.getItem(id_likes),liked&&(liked_page=!0,document.querySelectorAll("span[id='likes_button_heart']")[0].style.display="",document.querySelectorAll("span[id='likes_button_emtpty_heart']")[0].style.display="none",document.querySelectorAll("span[id='likes_button_text']")[0].innerText=""));function like_article(e){auth.signInAnonymously().then(()=>{var t=db.collection("likes").doc(e);t.get().then(t=>{liked_page=!0,localStorage.setItem(e,!0),document.querySelectorAll("span[id='likes_button_heart']")[0].style.display="",document.querySelectorAll("span[id='likes_button_emtpty_heart']")[0].style.display="none",document.querySelectorAll("span[id='likes_button_text']")[0].innerText="",t.exists?db.collection("likes").doc(e).update({likes:firebase.firestore.FieldValue.increment(1)}):db.collection("likes").doc(e).set({likes:1})}).catch(e=>{console.log("Error getting document:",e)})}).catch(e=>{var t=e.code,n=e.message;console.error(t,n)})}function remove_like_article(e){auth.signInAnonymously().then(()=>{var t=db.collection("likes").doc(e);t.get().then(t=>{liked_page=!1,localStorage.removeItem(e),document.querySelectorAll("span[id='likes_button_heart']")[0].style.display="none",document.querySelectorAll("span[id='likes_button_emtpty_heart']")[0].style.display="",document.querySelectorAll("span[id='likes_button_text']")[0].innerText="\xa0Like",t.exists?db.collection("likes").doc(e).update({likes:firebase.firestore.FieldValue.increment(-1)}):db.collection("likes").doc(e).set({likes:0})}).catch(e=>{console.log("Error getting document:",e)})}).catch(e=>{var t=e.code,n=e.message;console.error(t,n)})}function process_article(){var e=oid_likes&&oid_likes.replaceAll("/","-");liked_page?remove_like_article(e):like_article(e)}