mirror of
https://gitlab.com/idotj/mastodon-embed-timeline.git
synced 2025-05-24 08:52:46 +00:00
Add reblog txt condition
This commit is contained in:
parent
93edb9847e
commit
238892360e
@ -34,7 +34,7 @@ let MastodonApi = function (params_) {
|
||||
this.mtIdContainer.addEventListener('click', function (event) {
|
||||
let urlToot = event.target.closest('.mt-toot').dataset.location;
|
||||
// Open Toot in new page avoiding any other natural link
|
||||
if(event.target.localName != 'a' && event.target.localName != 'span' && urlToot){
|
||||
if (event.target.localName != 'a' && event.target.localName != 'span' && urlToot) {
|
||||
window.open(urlToot, '_blank');
|
||||
}
|
||||
});
|
||||
@ -51,7 +51,7 @@ MastodonApi.prototype.getToots = function () {
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(jsonData => {
|
||||
// console.log('jsonData: ', jsonData);
|
||||
console.log('jsonData: ', jsonData);
|
||||
|
||||
// Clear the loading message
|
||||
this.mtBodyContainer.innerHTML = '';
|
||||
@ -66,7 +66,7 @@ MastodonApi.prototype.getToots = function () {
|
||||
|
||||
// Add target="_blank" to all hashtags
|
||||
let allHashtags = document.querySelectorAll("#mt-timeline .hashtag");
|
||||
for(let j=0; j<allHashtags.length; j++) {
|
||||
for (let j = 0; j < allHashtags.length; j++) {
|
||||
allHashtags[j].target = "_blank";
|
||||
allHashtags[j].rel = "tag noopener noreferrer";
|
||||
}
|
||||
@ -133,12 +133,17 @@ MastodonApi.prototype.getToots = function () {
|
||||
}
|
||||
|
||||
// Main content
|
||||
if(status_.spoiler_text != '') {
|
||||
if (status_.spoiler_text != '') {
|
||||
content =
|
||||
'<div class="toot-text">'
|
||||
+ status_.spoiler_text
|
||||
+ ' [Show more...]'
|
||||
+ '</div>';
|
||||
} else if (status_.reblog && status_.reblog.content != '') {
|
||||
content =
|
||||
'<div class="toot-text">'
|
||||
+ status_.reblog.content
|
||||
+ '</div>';
|
||||
} else {
|
||||
content =
|
||||
'<div class="toot-text">'
|
||||
@ -148,12 +153,12 @@ MastodonApi.prototype.getToots = function () {
|
||||
|
||||
// Media attachments
|
||||
let media = '';
|
||||
if (status_.media_attachments.length > 0 ) {
|
||||
if (status_.media_attachments.length > 0) {
|
||||
for (let picid in status_.media_attachments) {
|
||||
media = this.replaceMedias(status_.media_attachments[picid], status_.sensitive);
|
||||
}
|
||||
}
|
||||
if (status_.reblog && status_.reblog.media_attachments.length > 0 ) {
|
||||
if (status_.reblog && status_.reblog.media_attachments.length > 0) {
|
||||
for (let picid in status_.reblog.media_attachments) {
|
||||
media = this.replaceMedias(status_.reblog.media_attachments[picid], status_.sensitive);
|
||||
}
|
||||
@ -174,7 +179,7 @@ MastodonApi.prototype.getToots = function () {
|
||||
+ '<ul>'
|
||||
+ pollOption
|
||||
+ '</ul>'
|
||||
+'</div>';
|
||||
+ '</div>';
|
||||
}
|
||||
|
||||
// Date
|
||||
@ -232,7 +237,7 @@ function removeSpinner(element) {
|
||||
const spinnerCSS = 'loading-spinner';
|
||||
// Find closest parent container (1st, 2nd or 3rd level)
|
||||
let spinnerContainer = element.closest('.' + spinnerCSS);
|
||||
if(spinnerContainer){
|
||||
if (spinnerContainer) {
|
||||
spinnerContainer.classList.remove(spinnerCSS);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user