From a45904e637925a7f441ad22e0ed8db8255576f08 Mon Sep 17 00:00:00 2001 From: idotj Date: Sat, 21 Jan 2023 20:28:25 +0100 Subject: [PATCH] Change var number to string --- README.md | 4 ++-- src/mastodon-timeline.js | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 60fd62a..2e3da1f 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Here you have some parameters to customize your embed timeline: ``` // Maximum amount of toots to get from the user (default: 20) - toots_limit: 20 + toots_limit: '20' // Hide boosted toots (default: don't hide) hide_reblog: false @@ -65,7 +65,7 @@ Here you have some parameters to customize your embed timeline: hide_replies: false // Limit the text content to a maximum number of lines (default: unlimited) - text_max_lines: 0 + text_max_lines: '0' // Customize the text of the button linking to the user profile page (appears after the last toot) btn_see_more: 'See more posts at Mastodon' diff --git a/src/mastodon-timeline.js b/src/mastodon-timeline.js index 0a21855..4d0826c 100644 --- a/src/mastodon-timeline.js +++ b/src/mastodon-timeline.js @@ -8,12 +8,12 @@ document.addEventListener("DOMContentLoaded", () => { container_id: 'mt-timeline', container_body_id: 'mt-body', instance_uri: 'https://mastodon.online', - user_id: 180745, + user_id: '180745', profile_name: '@idotj', - toots_limit: 20, + toots_limit: '20', hide_reblog: false, hide_replies: false, - text_max_lines: 0, + text_max_lines: '0', btn_see_more: 'See more posts at Mastodon' }); }); @@ -24,10 +24,10 @@ let MastodonApi = function (params_) { this.INSTANCE_URI = params_.instance_uri; this.USER_ID = params_.user_id; this.PROFILE_NAME = params_.profile_name; - this.TOOTS_LIMIT = params_.toots_limit || 20; + this.TOOTS_LIMIT = params_.toots_limit || '20'; this.HIDE_REBLOG = typeof params_.hide_reblog !== 'undefined' ? params_.hide_reblog : false; this.HIDE_REPLIES = typeof params_.hide_replies !== 'undefined' ? params_.hide_replies : false; - this.TEXT_MAX_LINES = params_.text_max_lines || 0; + this.TEXT_MAX_LINES = params_.text_max_lines || '0'; this.BTN_SEE_MORE = params_.btn_see_more; // Target selectors @@ -51,10 +51,10 @@ let MastodonApi = function (params_) { spoilerText.classList.toggle('spoiler-text'); if (spoilerBtnText == 'Show more') { - event.target.textContent = 'Show less'; + spoilerBtnText = 'Show less'; event.target.setAttribute('aria-expanded', 'true'); } else { - event.target.textContent = 'Show more'; + spoilerBtnText = 'Show more'; event.target.setAttribute('aria-expanded', 'false'); } } @@ -161,7 +161,7 @@ MastodonApi.prototype.getToots = function () { // Main text let text_css = ''; - if (this.TEXT_MAX_LINES) { + if (this.TEXT_MAX_LINES !== '0') { text_css = 'truncate'; document.documentElement.style.setProperty('--text-max-lines', this.TEXT_MAX_LINES); }