Compare commits
No commits in common. "39138ef88925a958619b0ea0135b1aae3a267495" and "e821501f6c6e688dffb227022199d51594f0f769" have entirely different histories.
39138ef889
...
e821501f6c
2 changed files with 12 additions and 31 deletions
32
script.js
32
script.js
|
@ -95,10 +95,8 @@ const fetchPosts = async function(serverUrl, hashtag) {
|
||||||
|
|
||||||
// updateTimesOnPage updates the time information displayed for each post
|
// updateTimesOnPage updates the time information displayed for each post
|
||||||
const updateTimesOnPage = function() {
|
const updateTimesOnPage = function() {
|
||||||
$('.card-text a.time').each(function() {
|
$('.card-text a').each(function() {
|
||||||
const timeValue = $(this).attr('data-time');
|
const date = new Date($(this).attr('data-time'));
|
||||||
if (timeValue === '') return;
|
|
||||||
const date = new Date(timeValue);
|
|
||||||
const newTimeAgo = timeAgo(secondsAgo(date));
|
const newTimeAgo = timeAgo(secondsAgo(date));
|
||||||
$(this).text(newTimeAgo);
|
$(this).text(newTimeAgo);
|
||||||
});
|
});
|
||||||
|
@ -120,7 +118,7 @@ const displayPost = function(post) {
|
||||||
${post.media_attachments[0] ? `<img src="${post.media_attachments[0].url}" class="card-img-top mb-2">` : ''}
|
${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>
|
<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>` : ''}
|
${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 class="time" 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 href="${post.url}" target="_blank" data-time="${post.created_at}">${timeAgo(secondsAgo(new Date(post.created_at)))}</a></small></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
@ -167,25 +165,16 @@ const updateCarousel = function(slides, posts) {
|
||||||
var newHTML = ` <!-- No Indicators -->`
|
var newHTML = ` <!-- No Indicators -->`
|
||||||
newHTML += `<!-- the slides -->
|
newHTML += `<!-- the slides -->
|
||||||
<div class="carousel-inner">
|
<div class="carousel-inner">
|
||||||
`;
|
`
|
||||||
|
|
||||||
let existingCards = [];
|
|
||||||
|
|
||||||
for( let i = 0; i < posts.length; i++ ) {
|
for( let i = 0; i < posts.length; i++ ) {
|
||||||
let post = posts[i];
|
let post = posts[i];
|
||||||
|
|
||||||
if (existingCards.includes(post.id) || (!includeReplies && post.in_reply_to_id !== null)) continue;
|
|
||||||
|
|
||||||
existingCards.push(post.id);
|
|
||||||
|
|
||||||
/*console.log( post.content )*/
|
/*console.log( post.content )*/
|
||||||
if ( i == 0 ) {
|
if ( i == 0 ) {
|
||||||
newHTML += `<div class="carousel-item active" data-interval="${duration}" data-pause="false">`;
|
newHTML += `<div class="carousel-item active" data-mdb-interval="${duration}" data-mdb-pause="false">`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newHTML += `<div class="carousel-item" data-interval="${duration}" data-pause="false">`;
|
newHTML += `<div class="carousel-item" data-mdb-interval="${duration}" data-mdb-pause="false">`;
|
||||||
}
|
}
|
||||||
const postContent = DOMPurify.sanitize(post.content);
|
|
||||||
newHTML += `
|
newHTML += `
|
||||||
<div class="card-big">
|
<div class="card-big">
|
||||||
<div class="d-flex align-items-center mb-4">
|
<div class="d-flex align-items-center mb-4">
|
||||||
|
@ -194,12 +183,12 @@ const updateCarousel = function(slides, posts) {
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="row align-items-center vertical-align-center">
|
<div class="row align-items-center vertical-align-center">
|
||||||
<div class="${post.media_attachments[0] ? `col-md-6` : `col-md-12`}"><div class="card-text" ${strip(postContent).length > 800 ? `style="font-size: 0.9em;"`: ``}>${postContent}</div></div>
|
${post.media_attachments[0] ? `<div class="col-md-6"><p class="card-text">${DOMPurify.sanitize(post.content)}</p></div>` : `<div class="col-md-12"><p class="card-text">${DOMPurify.sanitize(post.content)}</p></div>`}
|
||||||
${post.media_attachments[0] ? `<div class="col-md-6"><img src="${post.media_attachments[0].url}" class="card-img-bottom" align="center"> </div>` : ''}
|
${post.media_attachments[0] ? `<div class="col-md-6"><img src="${post.media_attachments[0].url}" class="card-img-bottom" align="center"> </div>` : ''}
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<p class="card-text text-right">
|
<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 class="text-muted"><a 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.favourites_count ? `, <b>${post.favourites_count}</b> mal favorisiert` : '' }
|
||||||
${post.replies_count ? `, <b>${post.replies_count}</b> mal kommentiert` : '' }
|
${post.replies_count ? `, <b>${post.replies_count}</b> mal kommentiert` : '' }
|
||||||
${post.reblogs_count ? `, <b>${post.reblogs_count}</b> mal geteilt` : '' }
|
${post.reblogs_count ? `, <b>${post.reblogs_count}</b> mal geteilt` : '' }
|
||||||
|
@ -229,11 +218,6 @@ const showCarousel = function() {
|
||||||
$('#myCarousel').carousel("cycle");
|
$('#myCarousel').carousel("cycle");
|
||||||
}
|
}
|
||||||
|
|
||||||
const strip = function(html) {
|
|
||||||
let doc = new DOMParser().parseFromString(html, 'text/html');
|
|
||||||
return doc.body.textContent || "";
|
|
||||||
}
|
|
||||||
|
|
||||||
const hideCarousel = function() {
|
const hideCarousel = function() {
|
||||||
// show popover
|
// show popover
|
||||||
document.getElementById('popover').style.opacity = '0';
|
document.getElementById('popover').style.opacity = '0';
|
||||||
|
|
11
styles.css
11
styles.css
|
@ -50,12 +50,6 @@
|
||||||
margin-bottom: 1px !important;
|
margin-bottom: 1px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.carousel .card-text {
|
|
||||||
font-size: 1.4em;
|
|
||||||
overflow: hidden;
|
|
||||||
max-height: 60vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
font-size: 0.9em; /* adjust this value to get the desired text size */
|
font-size: 0.9em; /* adjust this value to get the desired text size */
|
||||||
}
|
}
|
||||||
|
@ -192,6 +186,10 @@ body {
|
||||||
margin-bottom: 20px !important;
|
margin-bottom: 20px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.card-text ~ p {
|
||||||
|
font-size: 1.4em;
|
||||||
|
}
|
||||||
|
|
||||||
.card-img-bottom {
|
.card-img-bottom {
|
||||||
max-width: 600px;
|
max-width: 600px;
|
||||||
max-height: 500px;
|
max-height: 500px;
|
||||||
|
@ -203,7 +201,6 @@ body {
|
||||||
margin-top: 0px !important;
|
margin-top: 0px !important;
|
||||||
margin-bottom: 10px !important;
|
margin-bottom: 10px !important;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
float: right;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-muted {
|
.text-muted {
|
||||||
|
|
Loading…
Reference in a new issue