Compare commits

..

4 Commits

Author SHA1 Message Date
Nuno Coração
ea8344a4bc Merge pull request #1099 from nunocoracao/dev
🔖 v2.47.2 - small bug fix volume 2 - like button
2023-12-06 22:18:29 +00:00
Nuno Coração
80d2a65a0c small bug fix volume 2 - like button 2023-12-06 22:17:39 +00:00
Nuno Coração
ea8ad8ba7c Merge pull request #1098 from nunocoracao/dev
🔖 v2.47.1 - Small bug fix
2023-12-06 22:09:34 +00:00
Nuno Coração
d613121b76 small bug fix 2023-12-06 22:08:16 +00:00
4 changed files with 22 additions and 16 deletions

View File

@@ -33,9 +33,9 @@ if (typeof auth !== 'undefined') {
if (liked) {
liked_page = true
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 = ""
document.querySelectorAll("span[id='button_likes_heart']")[0].style.display = ""
document.querySelectorAll("span[id='button_likes_emtpty_heart']")[0].style.display = "none"
document.querySelectorAll("span[id='button_likes_text']")[0].innerText = ""
}
}
@@ -47,9 +47,9 @@ function like_article(id_likes) {
docRef.get().then((doc) => {
liked_page = true
localStorage.setItem(id_likes, true);
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 = ""
document.querySelectorAll("span[id='button_likes_heart']")[0].style.display = ""
document.querySelectorAll("span[id='button_likes_emtpty_heart']")[0].style.display = "none"
document.querySelectorAll("span[id='button_likes_text']")[0].innerText = ""
if (doc.exists) {
db.collection('likes').doc(id_likes).update({
likes: firebase.firestore.FieldValue.increment(1)
@@ -75,9 +75,9 @@ function remove_like_article(id_likes) {
docRef.get().then((doc) => {
liked_page = false
localStorage.removeItem(id_likes);
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"
document.querySelectorAll("span[id='button_likes_heart']")[0].style.display = "none"
document.querySelectorAll("span[id='button_likes_emtpty_heart']")[0].style.display = ""
document.querySelectorAll("span[id='button_likes_text']")[0].innerText = "\xa0Like"
if (doc.exists) {
db.collection('likes').doc(id_likes).update({
likes: firebase.firestore.FieldValue.increment(-1)

View File

@@ -8,6 +8,7 @@ if (typeof auth !== 'undefined') {
function toggleLoaders(node){
var classesString = node.className;
if(classesString == "") return
var classes = classesString.split(" ");
for(var i in classes){
node.classList.toggle(classes[i])
@@ -18,9 +19,11 @@ if (typeof auth !== 'undefined') {
viewsCollection.doc(id).onSnapshot(doc => {
var data = doc.data();
if (data) {
toggleLoaders(node)
node.innerText = numberWithCommas(data.views)
} else {
node.innerText = 0
}
toggleLoaders(node)
})
}
@@ -28,9 +31,12 @@ if (typeof auth !== 'undefined') {
likesCollection.doc(id).onSnapshot(doc => {
var data = doc.data();
if (data) {
toggleLoaders(node)
node.innerText = numberWithCommas(data.likes)
} else {
node.innerText = 0
}
toggleLoaders(node)
})
}

View File

@@ -1,10 +1,10 @@
<span>
<button id="likes_button"
<button id="button_likes"
class="rounded-md border border-primary-400 px-1 py-[1px] text-xs font-normal text-primary-700 dark:border-primary-600 dark:text-primary-400"
onclick="process_article()">
<span id="likes_button_heart" style="display:none" class="inline-block align-text-bottom">{{ partial "icon.html" "heart" }} </span>
<span id="likes_button_emtpty_heart" class="inline-block align-text-bottom">{{ partial "icon.html" "heart-empty" }}</span>
<span id="likes_button_text">&nbsp;Like</span>
<span id="button_likes_heart" style="display:none" class="inline-block align-text-bottom">{{ partial "icon.html" "heart" }} </span>
<span id="button_likes_emtpty_heart" class="inline-block align-text-bottom">{{ partial "icon.html" "heart-empty" }}</span>
<span id="button_likes_text">&nbsp;Like</span>
</button>
</span>
{{- /* Trim EOF */ -}}

View File

@@ -1,6 +1,6 @@
{
"name": "hugo-blowfish-theme",
"version": "2.47.0",
"version": "2.47.2",
"description": "Blowfish theme for Hugo",
"scripts": {
"fullinstall": "npm run preinstall && npm install && npm run postinstall",