-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.js
98 lines (85 loc) · 3.52 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
function setTheme() {
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
colorCSS.href = 'color-dark.css';
fontcolor = 'white';
} else {
colorCSS.href = 'color-light.css';
fontcolor = 'black';
}
}
function setLayout() {
var mobile = false;
if (/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(navigator.userAgent)) {
//document.body.style.zoom = window.devicePixelRatio * window.innerWidth / 1100;
let zoom = window.devicePixelRatio * window.innerWidth / 1100;
if (window.devicePixelRatio * window.innerHeight / 1100 < zoom) {
zoom = window.devicePixelRatio * window.innerHeight / 1100;
}
document.body.style.zoom = zoom;
mobile = true;
}
if (window.innerHeight > window.innerWidth) {
layoutCSS.href = 'layout-mobile.css';
if (!(mobile) && window.innerWidth < 500) {
document.body.style.zoom = 100 - (100 - window.innerWidth / 510 * 100) + "%";
}
} else {
layoutCSS.href = 'layout-desktop.css';
}
}
var colorCSS = document.createElement('link');
colorCSS.rel = ' stylesheet'
document.head.appendChild(colorCSS);
var layoutCSS = document.createElement('link');
layoutCSS.rel = ' stylesheet'
document.head.appendChild(layoutCSS);
const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
const setColorScheme = setTheme;
setColorScheme(colorSchemeQueryList);
colorSchemeQueryList.addEventListener('change', setColorScheme);
window.onresize = setLayout;
var bigTextarea = 0;
var fontcolor = 'black';
setTheme()
setLayout();
function showInput() {
document.getElementById("input").style.visibility = "initial";
document.getElementById("output").style.visibility = "hidden";
document.getElementById("edittext").style.visibility = "hidden";
document.getElementById("calculate").innerText = "Transpose";
document.getElementById("input").focus();
document.getElementById("input").style.color = fontcolor;
document.getElementById("output").style.color = "grey";
bigTextarea = 0;
}
function showOutput() {
document.getElementById("input").style.visibility = "hidden";
document.getElementById("output").style.visibility = "initial";
document.getElementById("calculate").innerText = "🠄 Back to edit";
document.getElementById("edittext").style.visibility = "initial";
document.getElementById("edittext").style.visibility = "initial";
document.getElementById("output").style.color = fontcolor;
document.getElementById("input").style.color = "grey";
bigTextarea = 1;
}
function showNotes() {
document.getElementById("startChord").style.visibility = "initial";
document.getElementById("endChord").style.visibility = "initial";
document.getElementById("sTonesSelector").style.visibility = "hidden";
}
function showTones() {
document.getElementById("startChord").style.visibility = "hidden";
document.getElementById("endChord").style.visibility = "hidden";
document.getElementById("sTonesSelector").style.visibility = "initial";
}
if (navigator.serviceWorker.controller) {
console.log("Active service worker found");
} else {
navigator.serviceWorker
.register("serviceWorker.js", {
scope: "./"
})
.then(function (reg) {
console.log("Service worker registered");
});
}