-
Notifications
You must be signed in to change notification settings - Fork 0
/
コード.gs
68 lines (61 loc) · 2.39 KB
/
コード.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
function doPost(e) {
var params = JSON.parse(e.postData.getDataAsString());
var properties = PropertiesService.getScriptProperties();
var isKagawa = "guest";
var weekPlayTime = 0;
var dayPlayTime = 0;
var allPlayTime = 0;
if (properties.getProperty(params.name)) {
var data = Json.parse(properties.getProperty(params.name));
if (params.option === "add") {
data.weekPlayTime += params.value;
data.dayPlayTime += params.value;
data.allPlayTime += params.value;
isKagawa = data.isKagawa;
weekPlayTime = data.weekPlayTime;
dayPlayTime = data.dayPlayTime;
allPlayTime = data.allPlayTime;
properties.setProperty(params.name, Json.stringify({isKagawa: isKagawa, weekPlayTime: weekPlayTime, dayPlayTime: dayPlayTime, allPlayTime: allPlayTime}));
}else if (params.option === set) {
var json = Json.parse(properties.getProperty(params.name));
json.isKagawa = params.value;
properties.setProperty(params.name, Json.stringify(json));
isKagawa = data.isKagawa;
weekPlayTime = data.weekPlayTime;
dayPlayTime = data.dayPlayTime;
allPlayTime = data.allPlayTime;
} else {
isKagawa = data.isKagawa;
weekPlayTime = data.weekPlayTime;
dayPlayTime = data.dayPlayTime;
allPlayTime = data.allPlayTime;
}
} else {
if (params.option === "register") {
properties.setProperty(params.name, Json.stringify({isKagawa: params.value, weekPlayTime: weekPlayTime, dayPlayTime: dayPlayTime, allPlayTime: allPlayTime}));
isKagawa = params.value;
}
}
var output = ContentService.createTextOutput();
output.setMimeType(ContentService.MimeType.JSON);
output.setContent(JSON.stringify({isKagawa: isKagawa, weekPlayTime: weekPlayTime, dayPlayTime: dayPlayTime, allPlayTime: allPlayTime}));
return output;
}
function resetDay() {
var properties = PropertiesService.getScriptProperties();
var userDatas = properties.getProperties();
for(var user in userDatas) {
var json = Json.parse(userDatas[user]);
json.dayPlayTime = 0;
properties.setProperty(user, Json.stringfy(json));
}
}
function resetWeek() {
var properties = PropertiesService.getScriptProperties();
var userDatas = properties.getProperties();
for(var user in userDatas) {
var json = Json.parse(userDatas[user]);
json.weekPlayTime = 0;
properties.setProperty(user, Json.stringfy(json));
}
}