for-pi2 #3
1 changed files with 6 additions and 4 deletions
10
script.js
10
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] ? `<img src="${post.media_attachments[0].url}" class="card-img-top mb-2">` : ''}
|
||||
<p class="card-text">${DOMPurify.sanitize(post.content)}</p>
|
||||
${post.spoiler_text ? `<p class="card-text text-muted spoiler">${DOMPurify.sanitize(post.spoiler_text)}</p>` : ''}
|
||||
<p class="card-text text-right"><small class="text-muted"><a href="${post.url}" target="_blank" data-time="${post.created_at}">${timeAgo(secondsAgo(new Date(post.created_at)))}</a></small></p>
|
||||
<p class="card-text text-right"><small class="text-muted"><a class="time" href="${post.url}" target="_blank" data-time="${post.created_at}">${timeAgo(secondsAgo(new Date(post.created_at)))}</a></small></p>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
@ -196,7 +198,7 @@ const updateCarousel = function(slides, posts) {
|
|||
</div>
|
||||
<hr>
|
||||
<p class="card-text text-right">
|
||||
<small class="text-muted"><a href="${post.url}" target="_blank" data-time="${post.created_at}">${timeAgo(secondsAgo(new Date(post.created_at)))}</a>
|
||||
<small class="text-muted"><a class="time" href="${post.url}" target="_blank" data-time="${post.created_at}">${timeAgo(secondsAgo(new Date(post.created_at)))}</a>
|
||||
${post.favourites_count ? `, <b>${post.favourites_count}</b> mal favorisiert` : '' }
|
||||
${post.replies_count ? `, <b>${post.replies_count}</b> mal kommentiert` : '' }
|
||||
${post.reblogs_count ? `, <b>${post.reblogs_count}</b> mal geteilt` : '' }
|
||||
|
|
Loading…
Reference in a new issue