質問編集履歴
2
誤字の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -440,6 +440,6 @@
|
|
440
440
|
|
441
441
|
|
442
442
|
|
443
|
-
}
|
443
|
+
}
|
444
444
|
|
445
445
|
```
|
1
インデントを揃えました。失礼いたしました!
test
CHANGED
File without changes
|
test
CHANGED
@@ -192,11 +192,11 @@
|
|
192
192
|
|
193
193
|
```JavaScript
|
194
194
|
|
195
|
-
const bookTypesNum = 500;
|
195
|
+
const bookTypesNum = 500;
|
196
196
|
|
197
197
|
const animationTime = 15000; // cssのanimationTimeと一致させる!
|
198
198
|
|
199
|
-
const fetchWeatherInfoInterval = 3600000;
|
199
|
+
const fetchWeatherInfoInterval = 3600000;
|
200
200
|
|
201
201
|
const maxRainfall = 88.7;
|
202
202
|
|
@@ -224,224 +224,222 @@
|
|
224
224
|
|
225
225
|
}
|
226
226
|
|
227
|
-
|
228
|
-
|
229
|
-
|
227
|
+
|
228
|
+
|
229
|
+
|
230
230
|
|
231
231
|
let appearanceRate = 4000;
|
232
232
|
|
233
|
+
|
234
|
+
|
235
|
+
console.log(appearanceRate);
|
236
|
+
|
237
|
+
interval = setInterval(createSentence, appearanceRate);
|
238
|
+
|
239
|
+
return;
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
interval = setInterval(createSentence, appearanceRate);
|
244
|
+
|
245
|
+
;
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
async function getSentence() {
|
254
|
+
|
255
|
+
let id = Math.round(Math.random() * bookTypesNum) + 3;
|
256
|
+
|
257
|
+
let res = await fetch(`https://api.bungomail.com/v0/books/${id}`);
|
258
|
+
|
259
|
+
let json = await res.json();
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
while (
|
264
|
+
|
265
|
+
!("書き出し" in json.book) &&
|
266
|
+
|
267
|
+
!("作品名" in json.book) &&
|
268
|
+
|
269
|
+
!("XHTML/HTMLファイルURL" in json.book) &&
|
270
|
+
|
271
|
+
!("作品ID" in json.book) &&
|
272
|
+
|
273
|
+
json.book["書き出し"] !== ""
|
274
|
+
|
275
|
+
) {
|
276
|
+
|
277
|
+
id = Math.round(Math.random() * bookTypesNum) + 3;
|
278
|
+
|
279
|
+
res = await fetch(`https://api.bungomail.com/v0/books/${id}`);
|
280
|
+
|
281
|
+
json = await res.json();
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
return json;
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
function isOverlapSentence(left) {
|
294
|
+
|
295
|
+
for (let i = 0; i < leftPositions.length; i++) {
|
296
|
+
|
297
|
+
if (leftPositions[i] - 8.0 < left && left < leftPositions[i] + 8.0) {
|
298
|
+
|
299
|
+
return true;
|
300
|
+
|
301
|
+
}
|
302
|
+
|
303
|
+
}
|
304
|
+
|
305
|
+
return false;
|
306
|
+
|
307
|
+
}
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
function createSentenceElement(sentence) {
|
312
|
+
|
313
|
+
const top = (Math.random() * 60).toFixed(2) + "%";
|
314
|
+
|
315
|
+
let left = Math.random() * 95;
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
if (leftPositions) {
|
320
|
+
|
321
|
+
while (isOverlapSentence(left)) {
|
322
|
+
|
323
|
+
left = Math.random() * 95;
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
}
|
328
|
+
|
329
|
+
leftPositions.push(left);
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
let div = document.createElement("div");
|
336
|
+
|
337
|
+
div.setAttribute("class", "water");
|
338
|
+
|
339
|
+
document.body.appendChild(div);
|
340
|
+
|
341
|
+
div.style.left = left.toFixed(2) + "%";
|
342
|
+
|
343
|
+
div.style.top = top;
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
let h2 = document.createElement("h2");
|
352
|
+
|
353
|
+
h2.setAttribute("class", "sentence");
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
document.body.appendChild(h2);
|
358
|
+
|
359
|
+
h2.innerHTML = sentence;
|
360
|
+
|
361
|
+
h2.style.left = left.toFixed(2) + "%";
|
362
|
+
|
363
|
+
h2.style.top = top;
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
setTimeout(function () {
|
376
|
+
|
377
|
+
document.body.removeChild(div);
|
378
|
+
|
379
|
+
document.body.removeChild(h2);
|
380
|
+
|
381
|
+
leftPositions.splice(leftPositions.indexOf(left), 1);
|
382
|
+
|
383
|
+
}, animationTime);
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
}
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
function createSentence() {
|
398
|
+
|
399
|
+
getSentence().then((res) => {
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
let sentence = res.book["書き出し"] + "――『" + res.book["作品名"]+ "』"+res.book["作品ID"];
|
404
|
+
|
405
|
+
url = res.book["XHTML/HTMLファイルURL"];
|
406
|
+
|
407
|
+
//jgid = res.book["作品ID"];
|
408
|
+
|
409
|
+
//console.log(url)
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
document.body.addEventListener("click" ,function() {
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
window.open(url, '_blank');
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
});
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
createSentenceElement(sentence);
|
432
|
+
|
433
|
+
|
434
|
+
|
233
435
|
|
234
436
|
|
235
|
-
|
437
|
+
|
236
|
-
|
237
|
-
interval = setInterval(createSentence, appearanceRate);
|
238
|
-
|
239
|
-
return;
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
interval = setInterval(createSentence, appearanceRate);
|
244
|
-
|
245
|
-
;
|
246
|
-
|
247
|
-
}
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
async function getSentence() {
|
254
|
-
|
255
|
-
let id = Math.round(Math.random() * bookTypesNum) + 3;
|
256
|
-
|
257
|
-
let res = await fetch(`https://api.bungomail.com/v0/books/${id}`);
|
258
|
-
|
259
|
-
let json = await res.json();
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
while (
|
264
|
-
|
265
|
-
!("書き出し" in json.book) &&
|
266
|
-
|
267
|
-
!("作品名" in json.book) &&
|
268
|
-
|
269
|
-
!("XHTML/HTMLファイルURL" in json.book) &&
|
270
|
-
|
271
|
-
!("作品ID" in json.book) &&
|
272
|
-
|
273
|
-
json.book["書き出し"] !== ""
|
274
|
-
|
275
|
-
) {
|
276
|
-
|
277
|
-
id = Math.round(Math.random() * bookTypesNum) + 3;
|
278
|
-
|
279
|
-
res = await fetch(`https://api.bungomail.com/v0/books/${id}`);
|
280
|
-
|
281
|
-
json = await res.json();
|
282
|
-
|
283
|
-
}
|
284
|
-
|
285
|
-
return json;
|
286
|
-
|
287
|
-
}
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
function isOverlapSentence(left) {
|
294
|
-
|
295
|
-
for (let i = 0; i < leftPositions.length; i++) {
|
296
|
-
|
297
|
-
if (leftPositions[i] - 8.0 < left && left < leftPositions[i] + 8.0) {
|
298
|
-
|
299
|
-
return true;
|
300
|
-
|
301
|
-
}
|
302
|
-
|
303
|
-
}
|
304
|
-
|
305
|
-
return false;
|
306
|
-
|
307
|
-
}
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
function createSentenceElement(sentence) {
|
312
|
-
|
313
|
-
const top = (Math.random() * 60).toFixed(2) + "%";
|
314
|
-
|
315
|
-
let left = Math.random() * 95;
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
if (leftPositions) {
|
320
|
-
|
321
|
-
while (isOverlapSentence(left)) {
|
322
|
-
|
323
|
-
left = Math.random() * 95;
|
324
|
-
|
325
|
-
}
|
326
|
-
|
327
|
-
}
|
328
|
-
|
329
|
-
leftPositions.push(left);
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
let div = document.createElement("div");
|
336
|
-
|
337
|
-
div.setAttribute("class", "water");
|
338
|
-
|
339
|
-
document.body.appendChild(div);
|
340
|
-
|
341
|
-
div.style.left = left.toFixed(2) + "%";
|
342
|
-
|
343
|
-
div.style.top = top;
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
let h2 = document.createElement("h2");
|
352
|
-
|
353
|
-
h2.setAttribute("class", "sentence");
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
document.body.appendChild(h2);
|
358
|
-
|
359
|
-
h2.innerHTML = sentence;
|
360
|
-
|
361
|
-
h2.style.left = left.toFixed(2) + "%";
|
362
|
-
|
363
|
-
h2.style.top = top;
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
setTimeout(function () {
|
376
|
-
|
377
|
-
document.body.removeChild(div);
|
378
|
-
|
379
|
-
document.body.removeChild(h2);
|
380
|
-
|
381
|
-
leftPositions.splice(leftPositions.indexOf(left), 1);
|
382
|
-
|
383
|
-
}, animationTime);
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
}
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
function createSentence() {
|
398
|
-
|
399
|
-
getSentence().then((res) => {
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
let sentence = res.book["書き出し"] + "――『" + res.book["作品名"]+ "』"+res.book["作品ID"];
|
404
|
-
|
405
|
-
url = res.book["XHTML/HTMLファイルURL"];
|
406
|
-
|
407
|
-
jgid = res.book["作品ID"];
|
408
|
-
|
409
|
-
//console.log(url)
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
document.body.addEventListener("click" ,function() {
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
window.open(url, '_blank');
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
});
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
createSentenceElement(sentence);
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
//this.onclick = window.open(url, '_blank');
|
436
|
-
|
437
|
-
|
438
438
|
|
439
439
|
});
|
440
440
|
|
441
|
-
|
442
|
-
|
441
|
+
|
442
|
+
|
443
|
-
}
|
443
|
+
}ï
|
444
|
-
|
445
|
-
|
446
444
|
|
447
445
|
```
|