-
Notifications
You must be signed in to change notification settings - Fork 7
/
Server.gs
59 lines (44 loc) · 1.24 KB
/
Server.gs
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
function onOpen() {
SpreadsheetApp
.getUi()
.createMenu('Sidebar')
.addItem('Open', 'onOpenSidebar')
.addToUi()
}
function onOpenSidebar() {
var ui = HtmlService.createTemplateFromFile('Sidebar')
.evaluate()
.setTitle('Materialize CSS Sidebar Example')
SpreadsheetApp.getUi().showSidebar(ui)
}
function onFormSubmit(form) {
var spreadsheet = SpreadsheetApp.getActive()
var sheet = getSheet(spreadsheet)
var photoUrl = (form.filepath) ? DriveApp.createFile(form.photo).getUrl() : ''
sheet.appendRow([
new Date(),
form.first_name,
form.last_name,
form.password,
form.email,
photoUrl
])
// Private Functions
// -----------------
function getSheet(spreadsheet) {
var sheet = spreadsheet.getSheetByName('Results')
if (sheet === null) {
sheet = spreadsheet.insertSheet().setName('Results')
}
if (sheet.getRange('A1').getValue() === '') {
sheet
.getRange('A1:F1')
.setValues([['Timestamp', 'First Name', 'Last Name', 'Password', 'Email', 'Photo']])
sheet.setFrozenRows(1)
}
return sheet
}
}
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename).getContent()
}