-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateFromExistingJavaScript.html
98 lines (86 loc) · 3.17 KB
/
CreateFromExistingJavaScript.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
<script>
$(function() {
$('#sidebar-save-button').click(onSaveClick);
utils.disableButtons();
clearOptions();
loadConfig();
utils.enableButtons();
});
function onSaveClick() {
utils.disableButtons();
utils.enableLoader();
var saveOptions = getOptions();
google.script.run
.withSuccessHandler(
function(msg) {
if(msg){
console.log(msg);
}else{
console.log('Config saved.');
}
})
.withFailureHandler(
function(msg) {
utils.failure(msg);
})
.createFromExisting(
saveOptions.sheet_name,
saveOptions.range_person_name,
saveOptions.range_timeslot,
saveOptions.range_timestamp,
saveOptions.lookup_sheet_name.
saveOptions.lookup_range_person_name,
saveOptions.lookup_range_timeslot,
saveOptions.lookup_range_timestamp,
saveOptions.lookup_data_retention_days
);
}
function getOptions() {
return {
lookup_sheet_name: $('#sidebar-lookup-sheetname').val().trim(),
lookup_range_person_name: $('#sidebar-lookup-person-name-range').val(),
lookup_range_timeslot: $('#sidebar-lookup-timeslot-range').val(),
lookup_range_timestamp: $('#sidebar-lookup-timestamp-range').val(),
lookup_data_retention_days: $('#sidebar-lookup-data-retention-days').val(),
sheet_name: $('#sidebar-fillup-sheetname').val(),
range_person_name: $('#sidebar-fillup-person-name-range').val(),
range_timeslot: $('#sidebar-fillup-timeslot-range').val(),
range_timestamp: $('#sidebar-fillup-timestamp-range').val()
};
}
function loadConfig() {
google.script.run
.withSuccessHandler(
function(config) {
if (config) {
$('#sidebar-lookup-sheetname').val(config.lookup_sheet_name);
$('#sidebar-lookup-person-name-range').val(config.lookup_range_person_name);
$('#sidebar-lookup-timeslot-range').val(config.lookup_range_timeslot);
$('#sidebar-lookup-timestamp-range').val(config.lookup_range_timestamp);
$('#sidebar-lookup-data-retention-days').val(config.lookup_data_retention_days);
$('#sidebar-fillup-sheetname').val(config.sheet_name);
$('#sidebar-fillup-person-name-range').val(config.range_person_name);
$('#sidebar-fillup-timeslot-range').val(config.range_timeslot);
$('#sidebar-fillup-timestamp-range').val(config.range_timestamp);
} else {
console.log('unable to load config');
}
})
.withFailureHandler(
function(msg) {
utils.failure(msg);
})
.readConfigForActiveSheet();
}
function clearOptions() {
$('#sidebar-lookup-sheetname').val('');
$('#sidebar-lookup-person-name-range').val('');
$('#sidebar-lookup-timeslot-range').val('');
$('#sidebar-lookup-timestamp-range').val('');
$('#sidebar-lookup-data-retention-days').val('');
$('#sidebar-fillup-sheetname').val('');
$('#sidebar-fillup-person-name-range').val('');
$('#sidebar-fillup-timeslot-range').val('');
$('#sidebar-fillup-timestamp-range').val('');
}
</script>