質問編集履歴
1
コードの削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,49 +9,7 @@
|
|
9
9
|
### 該当のソースコード
|
10
10
|
|
11
11
|
```index.html
|
12
|
-
|
12
|
+
|
13
|
-
<html lang="ja">
|
14
|
-
<head>
|
15
|
-
<meta charset="UTF-8">
|
16
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
17
|
-
<title>今日のひとこと</title>
|
18
|
-
<style>
|
19
|
-
html {
|
20
|
-
cursor: default;
|
21
|
-
}
|
22
|
-
body {
|
23
|
-
background-image:url("https://lh3.googleusercontent.com/d/1948EkuyFTuHsrJZmM8LDQCbcrmQrnEQk");
|
24
|
-
background-position:center top;
|
25
|
-
background-repeat: no-repeat;
|
26
|
-
background-size: cover;
|
27
|
-
background-attachment: fixed;
|
28
|
-
text-align: center;
|
29
|
-
font-family: serif;
|
30
|
-
color:white;
|
31
|
-
text-shadow: 2px 2px 2px black;
|
32
|
-
font-weight:bold;
|
33
|
-
overflow-x:hidden
|
34
|
-
}
|
35
|
-
|
36
|
-
h1{
|
37
|
-
margin-top: 15%;
|
38
|
-
margin-left:15%;
|
39
|
-
margin-right:15%;
|
40
|
-
font-size:25px;
|
41
|
-
}
|
42
|
-
p{
|
43
|
-
font-size: 25px;
|
44
|
-
}
|
45
|
-
.text-button:hover{
|
46
|
-
backdrop-filter: sepia(20%);
|
47
|
-
border-radius:20px;
|
48
|
-
cursor: pointer;
|
49
|
-
width:150px;
|
50
|
-
}
|
51
|
-
.text-button{
|
52
|
-
width:180px;
|
53
|
-
margin:5% auto auto auto;
|
54
|
-
}
|
55
13
|
.fadeIn{
|
56
14
|
animation-name:fadeInAnime;
|
57
15
|
animation-duration:3s;
|
@@ -74,48 +32,22 @@
|
|
74
32
|
<script type="text/javascript" charset="UTF-8" src="//cache1.value-domain.com/xrea_header.js" async="async"></script>
|
75
33
|
</head>
|
76
34
|
<body>
|
77
|
-
|
35
|
+
|
78
36
|
<p id="name"></p>
|
79
37
|
<p class="text-button" id="text-button">Click Here</p>
|
80
|
-
|
38
|
+
|
81
39
|
<script>
|
82
|
-
document.getElementById("text-button").onclick = function() {//ボタン押下時の動作
|
83
|
-
async function fetchData() {//jsonデータをfetchし、wordsという名の変数に辞書型のような状態で格納し返す
|
84
|
-
console.log("押された");
|
85
|
-
const res = await fetch("https://script.google.com/macros/s/AKfycbwHgr1r_IMMX5i-icdtoQxj6uhmzkSey-IjZAOcpRTjFu48L4sDrpydm7DNumZdQqq8/exec");
|
86
|
-
const data = await res.json();
|
87
|
-
let words = [];
|
88
|
-
for (i = 0; i <data.length; i++){
|
89
|
-
words.push(data[i][i+1]);
|
90
|
-
}
|
91
|
-
|
40
|
+
//省略
|
92
|
-
}
|
93
|
-
|
94
|
-
fetchData().then(lists => {//上の処理が終わった後に以下の動作を実施
|
95
|
-
let wordsList = [];
|
96
|
-
nameValue = lists[0];
|
97
|
-
for (let j = 1;j<lists.length;j++){
|
98
|
-
wordsList.push(lists[j]);
|
99
|
-
}
|
100
|
-
let selecter = parseInt(Math.random()*((wordsList.length)-1)+1);
|
101
|
-
let button = document.getElementById("text-button");
|
102
|
-
let words = document.getElementById("words");
|
103
|
-
|
41
|
+
if(name.classList.contains("fadeIn")){
|
104
|
-
|
42
|
+
|
105
|
-
。一回目のボタン押下字には適用された表示をします。二回目以降もクラスは適用されているようなのですが、一回目のような効果を伴う画面表示がされません*/
|
106
|
-
console.log("contain");
|
107
43
|
console.log(words);
|
108
44
|
console.log(name);
|
109
45
|
|
110
46
|
}else{
|
111
|
-
|
47
|
+
|
112
|
-
console.log(words);
|
113
|
-
console.log(name);
|
114
48
|
words.classList.add("fadeIn");
|
115
49
|
name.classList.add("fadeIn");
|
116
|
-
|
50
|
+
|
117
|
-
console.log(words);
|
118
|
-
console.log(name);
|
119
51
|
}
|
120
52
|
words.innerHTML = wordsList[selecter];
|
121
53
|
name.innerHTML = nameValue;
|