This repository was archived by the owner on Jun 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcode.js
More file actions
50 lines (42 loc) · 1.33 KB
/
code.js
File metadata and controls
50 lines (42 loc) · 1.33 KB
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
/**
* Interesting Tools Apps Script
*
* Shows the deploy menu in the Interesting Tools Google Sheet to get the HTML
* code to copy into the MailChimp template.
*
*/
/**
* Create menu in Sheets UI
*/
function onOpen() {
var ui = SpreadsheetApp.getUi();
// Newsletter meny
ui.createMenu("Newsletter")
.addItem("Get MailChimp code", "getMCCode")
.addItem("Get Tweets", "getTweets")
.addToUi();
}
// These needs 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);
}