-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJavaScript.html
68 lines (67 loc) · 2.17 KB
/
JavaScript.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
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script>
var utils = {
/**
* 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.
*/
showStatus: function(msg, classId) {
$('#sidebar-status').removeClass().html(msg);
if (classId) {
$('#sidebar-status').addClass(classId);
}
},
disableButtons: function() {
$(".sidebar-button").prop('disabled', true);
},
enableButtons: function() {
$(".sidebar-button").prop('disabled', false);
},
enableLoader: function() {
$('#static-loader').removeClass().addClass('hidden');
$('#dynamic-loader').removeClass().addClass('show-inline');
},
disableLoader: function() {
$('#dynamic-loader').removeClass().addClass('hidden');
$('#static-loader').removeClass().addClass('show-inline');
},
success: function(msg) {
utils.showStatus(msg);
utils.enableButtons();
utils.disableLoader();
},
failure: function(msg) {
utils.showStatus(msg, 'error');
utils.enableButtons();
utils.disableLoader();
},
updateRange: function(range_element_id, sheetname_element_id) {
var $range_element = $('#' + range_element_id);
var $sheetname_element = $('#' + sheetname_element_id);
google.script.run
.withSuccessHandler(function(msg) {
if (msg) {
if (range_element_id) {
if ($range_element.val() != msg.range) {
$range_element.val(msg.range);
}
}
if (sheetname_element_id) {
if ($sheetname_element.val() != msg.sheetname) {
$sheetname_element.val(msg.sheetname);
}
}
}
utils.success('');
})
.withFailureHandler(function(msg) {
utils.failure(msg);
})
.getSelectedRangeWithSheetname();
}
}
</script>