'use strict'; /* ===================================== БЕЗ ЗВУКА: hover + клавиши = bounce (всё аудио удалено) ===================================== */ // --- Bounce-эффект (как в оригинале) --- function ballBounce(el) { if (!el) return; if (String(el.className).indexOf(" bounce") > -1) return; toggleBounce(el); } function toggleBounce(i) { i.classList.add("bounce"); function n() { i.classList.remove("bounce"); i.classList.add("bounce1"); function o() { i.classList.remove("bounce1"); i.classList.add("bounce2"); function p() { i.classList.remove("bounce2"); i.classList.add("bounce3"); function q() { i.classList.remove("bounce3"); } setTimeout(q, 300); } setTimeout(p, 300); } setTimeout(o, 300); } setTimeout(n, 300); } // --- Hover: подпрыгивание шарика --- var array1 = document.querySelectorAll('.b-ball_bounce'); var array2 = document.querySelectorAll('.b-ball_bounce .b-ball__right'); for (var i = 0; i < array1.length; i++) { array1[i].addEventListener('mouseenter', function () { ballBounce(this); }); } for (var j = 0; j < array2.length; j++) { array2[j].addEventListener('mouseenter', function () { ballBounce(this); }); } // --- Клавиши: карта (как в оригинале), но без звука --- var l = ["49", "50", "51", "52", "53", "54", "55", "56", "57", "48", "189", "187", "81", "87", "69", "82", "84", "89", "85", "73", "79", "80", "219", "221", "65", "83", "68", "70", "71", "72", "74", "75", "76", "186", "222", "220"]; var k = ["90", "88", "67", "86", "66", "78", "77", "188", "190", "191"]; var a = {}; // 1..0, -, =, QWERTY..., [ ], ASDF..., ; ' \ -> индексы 0..35 for (var e = 0, c = l.length; e < c; e++) a[l[e]] = e; // Z X C V B N M , . / -> индексы 0..9 (повторяет первые 10 шаров, как в оригинале) for (var e2 = 0, c2 = k.length; e2 < c2; e2++) a[k[e2]] = e2; document.addEventListener('keydown', function (j) { // чтобы не мешать вводу в полях var t = j.target; var tag = t && t.tagName ? t.tagName.toLowerCase() : ''; if (tag === 'input' || tag === 'textarea' || t.isContentEditable) return; if (j.which in a) { var index = parseInt(a[j.which], 10); // ищем шар по data-note и запускаем bounce var ball = document.querySelector('[data-note="' + index + '"]'); if (ball) toggleBounce(ball); } });