diff --git a/script.js b/script.js index b87dded..fa94ffb 100644 --- a/script.js +++ b/script.js @@ -95,8 +95,10 @@ const fetchPosts = async function(serverUrl, hashtag) { // updateTimesOnPage updates the time information displayed for each post const updateTimesOnPage = function() { - $('.card-text a').each(function() { - const date = new Date($(this).attr('data-time')); + $('.card-text a.time').each(function() { + const timeValue = $(this).attr('data-time'); + if (timeValue === '') return; + const date = new Date(timeValue); const newTimeAgo = timeAgo(secondsAgo(date)); $(this).text(newTimeAgo); }); @@ -118,7 +120,7 @@ const displayPost = function(post) { ${post.media_attachments[0] ? `` : ''}

${DOMPurify.sanitize(post.content)}

${post.spoiler_text ? `

${DOMPurify.sanitize(post.spoiler_text)}

` : ''} -

${timeAgo(secondsAgo(new Date(post.created_at)))}

+

${timeAgo(secondsAgo(new Date(post.created_at)))}

`; @@ -165,16 +167,25 @@ const updateCarousel = function(slides, posts) { var newHTML = ` ` newHTML += `