This repository has been archived by the owner on Jun 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.js
56 lines (47 loc) · 1.43 KB
/
code.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* Beta Console Apps Script
*
* Shows two menus in the Beta Programs Google Sheet to:
*
* 1) Deploy: Make it easy to trigger the GitHub action that deploys the site.
* 2) Newsletter: Get the HTML code to copy into the MailChimp template.
*
*/
/**
* Create menu in Sheets UI
*/
function onOpen() {
var ui = SpreadsheetApp.getUi();
// Newsletter menu
ui.createMenu("Newsletter")
.addItem("Get MailChimp code", "getMCCode")
.addItem("Get Tweets", "getTweets")
.addToUi();
}
/**
* Newsletter
*/
// These need to be in the script and not the library because createTemplateFromFile
// is scoped to the calling script. If it's in the library, the template file must
// also be in the library.
function getMCCode() {
// Create HTML from template
var html = HtmlService.createTemplateFromFile("mailchimp.html")
.evaluate()
.setHeight(350);
// Build title
var title = "Mailchimp code for " + LibMailchimpHTML.getNextThurs();
// Show modal
SpreadsheetApp.getUi().showModalDialog(html, title);
}
function getTweets() {
// Create HTML from template
var html = HtmlService.createTemplateFromFile("tweets.html")
.evaluate()
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setHeight(180);
// Build title
var title = "Tweets for " + LibMailchimpHTML.getNextThurs();
// Show modal
SpreadsheetApp.getUi().showModalDialog(html, title);
}