-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.html
99 lines (98 loc) · 2.83 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Nokia Composer</title>
<style>
@font-face {
font-family: 'N';
src: url('N.ttf');
}
* {
margin: 0;
padding: 0;
font-family: 'N';
font-size: 5vmin;
border: 0;
outline: 0;
background: #7b8;
color: #333;
}
a {
font-weight: bold;
text-decoration: none;
}
body {
width: 15rem;
margin: 4rem auto;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
input[type=number] {
-moz-appearance: textfield;
}
</style>
</head>
<body>
<div style="display:flex;flex-direction:column;align-items:stretch;">
<div style="display:flex;margin-bottom:1rem;">
<label for="bpm">BPM:<input id="bpm" value="120" size="3" type="number" min="1" max="800" /></label>
<span style="flex:1"></span>
<a target="_blank" href="h/">?</a>
</div>
<div id="song" contenteditable="true" spellcheck="false"></div>
<a
id="btn"
style="margin:1rem;text-align:center;"
href="javascript:void(0)"
onclick="togglePlayback()"
>Play</a
>
</div>
<script>
// This is a little shim to make the composer a bit more usable
// Safari does not support AudioContext yet
window.AudioContext = window.AudioContext || window.webkitAudioContext;
// Load song from the URL
try {
const data = JSON.parse(atob(location.hash.slice(1)));
bpm.value = data.bpm;
song.innerText = data.song;
} catch (ignored) {
// Nokia ringtone, by default
bpm.value = '120';
song.innerText = `16e2 16d2 8#f 8#g 16#c2 16b 8d 8e 16b 16a 8#c 8e 2a 2-`;
}
// Toggle playback on Ctrl+Enter
song.onkeydown = e => {
if (e.ctrlKey && e.keyCode === 13) {
e.preventDefault();
togglePlayback();
}
};
// Auto-song to URI
(song.oninput = bpm.oninput = () => {
location.hash = btoa(
JSON.stringify({bpm: bpm.value, song: song.innerText}),
);
})();
// Play song or stop the playback
function togglePlayback() {
if (C) {
stop();
btn.innerText = 'Play';
} else {
btn.innerText = 'Stop';
play(song.innerText, c(bpm.value, 40, 400));
}
}
</script>
<script src="n.min.js"></script>
<script>new Image().src='https://nullitics.com/file.gif?u=nokia&r='+encodeURI(document.referrer)+'&d='+screen.width</script>
<noscript><img src=https://nullitics.com/file.gif></noscript>
</body>
</html>