diff --git a/script.js b/script.js
index fa94ffb..af3bfbc 100644
--- a/script.js
+++ b/script.js
@@ -104,6 +104,14 @@ const updateTimesOnPage = function() {
});
};
+// replace certain emojies in some text with images
+const replaceEmojies = (text, emojis) => {
+ emojis.forEach(emoji => {
+ text = text.replaceAll(`:${emoji.shortcode}:`, ``);
+ });
+ return text;
+};
+
// displayPost creates and displays a post
const displayPost = function(post) {
if (existingPosts.includes(post.id) || (!includeReplies && post.in_reply_to_id !== null)) return 0;
@@ -115,10 +123,10 @@ const displayPost = function(post) {
-
${DOMPurify.sanitize(post.account.display_name)} @${DOMPurify.sanitize(post.account.acct)}
+
${replaceEmojies(DOMPurify.sanitize(post.account.display_name), post.account.emojis)} @${DOMPurify.sanitize(post.account.acct)}
${post.media_attachments[0] ? `
` : ''}
-
${DOMPurify.sanitize(post.content)}
+
${replaceEmojies(DOMPurify.sanitize(post.content), post.emojis)}
${post.spoiler_text ? `
${DOMPurify.sanitize(post.spoiler_text)}
` : ''}
${timeAgo(secondsAgo(new Date(post.created_at)))}
@@ -185,16 +193,16 @@ const updateCarousel = function(slides, posts) {
else {
newHTML += ``;
}
- const postContent = DOMPurify.sanitize(post.content);
+ const postContent = replaceEmojies(DOMPurify.sanitize(post.content), post.emojis);
newHTML += `
-
${DOMPurify.sanitize(post.account.display_name)} @${DOMPurify.sanitize(post.account.acct)}
+
${replaceEmojies(DOMPurify.sanitize(post.account.display_name), post.account.emojis)} @${DOMPurify.sanitize(post.account.acct)}
-
800 ? `style="font-size: 0.9em;"`: ``}>${postContent}
+
700 ? `style="font-size: ${strip(postContent).length > 1000 ? `0.5`:`0.9`}em;"`: ``}>${postContent}
${post.media_attachments[0] ? `
` : ''}
@@ -210,7 +218,7 @@ const updateCarousel = function(slides, posts) {
newHTML += '
';
}
for( let i = 0; i < extraCards.length; i++ ) {
- newHTML += `
+ newHTML += `
${extraCards[i]}
@@ -341,9 +349,7 @@ $(document).ready(async function() {
const newPosts = await Promise.all(hashtagsArray.map(hashtag => fetchPosts(serverUrl, hashtag)));
let updated = updateWall(newPosts.flat());
if ( updated > 0 ) {
- hideCarousel()
updateCarousel(slides, newPosts.flat());
- setTimeout(async function() { showCarousel(); }, duration)
}
}, refresh);
} else {
diff --git a/styles.css b/styles.css
index 3291ebf..34f152b 100644
--- a/styles.css
+++ b/styles.css
@@ -51,9 +51,9 @@
}
.carousel .card-text {
- font-size: 1.4em;
+ font-size: 1.6em;
overflow: hidden;
- max-height: 60vh;
+ max-height: 50vh;
}
.card {
@@ -208,7 +208,7 @@ body {
.text-muted {
color:#6c757d !important;
- font-size: 1.2em;
+ font-size: 1em;
text-align: right;
}
@@ -223,4 +223,8 @@ body {
.footer a {
color: rgba(255, 255, 255, 0.8) !important;
+}
+
+.emoji {
+ height: 1em;
}
\ No newline at end of file