Skip to content

Instantly share code, notes, and snippets.

@davecra
Created October 22, 2023 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davecra/cc2bba1a6e2963a6aad92ca2a45530c6 to your computer and use it in GitHub Desktop.
Save davecra/cc2bba1a6e2963a6aad92ca2a45530c6 to your computer and use it in GitHub Desktop.
settingsPage for Power-Up
/// <reference path="../../types/trello.d.js" />
import Common from "../common/common";
export default class SettingsPage {
constructor() { }
/**
* Renders the settings page
* @param {TrelloObject} t
*/
render = async (t) => {
/** @type {String} */
const html = /*html*/`
<p>You are on the setting page for ${Common.APPNAME}, ${Common.VERSION}</p>
<p>Set the label for your button:</p>
<input type="text" id="boardButtonTextInput" />
<button id="saveButton" disabled>Save</button>&nbsp;<button id="closeButton">Close</button>
`;
// If you look at the index.html you will see there is a single div with this ID
// this is how we DYNAMICALLY build a page in memory (above) and plop it in place
document.getElementById("content").innerHTML = html;
// now hook up things...
/** @type {HTMLButtonElement} */
const saveButton = document.getElementById("saveButton");
/** @type {HTMLInputElement} */
const input = document.getElementById("boardButtonTextInput");
input.value = await t.get("board", "private", "buttonName", "Hello World");
input.addEventListener("keypress", () => saveButton.disabled = false);
saveButton.addEventListener("click", () => {
t.set("board", "private", "buttonName", input.value);
saveButton.disabled = true;
});
document.getElementById("closeButton").addEventListener("click", () => {
t.closePopup();
});
t.sizeTo("#content");
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment