-
Notifications
You must be signed in to change notification settings - Fork 0
/
SidebarJavaScript.html
73 lines (64 loc) · 2.36 KB
/
SidebarJavaScript.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
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
/**
* Run initializations on sidebar load.
*/
$(function() {
// Assign handler functions to sidebar elements here, if needed.
$('#sidebar-file-picker-button').click(onFolderPickClick);
$('#add-more-fields').click(onShowOptionalFieldsClick);
});
/**
* Calls the server to close the sidebar.
*/
function onShowOptionalFieldsClick() {
$('#add-more-fields').hide();
$('#form-optional-fields').show();
}
function onFolderPickClick() {
var curHeader = getCurrentHeaders();
// Send the value to the server and handle the response.
google.script.run
.withSuccessHandler(
function (msg,folder){
$('#sidebar-get-data-button').prop('disabled', false);
})
.withFailureHandler(
function(msg, element) {
showStatus('Unable to load Folder Picker.','error');
})
.showPicker(curHeader)
}
/**
* Displays the given status message in the sidebar.
*
* @param {String} msg The status message to display.
* @param {String} classId The message type (class id) that the message
* should be displayed as.
*/
function showStatus(msg, classId) {
$('#sidebar-status').removeClass().html(msg);
if (classId) {
$('#sidebar-status').addClass(classId);
}
}
function getCurrentHeaders(){
var obj = {
'Name': $('#Name').prop( "checked" ),
'Type': $('#Type').prop( "checked" ),
'Description': $('#Description').prop( "checked" ),
'Id': $('#Id').prop( "checked" ),
'Url': $('#Url').prop( "checked" ),
'Date created': $('#Date-created').prop( "checked" ),
'Last updated': $('#Last-updated').prop( "checked" ),
'Size': $('#Size').prop( "checked" ),
'Owner': $('#Owner').prop( "checked" ),
'Sharing Access': $('#Sharing-Access').prop( "checked" ),
'Sharing Permission': $('#Sharing-Permission').prop( "checked" ),
'Viewers': $('#Viewers').prop( "checked" ),
'Editors': $('#Editors').prop( "checked" ),
'Parent folder': $('#Parent-folder').prop( "checked" )
}
return obj;
}
</script>