-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
57 lines (45 loc) · 1.65 KB
/
main.js
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
const btn1 = document.querySelector('.juke');
const btn2 = document.querySelector('.title');
const btn3 = document.querySelector('.goToPage')
const isSupported = !!(
'ontouchstart' in window ||
(navigator.pointerEnabled && navigator.maxTouchPoints > 0)
);
if(isSupported){
document.querySelector('.log').innerHTML = 'Smartphone or Touchable-PC';
}else{
document.querySelector('.log').innerHTML = 'PC';
}
const URLs = ['https://www.youtube.com/watch?v=ony539T074w',
'https://www.youtube.com/watch?v=LIlZCmETvsY',
'https://www.youtube.com/watch?v=MSv7NbfbtU8',
'https://www.youtube.com/watch?v=RLAw8Ct9k48',
'https://www.youtube.com/watch?v=XDiuwqJg8pU'];
btn1.addEventListener('click', (juke) => {
const isYes = confirm(`${URLs.length}曲からランダムに選ばれます`);
if(isYes){
const random = Math.floor(Math.random()*URLs.length);
const win = window.open(`${URLs[random]}`);
win.focus();
}
});
btn2.addEventListener('click', (event) => {
const msg = prompt('タイトルいれて','title');
document.title = msg;
});
btn3.addEventListener('click', (event) => {
// 入力欄からURLを取得
const path = document.getElementById("pathInput").value;
// パスが空でないことを確認
if (path) {
// 相対パスで移動
window.location.href = window.location.origin + '/' + path + '.html';
} else {
alert("相対パスを入力してください。");
}
});
setInterval( () => {
const parent = document.querySelector('.box');
const child = document.querySelector('.del');
parent.removeChild(child);
}, 5000);