Skip to content

Instantly share code, notes, and snippets.

View davecra's full-sized avatar
💭
Coding for arrays

David E. Craig davecra

💭
Coding for arrays
View GitHub Profile
@davecra
davecra / package.json
Created October 22, 2023 20:03
Package.json for Power-Up
{
"name": "trello-hello-world",
"appName": "Hello World",
"version": "1.0",
"description": "A Power-Up to say hello.",
"scripts": {
"start": "webpack-dev-server --mode development",
"build": "node webpack --mode production"
},
"dependencies": {
@davecra
davecra / settingsPage.js
Created October 22, 2023 20:01
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} */
@davecra
davecra / details.js
Created October 22, 2023 20:00
Details.js for Power-Up
/* global TrelloPowerUp */
/// <reference path="../types/trello.d.js" />
import SettingsPage from "./pages/settingsPage";
/** @type {TrelloPowerUp} */
const tpu = window.TrelloPowerUp;
/** @type {TrelloObject} Trello iframe object */
const t = tpu.iframe();
t.render(() => {
/** @type { "settings" } */
const page = t.arg("page");
@davecra
davecra / client.js
Created October 22, 2023 19:58
Client.js for Power-Up
/* global TrelloPowerUp */
/// <reference path="../types/trello.d.js" />
import Common from './common/common';
/** @type {TrelloPowerUp} */
const tpu = window.TrelloPowerUp;
tpu.initialize({
'board-buttons': async (t) => await getBoardButton(t),
});
/**
* Returns the board button
@davecra
davecra / common.js
Created October 22, 2023 19:57
Common.js for Power-Up
const PACKAGE = require('../../package.json');
/**
* CommonFunctions to be shared across all the project
*/
export default class Common {
/** @type {String} */
static APPNAME = PACKAGE.appName;
/** @type {String} */
static VERSION = PACKAGE.version;
/** @type {String} */
@davecra
davecra / index.html
Created October 22, 2023 19:55
index.html for Trello Power-Up
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta http-equiv="Cache-control" content="no-cache"/>
<meta http-equiv="pragma" content="no-cache"/>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<!-- if you want Trello sizeTo to work correctly, you need to keep this -->
<link crossorigin="anonymous" rel="stylesheet" href="https://p.trellocdn.com/power-up.min.css">
<title>Power-Up</title>
@davecra
davecra / commands.js
Created September 13, 2023 13:33
JSRuntime to get it working
/**
* Checks to see if we are running in Windows Outlook
* @returns {Boolean}
*/
function isPC() {
try {
if (Office.context.platform === Office.PlatformType.PC || Office.context.platform === null) {
return true;
} else {
return false;
@davecra
davecra / onready.js
Created September 13, 2023 13:30
Office OnReady in JSRuntime
/**
* Ensures the Office.js library is loaded.
*/
Office.onReady((info) => {
/**
* Maps the event handler name specified in the manifest's LaunchEvent element to its JavaScript counterpart.
* This ensures support in Outlook on Windows.
*/
if (Office.context.platform === Office.PlatformType.PC || Office.context.platform == null) {
Office.actions.associate("onMessageSendHandler", onMessageSendHandler);
@davecra
davecra / sanitizeString.js
Created September 8, 2023 03:16
HTML Sanitizer
/**
* Sanitizes the string for possible malicious values
* @param {String} string
* @returns {String}
*/
static sanitizeString = (string) => {
try {
string = string.replace(/(javascript:|onerror)/gi, "");
string = string.replace(/undefined/gi, "");
string = string.replace(/<script/gi, "&lt;script");
@davecra
davecra / inline4.js
Created May 12, 2023 21:58
inline4.js
const myObj = new MyClassToCallTheServer();
let someValue = await myObj.doSomegthingWithTheServerData();