diff --git a/assets/js/process.js b/assets/js/process.js index eb811015..8d9e87a6 100644 --- a/assets/js/process.js +++ b/assets/js/process.js @@ -7,22 +7,22 @@ if (typeof auth !== 'undefined') { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); } - var update_views = function (oid, id) { + var update_views = function (node, id) { viewsCollection.doc(id).onSnapshot(doc => { var data = doc.data(); if (data) { - var label = document.querySelectorAll("span[id='" + oid + "']")[0].innerText.split(' ')[1] - document.querySelectorAll("span[id='" + oid + "']")[0].innerText = numberWithCommas(data.views) + //var label = node.innerText.split(' ')[1] + node.innerText = numberWithCommas(data.views) } }) } - var update_likes = function (oid, id) { + var update_likes = function (node, id) { likesCollection.doc(id).onSnapshot(doc => { var data = doc.data(); if (data) { - var label = document.querySelectorAll("span[id='" + oid + "']")[0].innerText.split(' ')[1] - document.querySelectorAll("span[id='" + oid + "']")[0].innerText = numberWithCommas(data.likes) + //var label = node.innerText.split(' ')[1] + node.innerText = numberWithCommas(data.likes) } }) } @@ -33,20 +33,20 @@ if (typeof auth !== 'undefined') { var views_nodes = document.querySelectorAll("span[id^='views_']") for (var i in views_nodes) { - var oid = views_nodes[i].id - var id = oid ? oid.replaceAll("/", "-") : oid + var node = views_nodes[i] + var id = node.id ? node.id.replaceAll("/", "-") : node.id if (id) { - update_views(oid, id) + update_views(node, id) } } var likes_nodes = document.querySelectorAll("span[id^='likes_']") for (var i in likes_nodes) { - var oid = likes_nodes[i].id - var id = oid ? oid.replaceAll("/", "-") : oid + var node = likes_nodes[i] + var id = node.id ? node.id.replaceAll("/", "-") : node.id if (id) { - update_likes(oid, id) + update_likes(node, id) } } })