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 / etag.js
Created November 10, 2023 03:13
Converts an @odata.etag
View etag.js
const updatedTag = eTag.replace('W/"', '"').replace('\\"', "");
@davecra
davecra / ref.js
Created November 10, 2023 03:11
Creates a new reference for a Planner Task Attachment
View ref.js
const ref = {
/** @type {PlannerReference} */
[this.#encodePlannerExternalReferenceUrl(driveItem.webUrl)]: {
"@odata.type": "#microsoft.graph.plannerExternalReference",
alias: name,
type: "Other",
},
};
@davecra
davecra / enocdePlannerUrl.js
Created November 10, 2023 03:04
Encodes a URL in a format the Graph API References will accept
View enocdePlannerUrl.js
/**
* Encodes the URL ins the special planner format that is for oif but not quite
* following the encodeURIComponent() specification...
* @param {String} url
* @returns {String}
*/
#encodePlannerExternalReferenceUrl = (url) => {
// Encode specific characters: : . _
const encodedUrl = url.replace(/:/g, "%3A").replace(/\./g, "%2E").replace(/ /g, "%20");
return encodedUrl;
@davecra
davecra / client.js
Created October 22, 2023 20:20
Procured Board Button
View client.js
/// <reference path="trello.d.js" />
/** @type {TrelloPowerUp} */
const tpu = window.TrelloPowerUp;
tpu.initialize({
'board-buttons':
/**
* Returns the board button
* @param {TrelloObject} t
* @returns {TrelloBoardButtonOption[]}
*/
@davecra
davecra / webpack.config.js
Created October 22, 2023 20:04
Webpack.config.js for Power-Up
View webpack.config.js
const CopyWebpackPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const fs = require("fs");
module.exports = async (env, options) => {
const isProduction = options.mode === 'production';
const config = {
devtool: isProduction ? false : 'source-map',
mode: isProduction ? "production" : "development",
entry: {
details: "./js/details.js",
@davecra
davecra / package.json
Created October 22, 2023 20:03
Package.json for Power-Up
View package.json
{
"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
View settingsPage.js
/// <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
View details.js
/* 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
View client.js
/* 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
View common.js
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} */