-
Notifications
You must be signed in to change notification settings - Fork 0
/
support.gs
44 lines (37 loc) · 1.16 KB
/
support.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
let sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
function getSeatNumber(){
let ui = SpreadsheetApp.getUi();
let title = 'Where are you?';
let message = 'Please Input your seat Number.'
let res = ui.prompt(title, message, ui.ButtonSet.OK_CANCEL);
let resBtn = res.getSelectedButton();
if(resBtn == ui.Button.OK){
return res.getResponseText();
}else{
return 9999;
}
}
function getCell(seatNumber){
if(seatNumber==9999)
return "S50"
let regex = new RegExp(seatNumber, "i");
let seats = sheet.getRange("A1:T11").getValues();
let alphabets = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
for (let i = 0; i < seats.length; i++)
for (let j = 0; j < seats[i].length; j++)
if (seats[i][j].toString().match(regex))
return alphabets[j] + (i+2);
}
function done() {
sheet.getRange(getCell(getSeatNumber())).setBackground("green");
}
function help() {
sheet.getRange(getCell(getSeatNumber())).setBackground("orange");
}
function reset() {
sheet.getRange(getCell(getSeatNumber())).setBackground("white");
}
function clearAll(){
for (let i = 1; i <= 22; i++)
sheet.getRange(getCell(i)).setBackground("white");
}