-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_message_prompt.html
104 lines (92 loc) · 3.3 KB
/
custom_message_prompt.html
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<style>
.hidden {display: none;}
</style>
</head>
<body>
<script>
function showChoices(id) {
document.querySelectorAll('.choices').forEach(function (el) {el.classList.add('hidden')});
document.querySelector('#choices' + id).classList.remove('hidden');
}
function toggleTestEmail(el) {
var testEmailElement = document.querySelector('#test_email_inputs');
if (el.checked) {
testEmailElement.classList.remove('hidden');
} else {
testEmailElement.classList.add('hidden');
}
}
function fakeRadio(el) {
if (el.checked) {
var prefix = el.id.substring(0, el.id.lastIndexOf('_'));
['yes', 'no', 'maybe'].forEach(
function (ans) {
var id = prefix + '_' + ans;
if (id !== el.id) {
document.querySelector("#" + id).checked = false;
}
});
}
}
function handleSubmit(formObj) {
google.script.run.withSuccessHandler(google.script.host.close).customMessageHandler(formObj);
}
// Prevent forms from submitting.
function preventFormSubmit() {
var forms = document.querySelectorAll('form');
for (var i = 0; i < forms.length; i++) {
forms[i].addEventListener('submit', function(event) {
event.preventDefault();
});
}
}
window.addEventListener('load', preventFormSubmit);
</script>
<form onsubmit="handleSubmit(this);">
<h1>Custom Email</h1>
<div>
<input type="checkbox" id="test_toggle" onclick="toggleTestEmail(this)" />
<label for="test_toggle">Send Test Email?</label>
<div id="test_email_inputs" class="hidden">
<input type="email" name="test_email_address" />
</div>
</div>
<div>
<b>Send messages based on answer to:</b><br/>
<? for (var i in items) { ?>
<input type="radio" id="<?= items[i].getId() ?>" name="question" value="<?= items[i].getId() ?>" onclick="showChoices(<?= items[i].getId() ?>)">
<label for="<?= items[i].getId() ?>"><?= items[i].getTitle() ?></label><br />
<? } ?>
</div>
<? for (var i in items) { ?>
<div id="choices<?= items[i].getId() ?>" class="choices hidden">
<b>Send to users who replied:</b><br/>
<? var choices = items[i].getChoices(); ?>
<? for (var c in choices) { ?>
<input type="checkbox" name="allowed_responses" id="answer_<?= items[i].getId() ?>_<?= c ?>" value="<?= choices[c].getValue() ?>"/>
<label for="answer_<?= items[i].getId() ?>_<?= c ?>">"<?= choices[c].getValue() ?>"</label><br>
<? } ?>
<input type="checkbox" name="allowed_responses" id="answer_<?= items[i].getId() ?>_none" value=""/>
<label for="answer_<?= items[i].getId() ?>_none">(none)</label><br>
</div>
<? } ?>
<hr/>
<div>
<b>Subject line:</b> <input type="text" name="subject" />
</div>
<div>
<b>Message body:</b><br/>
<textarea name="message" style="width:100%;"></textarea>
</div>
<div>
<input type="checkbox" id="details_checkbox" name="include_details" value="true" checked>
<label for="details_checkbox">Include event details?</label>
</div>
<input type="submit" />
</form>
</body>
</html>