-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.gs
71 lines (63 loc) · 1.98 KB
/
global.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
60
61
62
63
64
65
66
67
68
69
70
71
/////////////////////////VARIABLES/////////////////////////
/**
* [global] The version number.
* @type {string}
*/
const VERSION = 'v1.1.1' //all version info's displayed reference this string
function get_ui(){
try{
/**
* [global] The handle for the current ui (independent to spreadsheet or sheet, etc.)
* @type {Ui}
*/
var ui = SpreadsheetApp.getUi();
}catch (error) {
Logger.log('Exception in Fetching UI: \n' + error);
}
return ui;
}
/**
* [global] retrieves the scoring system spreadsheet
* @return {SpreadsheetApp.Spreadsheet} the spreadsheet
*/
function get_ss_spreadsheet(){return SpreadsheetApp.getActive();}
/**
* [global] The time of excecution summarized as "yyyy-MM-dd-HH:mm"
* @return {String} the time
*/
function get_now(seconds = false) {
// timezone = "GMT+" + new Date().getTimezoneOffset()/60
timezone = SpreadsheetApp.getActive().getSpreadsheetTimeZone();
if(seconds){date = Utilities.formatDate(new Date(), timezone, "yyyy-MM-dd-HH:mm:ss.SSS");}
else {date = Utilities.formatDate(new Date(), timezone, "yyyy-MM-dd-HH:mm");}
return date;
}
function get_milisec(){
var t = new Date();
return t.getTime().toFixed(0)
}
/**
* [global] Fetches all named ranges (type:namedRange) with specified name and exactness
*
*/
function get_nr(name = "",name2 = "",exact = false) {
var nr_raw = SpreadsheetApp.getActive().getNamedRanges();
// Logger.log(nr_raw.map((a)=>a.getName()));
var nrs = [];
if(name == ""){return nr_raw;}
for(var nr of nr_raw){
// Logger.log(nr.getName());
if(exact){if(nr.getName()==name){return nr;}}
else if(nr.getName().includes(name) && nr.getName().includes(name2)){
nrs.push(nr)
}
}
return nrs
}
function get_full_name(){
return `${get_prop_value("category",'d')}-${get_prop_value("callname",'d')}`
}
function get_cache_expiration(){return 600;} //cache expiration time in seconds
function get_visible_sheet_colors(){
return ["#000000","#ff0000","#ff00ff","#0000ff"]
}