Fix bugs and add new elements

This commit is contained in:
Nikiroy78 2023-10-02 21:58:55 +03:00
parent 2bcef6fbae
commit 725f91ea8c
5 changed files with 15 additions and 7 deletions

View File

@ -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: {

View File

@ -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

View File

@ -55,7 +55,11 @@ function showAudio(settingsAuthors, settingsAudio) {
}" disabled>Пауза</button>
<input class="road-muzic" type="range" id="road-${
muzic.id
}" name="stop" min="0" max="0" value="0" step="0.01" style="width: 70%;"/>
}" name="stop" min="0" max="0" value="0" step="0.01" style="width: 70%;"></label>
<p style="margin-top: 7px;"><input type="checkbox" class="form-check-input" id="repeat-mode-${
muzic.id
}">
<label class="form-check-label" for="exampleCheck1">Повторять</label></p>
</div></p>`;
else
document.getElementById(
@ -100,7 +104,7 @@ function showAudio(settingsAuthors, settingsAudio) {
`add-muzic-${author.id}`,
).innerHTML = `<p><input class="form-control" type="text" placeholder="Введите название произведения" id="muzic-name-input-${author.id}" style="width: 90%"></p>
<p><button class="btn btn-primary" id="attach-file-${author.id}">Добавить файл (.mp3)</button>
<button class="btn btn-primary" id="add-muzic-${author.id}">Добавить произведение</button>
<button class="btn btn-primary" id="add-muzic-act-${author.id}">Добавить произведение</button>
<button class="btn btn-danger" id="cancel-add-muzic-${author.id}">Отменить</button></p>`;
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}`)

View File

@ -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);
}

View File

@ -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 = () =>