-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserch.html
236 lines (214 loc) · 8.89 KB
/
serch.html
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>タブタイトル</title>
<style>
.parent {
display: flex;
}
.child {
color: black;
border: double;
border-radius: 10px;
border-color: gray;
text-align: center;
width: 450px;
height: 300px;
background-color: bisque;
position: relative;
margin: 100px auto auto 0px;
padding: auto;
font-size: large;
display: inline-block;
}
</style>
<script>
//IFrame Player API の読み込み
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var keyword = "";
var dataCnt;
var ytData = [
{
id: '', //youtubeのID
area: '', //youtubeを表示する場所
part: '',
tempo: '',
user: ''
}
];
var ytPlayer = [];
var instObjs = [];
function reqListener2() {
var responseParmArray = this.responseText.split(",");
console.log(this.responseText);
dataCnt = responseParmArray.length / 3;
var root = document.createElement('rootObj');
for (var i = 0; i < dataCnt - 1; i++) {
// ytData[i]['id'] = responseParmArray[i * 5];
// ytData[i]['area'] = i + 1;
// ytData[i]['part'] = responseParmArray[(i * 5) + 1];
// ytData[i]['tempo'] = responseParmArray[(i * 5) + 2];
// ytData[i]['user'] = responseParmArray[(i * 5) + 3];
var new_data = {
id: responseParmArray[i * 4], //youtubeのID
area: String(i + 1), //youtubeを表示する場所
part: responseParmArray[(i * 4) + 1],
tempo: responseParmArray[(i * 4) + 2],
user: responseParmArray[(i * 4) + 3]
};
ytData.push(new_data);
}
console.log(ytData);
// areas = [];
// users = [];
// tempos = [];
// buttons = [];
for (var i = 1; i < ytData.length; i++) {
var resource = document.getElementById("template");
var instObj = resource.content.cloneNode(true);
instObjs.push(instObj);
instObj.querySelector(".area").id = String(i);
instObj.querySelector(".user").innerHTML = ytData[i]['user'];
instObj.querySelector(".tempo").innerHTML = ytData[i]['tempo'];
instObj.querySelector(".selectButton").value = ytData[i]['id'];
instObj.querySelector(".part").innerHTML = ytData[i]['part'];
document.getElementById("root").appendChild(instObj);
// document.getElementById("tempArea").id = String(i);
// document.getElementById("user").innerHTML = ytData[i]['user'];
// document.getElementById("tempo").innerHTML = ytData[i]['tempo'];
// document.getElementById("selectButton").value = ytData[i]['id'];
// resource.parentElement.after(instObj);
// root.after(instObj);
// console.log(ytData[i]['id']);
ytPlayer[i] = new YT.Player(ytData[i]['area'], {
width: 350,
height: 200,
videoId: ytData[i]['id'],
playerVars: {
rel: 0, //再生動画と同じチャンネルから関連動画を選択
modestbranding: 1 //YouTubeロゴを表示しない
}
});
}
// var elem = document.createElement('div');
// elem.innerHTML = this.responseText;
// my_div = document.getElementById("org_div1");
// document.body.insertBefore(elem, my_div);
// console.log(this.responseText)
}
function search() {
// for (var i = 0; i < ytPlayer.length; i++) {
// document.getElementById(String(i + 1)).remove();
// }
document.getElementById("root").innerHTML = '';
ytData = [
{
id: '', //youtubeのID
area: '', //youtubeを表示する場所
part: '',
tempo: '',
user: ''
}
];
ytPlayer = [];
var search = document.getElementById("serch").value;
//var keyword = "";
var url = "keyword.php?search=" + search;
// var url = "test.php";
const request = new XMLHttpRequest();
request.addEventListener("load", reqListener2);
request.open("GET", url, true);
request.send("");
}
function reqListener() {
var elem = document.createElement('div');
elem.innerHTML = this.responseText;
my_div = document.getElementById("org_div1");
document.body.insertBefore(elem, my_div);
console.log(this.responseText)
}
//YouTubeの埋め込み
function onYouTubeIframeAPIReady() {
}
var selectedCnt = 0;
function addID(value) {
var input = document.createElement("input");
input.name = "id" + selectedCnt;
input.value = value;
input.type = "hidden";
document.getElementById("get").insertBefore(input, document.getElementById("submit"));
selectedCnt++;
}
</script>
</head>
<body style="background-color: gray;">
<section>
<div id="upper-bar"
style="background-color: blanchedalmond; padding: 10px 10px; border-radius: 10px; border-style:solid; border-color: red;">
<button id="button" aria-pressed="false" style="font-size: 20px; border-radius: 5px;">
三
</button>
<a href="/home.php">Bander</a>
<a href="/account_part.html">
<img class="account" src="account.png"
style="width: 40px; height: 40px; display: block; float:right; position: relative;">
</a>
<a href="/serch.html">
<img src="bell.png"
style="width: 30px; height: 30px; display: block; float:right; position: relative; margin-right: 5px; margin-top: 5px;">
</a>
<a href="/upload.php">
<img class="upload" src="upload.png"
style="width: 45px; height: 45px; display: block; float:right; position: relative; margin-right: 6px;">
</a>
</div>
</section>
<section>
<div id="serch-bar">
<form id="serchform" align="center" style="position: relative; top: 50px">
<input type="serch" name="serch" id="serch" placeholder="検索"
style="padding: 10px; width: 250px; font-size: 1.1em; height: 10px; border-radius: 5px; border: double;">
</form>
<button id="serch-button" onclick="search()" style="font-size: 20px; padding: 2px; border-radius: 5px;">
serch
</button>
</div>
</section>
<section>
<form id="get" method="get" action="multi.html">
<button id="submit" type="submit"
style="margin: 50px 0px 0px 0px; width: 150px; height: 50px; font-size: 20px; border-radius: 5px;">
演奏する
</button>
</form>
</section>
<section id="rootObj">
<div id = "root" style="display: inline;">
</div>
</section>
<template id="template">
<div id="tempDiv" class="child">
<p>
<div class="area" id="area" style="position: relative; display: block; margin: 0px auto;"></div>
<div style="display: flex;">
<img class="follow_account" src="account.png"
style="width: 50px; height: 50px; margin-left: 50px;">
<div style="font-size: 10px;">
<p id="user" class="user">山田太郎</p>
<p id="tempo" class="tempo">テンポ:</p>
<p id="part" class="part">パート:</p>
</div>
<button class="selectButton" id="selectButton" onclick="addID(this.value)" value=""
style="display: inline; margin: 20px auto 0px auto; width: 150px; height: 40px; font-size: 16px;">
演奏に追加する
</button>
</div>
</p>
</div>
</template>
</body>
</html>