-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.gs
More file actions
77 lines (56 loc) · 3.13 KB
/
ui.gs
File metadata and controls
77 lines (56 loc) · 3.13 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
var SECONDARY_COLOR = '#24978d';
function buildAddOn(e) {
return [buildCard('',e.clientPlatform)];
}
function buildCard(status, platform){
var card = CardService.newCardBuilder();
card.addCardAction(CardService.newCardAction()
.setText('About')
.setOpenLink(CardService.newOpenLink().setUrl('https://github.com/daunera/QuickReply-Buttons/blob/master/README.md')));
card.addCardAction(CardService.newCardAction()
.setText('Delete my saved data')
.setOnClickAction(CardService.newAction().setFunctionName('deleteData')));
card.setHeader(CardService.newCardHeader()
.setTitle('Create your own "smart" reply buttons')
.setImageUrl('http://varosmajor.cserkesz.hu/qrb/reply.png'));
card.addSection(buildSection(status, platform));
return card.build();
}
function buildSection(status, platform){
var section = CardService.newCardSection();
if(platform === 'android' || platform === 'ios'){
section.addWidget(CardService.newTextParagraph().setText('<font color="#ff0000">'+status+'</font>'));
}
section.addWidget(CardService.newTextParagraph().setText('<br><b><font color="'+SECONDARY_COLOR+'">Response mail info</font></b>'));
section.addWidget(buildTextInput('subject', 'Response Subject (required)', 'Without "Re:" prefix, usually same as your mail subject'));
section.addWidget(buildTextInput('replyAddress', 'Reply Address (required)', 'Where the buttons\' link will point'));
section.addWidget(CardService.newTextParagraph().setText('<br><b><font color="'+SECONDARY_COLOR+'">Buttons\' look</font></b>'));
section.addWidget(buildTextInput('buttonTexts', 'Button Texts (required)', 'Separate by comma, whitespace allowed, but trimmed. To use comma, write semicolon and it will be changed'));
section.addWidget(buildTextInput('colorText', 'Text Color (Hex code)', 'By default Google blue (#4885ed)'));
section.addWidget(buildTextInput('colorFill', 'Fill Color (Hex code)', 'By default white'));
section.addWidget(buildTextInput('colorBorder', 'Border Color (Hex code)', 'By default same as text color'));
section.addWidget(buildTextInput('borderRound', 'Border Round', 'Number between 1 and 10, by default 5'));
if(platform === 'web' || !platform){
section.addWidget(CardService.newTextParagraph().setText('<font color="#ff0000">'+status+'</font>'));
}
section.addWidget(CardService.newButtonSet()
.addButton(CardService.newTextButton()
.setText('Insert buttons')
.setOnClickAction(CardService.newAction()
.setFunctionName('insertButtons'))));
return section;
}
function buildTextInput(fieldName, title, hint, value){
var textInput = CardService.newTextInput()
.setFieldName(fieldName)
.setTitle(title)
.setOnChangeAction(CardService.newAction().setFunctionName('saveData'));
if (hint) {
textInput.setHint(hint)
}
if (value) {
textInput.setValue(value);
} else
textInput.setValue(getValue(fieldName));
return textInput;
}