-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelper.js
More file actions
51 lines (47 loc) · 1.69 KB
/
helper.js
File metadata and controls
51 lines (47 loc) · 1.69 KB
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
// enterPrefix, prefixHeadings, sequentialNumbers, ignoredTextEditSetting use the function
function getValueFromUser(title,text, defaultOK, defaultCancel, defaultClose) {
text = text || "Please enter a value.";
defaultOK = defaultOK || "";
defaultCancel = defaultCancel || null;
defaultClose = defaultClose || null;
if (!text) {
//text = text || title;
title = text;
title = "BUtils";
};
var result = DocumentApp.getUi().prompt(title,text, DocumentApp.getUi().ButtonSet.OK_CANCEL);
// Process the user's response:
if (result.getSelectedButton() == DocumentApp.getUi().Button.OK) {
var res = result.getResponseText();
// DocumentApp.getUi().alert('Result: '+res);
if (res == "" && defaultOK) {
return defaultOK;
} else {
return res;
};
} else if (result.getSelectedButton() == DocumentApp.getUi().Button.CANCEL) {
//DocumentApp.getUi().alert('The user didn\'t want to provide a value.');
return defaultCancel;
} else if (result.getSelectedButton() == DocumentApp.getUi().Button.CLOSE) {
//DocumentApp.getUi().alert('The user clicked the close button in the dialog\'s title bar.');
return defaultClose;
}
DocumentApp.getUi().alert('Unknown action.');
return null;
}
// ignoredTextShowCurrentSetting
function getConfirmationFromUser(text) {
// Display a dialog box with a message and "Yes" and "No" buttons.
var ui = DocumentApp.getUi();
var response = ui.alert(text, ui.ButtonSet.YES_NO);
// Process the user's response.
if (response == ui.Button.YES) {
return true;
} else {
return false;
}
}
// numberHeadings, showCurrentStyle use the function
function alert(text) {
DocumentApp.getUi().alert(text);
};