回答編集履歴
2
a
test
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
やりたいことベースで考えると重複質問なんですが、debug依頼だと考えると、気持ちいくらい違うコードなんで。よく一つの課題にここまで違うコードを考えられると脱帽です。
|
2
|
-
|
3
|
-
|
4
|
-
|
5
1
|
このコードを直すならこうかなと思います。全部は、というかメッセージを作るとこはみてないです。forのなかで文字列を錬成するなんていうのはロストテクノロジーなんで、私みたいなレベルの低い人間には分かりません。
|
6
2
|
|
7
3
|
|
@@ -18,7 +14,7 @@
|
|
18
14
|
|
19
15
|
var message = getMessage(0);
|
20
16
|
|
21
|
-
if(!_isNull(message)) {
|
17
|
+
if (!_isNull(message)) {
|
22
18
|
|
23
19
|
var options =
|
24
20
|
|
@@ -40,7 +36,7 @@
|
|
40
36
|
|
41
37
|
message = getMessage(1) || '';
|
42
38
|
|
43
|
-
if(!_isNull(message)) {
|
39
|
+
if (!_isNull(message)) {
|
44
40
|
|
45
41
|
var options =
|
46
42
|
|
@@ -66,7 +62,7 @@
|
|
66
62
|
|
67
63
|
function getMessage(prm) {
|
68
64
|
|
69
|
-
const week = ['日','月','火','水','木','金','土'];
|
65
|
+
const week = ['日', '月', '火', '水', '木', '金', '土'];
|
70
66
|
|
71
67
|
|
72
68
|
|
@@ -92,25 +88,25 @@
|
|
92
88
|
|
93
89
|
// タイトル
|
94
90
|
|
95
|
-
if (
|
91
|
+
if (prm == 0) {
|
96
92
|
|
97
93
|
strHeader = '今日 ';
|
98
94
|
|
99
|
-
} else if (
|
95
|
+
} else if (prm == 1) {
|
100
96
|
|
101
97
|
strHeader = '明日 ';
|
102
98
|
|
103
99
|
}
|
104
100
|
|
105
|
-
date = new Date(date.getYear(),date.getMonth(),date.getDate() + prm);
|
101
|
+
date = new Date(date.getYear(), date.getMonth(), date.getDate() + prm);
|
106
|
-
|
102
|
+
|
107
|
-
strHeader += Utilities.formatDate(date,'JST','yyyy/M/d')
|
103
|
+
strHeader += Utilities.formatDate(date, 'JST', 'yyyy/M/d')
|
108
|
-
|
104
|
+
|
109
|
-
+ '(' +week[date.getDay()] + ') の予定\n';
|
105
|
+
+ '(' + week[date.getDay()] + ') の予定\n';
|
110
|
-
|
111
|
-
|
112
|
-
|
106
|
+
|
107
|
+
|
108
|
+
|
113
|
-
var strBody = getEvents(arrCals,date);
|
109
|
+
var strBody = getEvents(arrCals, date);
|
114
110
|
|
115
111
|
//if ( _isNull(strBody) ) strBody = '予定はありません。';
|
116
112
|
|
@@ -120,7 +116,7 @@
|
|
120
116
|
|
121
117
|
|
122
118
|
|
123
|
-
function getEvents(prmarrCals,prmDate) {
|
119
|
+
function getEvents(prmarrCals, prmDate) {
|
124
120
|
|
125
121
|
var strEvents = '';
|
126
122
|
|
@@ -134,49 +130,53 @@
|
|
134
130
|
|
135
131
|
var strDescription = '';
|
136
132
|
|
137
|
-
if (
|
133
|
+
if (!_isNull(prmarrCals)) {
|
138
134
|
|
139
135
|
for (var j = 0; j < prmarrCals.length; j++) {
|
140
136
|
|
137
|
+
var currentEvents = '';
|
138
|
+
|
139
|
+
var arrEvents = prmarrCals[j].getEventsForDay(new Date(prmDate));
|
140
|
+
|
141
|
+
for (var i = 0; i < arrEvents.length; i++) {
|
142
|
+
|
143
|
+
// if (!_isNull(strEvents)) strEvents += '\n';
|
144
|
+
|
145
|
+
var starts = arrEvents[i].getStartTime();
|
146
|
+
|
147
|
+
if (starts.getDate() !== prmDate.getDate()) continue;
|
148
|
+
|
149
|
+
strStart = _HHmm(starts);
|
150
|
+
|
151
|
+
strEnd = _HHmm(arrEvents[i].getEndTime());
|
152
|
+
|
153
|
+
if (strStart === strEnd) {
|
154
|
+
|
155
|
+
strTime = '終日';
|
156
|
+
|
157
|
+
} else {
|
158
|
+
|
159
|
+
strTime = strStart + '~' + strEnd;
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
currentEvents += '・' + strTime + '【' + arrEvents[i].getTitle() + '】';
|
164
|
+
|
165
|
+
strLocation = arrEvents[i].getLocation();
|
166
|
+
|
167
|
+
strDescription = arrEvents[i].getDescription();
|
168
|
+
|
169
|
+
if (!_isNull(strLocation)) currentEvents += '\n 場所:' + strLocation;
|
170
|
+
|
171
|
+
if (!_isNull(strDescription)) currentEvents += '\n 説明:' + strDescription;
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
if (_isNull(currentEvents)) continue;
|
176
|
+
|
141
177
|
if (!_isNull(strEvents)) strEvents += '\n';//
|
142
178
|
|
143
|
-
strEvents += prmarrCals[j].getName() + '\n';//
|
179
|
+
strEvents += prmarrCals[j].getName() + '\n' + currentEvents;//
|
144
|
-
|
145
|
-
var arrEvents = prmarrCals[j].getEventsForDay(new Date(prmDate));
|
146
|
-
|
147
|
-
for (var i = 0; i < arrEvents.length; i++) {
|
148
|
-
|
149
|
-
// if (!_isNull(strEvents)) strEvents += '\n';
|
150
|
-
|
151
|
-
var starts = arrEvents[i].getStartTime();
|
152
|
-
|
153
|
-
if(starts.getDate() !== prmDate.getDate()) continue;
|
154
|
-
|
155
|
-
strStart = _HHmm(starts);
|
156
|
-
|
157
|
-
strEnd = _HHmm(arrEvents[i].getEndTime());
|
158
|
-
|
159
|
-
if (strStart === strEnd) {
|
160
|
-
|
161
|
-
strTime = '終日';
|
162
|
-
|
163
|
-
} else {
|
164
|
-
|
165
|
-
strTime = strStart + '~' + strEnd;
|
166
|
-
|
167
|
-
}
|
168
|
-
|
169
|
-
strEvents += '・' + strTime + '【' + arrEvents[i].getTitle() + '】';
|
170
|
-
|
171
|
-
strLocation = arrEvents[i].getLocation();
|
172
|
-
|
173
|
-
strDescription = arrEvents[i].getDescription();
|
174
|
-
|
175
|
-
if (!_isNull(strLocation)) strEvents += '\n 場所:' + strLocation;
|
176
|
-
|
177
|
-
if (!_isNull(strDescription)) strEvents += '\n 説明:' + strDescription;
|
178
|
-
|
179
|
-
}
|
180
180
|
|
181
181
|
}
|
182
182
|
|
@@ -188,9 +188,9 @@
|
|
188
188
|
|
189
189
|
|
190
190
|
|
191
|
-
function _HHmm(str){
|
191
|
+
function _HHmm(str) {
|
192
|
-
|
192
|
+
|
193
|
-
return Utilities.formatDate(str,'JST','HH:mm');
|
193
|
+
return Utilities.formatDate(str, 'JST', 'HH:mm');
|
194
194
|
|
195
195
|
}
|
196
196
|
|
@@ -198,7 +198,7 @@
|
|
198
198
|
|
199
199
|
function _isNull(prm) {
|
200
200
|
|
201
|
-
if (
|
201
|
+
if (prm == '' || prm === null || prm === undefined) {
|
202
202
|
|
203
203
|
return true;
|
204
204
|
|
1
a
test
CHANGED
@@ -138,11 +138,15 @@
|
|
138
138
|
|
139
139
|
for (var j = 0; j < prmarrCals.length; j++) {
|
140
140
|
|
141
|
+
if (!_isNull(strEvents)) strEvents += '\n';//
|
142
|
+
|
143
|
+
strEvents += prmarrCals[j].getName() + '\n';//
|
144
|
+
|
141
145
|
var arrEvents = prmarrCals[j].getEventsForDay(new Date(prmDate));
|
142
146
|
|
143
147
|
for (var i = 0; i < arrEvents.length; i++) {
|
144
148
|
|
145
|
-
if (!_isNull(strEvents)) strEvents += '\n';
|
149
|
+
// if (!_isNull(strEvents)) strEvents += '\n';
|
146
150
|
|
147
151
|
var starts = arrEvents[i].getStartTime();
|
148
152
|
|