diff --git a/api/v1/methods/edit-item.js b/api/v1/methods/edit-item.js index 3790da5..7599fb0 100644 --- a/api/v1/methods/edit-item.js +++ b/api/v1/methods/edit-item.js @@ -32,7 +32,7 @@ async function checkSyntaxArgs(req, res) { (req.json.author_id === undefined ? true : await isAuthorExists(req.json.author_id)) && // Проверка поля data. (Передаётся либо ничего, либо строка с base64) - (req.json.data === undefined ? true : typeof req.json.data === "string") + ((req.json.data === undefined || req.json.data === null) ? true : typeof req.json.data === "string") : true) ); } @@ -77,7 +77,7 @@ module.exports = async (req, res) => { { name: req.json.name, author_id: req.json.author_id, - data: !req.json.data ? undefined : Buffer.from(req.json.data, "base64"), + data: !req.json.data ? (req.json.data === null ? null : undefined) : Buffer.from(req.json.data, "base64"), }, { where: { diff --git a/api/v1/methods/get-muzic.js b/api/v1/methods/get-muzic.js index 43a9998..e1ad971 100644 --- a/api/v1/methods/get-muzic.js +++ b/api/v1/methods/get-muzic.js @@ -96,7 +96,7 @@ module.exports = async (req, res) => { id: i.id, name: i.name, author_id: i.author_id, - is_data_exists: i.data !== null, + is_data_exists: i.data !== null && i.data.length > 0, date: i.time, })); // Если просят выборку по authors diff --git a/frontend/public/js/main.js b/frontend/public/js/main.js index 7c71cf6..6a8312d 100644 --- a/frontend/public/js/main.js +++ b/frontend/public/js/main.js @@ -55,7 +55,11 @@ function showAudio(settingsAuthors, settingsAudio) { }" disabled>Пауза + }" name="stop" min="0" max="0" value="0" step="0.01" style="width: 70%;"> +

+

`; else document.getElementById( @@ -100,7 +104,7 @@ function showAudio(settingsAuthors, settingsAudio) { `add-muzic-${author.id}`, ).innerHTML = `

- +

`; setTimeout(() => { document.getElementById( @@ -112,7 +116,7 @@ function showAudio(settingsAuthors, settingsAudio) { addMuzicButtonFunct(); }; - document.getElementById(`add-muzic-${author.id}`).onclick = + document.getElementById(`add-muzic-act-${author.id}`).onclick = function () { if ( document.getElementById(`muzic-name-input-${author.id}`) diff --git a/frontend/public/js/menu.js b/frontend/public/js/menu.js index e8df185..dd8735b 100644 --- a/frontend/public/js/menu.js +++ b/frontend/public/js/menu.js @@ -160,7 +160,7 @@ function bindShowEditMuzicButtons(muzicId, muzicName, dataExists) { document.getElementById(`delete-attach-${muzicId}`).disabled = true; }; document.getElementById(`edit-muzic-${muzicId}`).onclick = () => - editMuzic(muzicId, muzicName); + editMuzic(muzicId, document.getElementById(`muzic-edit-name-input-${muzicId}`).value); document.getElementById(`delete-muzic-${muzicId}`).onclick = () => removeMuzic(muzicId); } diff --git a/frontend/public/js/sound.js b/frontend/public/js/sound.js index 7aa70db..b6b60be 100644 --- a/frontend/public/js/sound.js +++ b/frontend/public/js/sound.js @@ -45,6 +45,10 @@ function playMuzic(id) { const interval = setInterval(() => { document.getElementById(`road-${id}`).value = audio.currentTime; + if (audio.currentTime >= audio.duration && document.getElementById(`repeat-mode-${id}`).checked) { + audio.currentTime = 0; + audio.play(); + } }, 750); audio.muzTimer = interval; document.getElementById(`play-${id}`).onclick = () =>