Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamouization committed Aug 9, 2022
2 parents 1477f8b + 1d8fb85 commit f5059aa
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions content_scripts/create_total_cards_button.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@
// Count number of cards.
const numberOfCards = document.querySelectorAll(".list-card").length;

// Create on/off button instance.
const buttonInstance = document.getElementById("button-total-cards-count");

// Create HTML for button.
const numberOfCardsButtonHTML = `<a id="button-total-cards-count" class="board-header-btn board-header-btn-invite ' +
'board-header-btn-without-icon" title="Invite to board"><span class="board-header-btn-text">' +
'Total cards: <b>' ${numberOfCards} '</b></span></a>`;

// Inner HTML of header buttons
let boardHeaderButtons = document.getElementsByClassName(
"board-header-btns mod-left"
)[1].innerHTML;

// Check if button already exists before creating it.
if (!buttonInstance) boardHeaderButtons += numberOfCardsButtonHTML;
})();
let buttonInstance = document.getElementById("button-total-cards-count");
if (buttonInstance === null) {
// Create HTML for button.
let numberOfCardsButtonHTML = '<a id="button-total-cards-count" class="board-header-btn board-header-btn-invite ' +
'board-header-btn-without-icon" title="Invite to board"><span class="board-header-btn-text">' +
'Total cards: <b>' + numberOfCards + '</b></span></a>'
// Add button to Trello board.
document.getElementsByClassName("board-header-btns mod-left")[1].innerHTML += numberOfCardsButtonHTML;
} else {
// Do nothing.
}
})();

0 comments on commit f5059aa

Please sign in to comment.