<% let feeds = []; const db = require('quick.db'); if (db.get('feeds.three')) { const fd = db.get('feeds.three'); const fdata = { color: fd.color, description: fd.description, icon: fd.icon, published: fd.published, diff: fd.diff, feedNum: 3 } feeds.push(fdata); } if (db.get('feeds.two')) { const fd = db.get('feeds.two'); const fdata = { color: fd.color, description: fd.description, icon: fd.icon, published: fd.published, diff: fd.diff, feedNum: 2 } feeds.push(fdata); } if (db.get('feeds.one')) { const fd = db.get('feeds.one'); const fdata = { color: fd.color, description: fd.description, published: fd.published, icon: fd.icon, diff: fd.diff, feedNum: 1 } feeds.push(fdata); } feeds.forEach(feed => { var delta = Math.abs(Date.now() - feed.published) / 1000; // calculate (and subtract) whole days var days = Math.floor(delta / 86400); delta -= days * 86400; // calculate (and subtract) whole hours var hours = Math.floor(delta / 3600) % 24; delta -= hours * 3600; // calculate (and subtract) whole minutes var minutes = Math.floor(delta / 60) % 60; delta -= minutes * 60; // what's left is seconds var seconds = delta % 60; // in theory the modulus is not required let dateString = `loading`; //stupid variable names but yeah :sweat_smile: if (seconds < 2) secsingle = "second"; else secsingle = "seconds"; if (minutes < 2) minsingle = "minute"; else minsingle = "minutes"; if (hours < 2) hrsingle = "hour"; else hrsingle = "hours"; if (days < 2) daysingle = "day"; else daysingle = "days"; if (minutes < 1) dateString = `${Math.round(seconds)} ${secsingle} ago`; else if (hours < 1) dateString = `${minutes} ${minsingle} ago`; else if (days < 1) dateString = `${hours} ${hrsingle} ago`; else dateString = `${days} ${daysingle} ago`; let faString = "fas fa-"; if (feed.diff) faString = "fab fa-"; %>
<% }) if(!feeds[0]) { %>
There are no feeds.
<% } %>