-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
105 lines (82 loc) · 3.09 KB
/
script.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
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
console.log("for Freedom! 24th DEY");
const pKeys = document.querySelectorAll(".piano-keys .key");
const volumeSlider = document.querySelector(".volume-slider input");
const keysOpacity = document.querySelector(".keys-checkbox input");
const container = document.querySelector(".container");
const ftr = document.querySelector("#ftr");
const alertph = document.querySelector(".anotherclass");
const flScr = document.querySelector(".fl-btn");
// const alertPhone = document.getElementById("aphone");
// const alPhoneBg = document.getElementsByClassName("background-dark");
let allKeys = [];
let sound = new Audio(`tunes/a.wav`); // by Default
function playTune(key) {
sound.src = `tunes/${key}.wav`;
sound.play();
const clickedKey = document.querySelector(`[data-key="${key}"]`);
clickedKey.classList.add("active");
setTimeout(() => {
clickedKey.classList.remove("active");
}, 200);
}
pKeys.forEach(key => {
allKeys.push(key.dataset.key);
key.addEventListener("click", () => playTune(key.dataset.key));
});
function pressedKey(e) {
// if the pressed key is in the allKeys array, only call the playTune function
if (allKeys.includes(e.key)) playTune(e.key);
// console.log('key');
}
function hideKeys() {
pKeys.forEach(key => key.classList.toggle("hide"));
}
function volSlider(e) {
sound.volume = e.target.value;
}
screen.addEventListener("orientationchange", () => {
console.log(`The orientation of the screen is: ${screen.orientation}`);
});
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
// $('body').css({
// "-webkit-transform": "rotate(90deg)"
// });
// if(window.innerHeight > window.innerWidth){
// alert("Please use Landscape!");
// }
if (window.matchMedia("(orientation: portrait)").matches) {
// alert("You are in portrait mode");
container.style.display = "none";
alertph.style.display = "flex";
ftr.style.display = "none";
// para.appendChild(node);
// const element = document.getElementById("div1");
// element.appendChild(para);
}
if (window.matchMedia("(orientation: landscape)").matches) {
// alert("You are in landscape mode");
// container.style.display = "none";
// ftr.style.display = "none";
// alertph.classList.add("anotherclass");
alertph.classList.add("none");
setTimeout( ()=> {
ftr.style.opacity = 0;
flScr.style.opacity = 0;
}, 10000);
}
}
// full screnn
const elem = document.documentElement;
function openFullscreen() {
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.webkitRequestFullscreen) { /* Safari */
elem.webkitRequestFullscreen();
} else if (elem.msRequestFullscreen) { /* IE11 */
elem.msRequestFullscreen();
}
}
// screen.orientation.lock('landscape').then(res=>console.log(res)).catch(err=>console.log(err))
volumeSlider.addEventListener("input", volSlider);
keysOpacity.addEventListener("click", hideKeys);
document.addEventListener("keydown", pressedKey);