53 lines
1.5 KiB
JavaScript
Executable File
53 lines
1.5 KiB
JavaScript
Executable File
let currentShimeji = null;
|
||
function initShimeji() {
|
||
currentShimeji = new Shimeji("/static/Shimeji");
|
||
}
|
||
|
||
function initKonamiCode(_fct) {
|
||
let code = [];
|
||
let konamiCode = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65];
|
||
let timeout;
|
||
document.body.addEventListener("keydown", function (e) {
|
||
clearTimeout(timeout);
|
||
e = e || window.event;
|
||
if (e.keyCode === konamiCode[code.length])
|
||
code.push(e.keyCode);
|
||
else
|
||
code = [];
|
||
if (code.length === konamiCode.length) _fct();
|
||
if (code.length <= 1) {
|
||
timeout = setTimeout(function () {
|
||
code = [];
|
||
}, 2000)
|
||
}
|
||
});
|
||
}
|
||
|
||
initKonamiCode(initShimeji);
|
||
|
||
console.log("LibKonamiCode from sorlinv is loaded");
|
||
|
||
function startaudio() {
|
||
let frequency = [32.703, 36.708, 41.203, 43.654, 48.999, 55.000, 61.735, 65.406, 73.416, 82.407, 87.307, 97.999, 110, 123.47, 130.81, 146.83, 164.81, 174.61, 196, 220, 246.94, 261.6, 293.67, 329.63, 349.23, 392, 440, 493.88, 523.25, 587.33, 659.26, 698.46];
|
||
fetch('songs/hakunamatata/Jean-Philippe Puymartin & Michel Elias (Le Roi Lion) - Hakuna Matata.txt')
|
||
.then(function(response) {
|
||
return response.text();
|
||
})
|
||
.then(function(text) {
|
||
let lines = text.split("\n");
|
||
for (let line of lines) {
|
||
let array = line.split(" ");
|
||
if(array[0] == ":" || array[0] == "F" || array[0] == "*") {
|
||
setTimeout(()=>{
|
||
// console.log(parseInt(array[3]));
|
||
let note = Pts.Sound.generate( "square", frequency[parseInt(array[3])]);
|
||
note.start();
|
||
setTimeout(()=>{
|
||
note.stop();
|
||
}, array[2] * 60);
|
||
}, array[1] * 60);
|
||
}
|
||
}
|
||
});
|
||
}
|