-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenglishWord.js
More file actions
57 lines (53 loc) · 1.47 KB
/
englishWord.js
File metadata and controls
57 lines (53 loc) · 1.47 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
51
52
53
54
55
56
57
const sheet_name = Math.floor(Math.random() * 2) == 0 ? "必修速読英単語" : "英熟語ターゲット";
const wordID_str = sheet_name === "必修速読英単語" ? '速単-' : '熟語-';
const sheet = SpreadsheetApp.openById(PropertiesService.getScriptProperties().getProperty("ENGLISHWORD_SHEET")).getSheetByName(sheet_name);
const wordNum = sheet.getLastRow();
let wordIndex = Math.floor(Math.random() * wordNum) + 1;
function getWord() {
const wordID = sheet.getRange(wordIndex, 1).getValue();
const word = sheet.getRange(wordIndex, 2).getValue();
const wordType = sheet.getRange(wordIndex, 3).getValue();
return {
"type": "box",
"layout": "horizontal",
"contents": [
{
"type": "text",
"text": '【' + wordID_str + wordID + '】',
"flex": 0,
"size": "md",
"color": "#444444"
},
{
"type": "text",
"text": word,
"flex": 0,
"size": "md",
"color": "#444444"
},
{
"type": "text",
"text": '(' + wordType + ')',
"flex": 0,
"size": "md",
"margin": "md",
"color": "#444444",
"gravity": "center"
}
],
"margin": "xs"
}
}
function getMeaning() {
const wordMeaning = sheet.getRange(wordIndex, 4).getValue();
return {
"type": "text",
"text": wordMeaning,
"wrap": true,
"gravity": "center",
"margin": "xs",
"size": "sm",
"color": "#444444",
"offsetStart": "md"
}
}