Skip to content
Snippets Groups Projects
Commit cc7ebd2d authored by me5na7qbjqbrp's avatar me5na7qbjqbrp
Browse files

Sometimes the nk20 is too laggy

parent fed95675
No related branches found
No related tags found
1 merge request!107Beta
Pipeline #8609 failed with stages
in 7 minutes and 33 seconds
/*
* Konami code support
*/
// Cursor denote the position in konami code
let cursor = 0
const KONAMI_CODE = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65]
function afterKonami() {
// Load Rythm.js
var rythmScript = document.createElement('script')
rythmScript.setAttribute('src','https://unpkg.com/rythm.js@2.2.5/rythm.min.js')
document.head.appendChild(rythmScript)
rythmScript.addEventListener('load', function() {
// This media source need to be accessible with a cross-origin header
const audioElement = new Audio('https://okazari.github.io/Rythm.js/samples/rythmC.mp3')
audioElement.crossOrigin = 'anonymous'
audioElement.play();
const rythm = new Rythm()
rythm.connectExternalAudioElement(audioElement)
rythm.addRythm('card', 'pulse', 0, 10)
rythm.addRythm('nav-link', 'color', 0, 10, {
from: [0,0,255],
to:[255,0,255]
})
rythm.start()
});
}
// Register custom event
document.addEventListener('keydown', (e) => {
cursor = (e.keyCode == KONAMI_CODE[cursor]) ? cursor + 1 : 0;
if (cursor == KONAMI_CODE.length) {
afterKonami()
}
});
...@@ -35,6 +35,7 @@ SPDX-License-Identifier: GPL-3.0-or-later ...@@ -35,6 +35,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<script src="https://cdnjs.cloudflare.com/ajax/libs/turbolinks/5.2.0/turbolinks.js" <script src="https://cdnjs.cloudflare.com/ajax/libs/turbolinks/5.2.0/turbolinks.js"
crossorigin="anonymous"></script> crossorigin="anonymous"></script>
<script src="{% static "js/base.js" %}"></script> <script src="{% static "js/base.js" %}"></script>
<script src="{% static "js/konami.js" %}"></script>
{# Si un formulaire requiert des données supplémentaires (notamment JS), les données sont chargées #} {# Si un formulaire requiert des données supplémentaires (notamment JS), les données sont chargées #}
{% if form.media %} {% if form.media %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment