/
Dmitry-F
/
cbt_tool
Обзор
Документация
Войти
/
Dmitry-F
/
cbt_tool
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
python-ml-service
app/javascript/controllers/custom_player_controller.js
18 строк
650 B
Dmitriy-Filatov
feat: аудиорекордер с таймером в шапке формы + тесты
06 апр 2026, 23:29
06 апр 2026, 23:29
763e879
Код
Авторство
О чём код?
import { Controller } from "@hotwired/stimulus"; export default class extends Controller { static targets = ["audio", "speedBtn"]; toggleSpeed() { const speeds = [1, 1.5, 2]; let currentSpeed = this.audioTarget.playbackRate; let nextSpeed = speeds[(speeds.indexOf(currentSpeed) + 1) % speeds.length]; this.audioTarget.playbackRate = nextSpeed; this.speedBtnTarget.innerText = `${nextSpeed}x`; // Подсветим кнопку, если скорость не 1 this.speedBtnTarget.classList.toggle("bg-indigo-100", nextSpeed > 1); this.speedBtnTarget.classList.toggle("text-indigo-700", nextSpeed > 1); } }