This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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, "<script"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myObj = new MyClassToCallTheServer(); | |
let someValue = await myObj.doSomegthingWithTheServerData(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class MyClassToCallTheServer { | |
#internvalValue = null; | |
#loading = false; | |
constrcutor() { | |
this.#internalValue = this.#callTheServer(); | |
} | |
doSomethingWithTheServerData = async () => { | |
while(this.#loading) await new Promise(resolve => setTimeout(resolve, 10)); | |
// the #internalValue is not null because we waited | |
return this.#internalValue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class MyClassToCallTheServer { | |
#internvalValue = null; | |
constrcutor() { | |
// this.#internalValue = await this.#callTheServer(); <-- the await will fail to compile | |
this.#internalValue = this.#callTheServer(); | |
} | |
doSomethingWithTheServerData = () => { | |
// the #internalValue is still null becasue we could not await in the constructor | |
return this.#internalValue; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myObj = new MyClassToCallTheServer(); | |
let someValue = myObj.doSomegthingWithTheServerData(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns the data type based on the base64 string | |
* @param {String} base64String | |
* @param {String} fileName | |
* @returns {String} | |
*/ | |
detectMimeType(base64String, fileName) { | |
var ext = fileName.substring(fileName.lastIndexOf(".") + 1); | |
if (ext === undefined || ext === null || ext === "") ext = "bin"; | |
ext = ext.toLowerCase(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function getUserName() { | |
try { | |
let tokenData = await OfficeRuntime.auth.getAccessToken({ allowSignInPrompt: false, forMSGraphAccess: true }); | |
var parts = tokenData.split("."); | |
var token = JSON.parse(atob(parts[1])); | |
return token.preferred_username; | |
} | |
catch (exception) { | |
console.log(exception.message); | |
} |