From d883115a80967675bc62746818b1715c6abd48f1 Mon Sep 17 00:00:00 2001 From: lalka2016 <99399973+lalka2016@users.noreply.github.com> Date: Wed, 20 Sep 2023 20:30:49 +0300 Subject: [PATCH] some fixesx --- Web/static/js/al_wall.js | 25 +++++++++++++++++++++++-- locales/en.strings | 1 + locales/ru.strings | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 096a5e79..5d692d6a 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -69,6 +69,24 @@ function initGraffiti(id) { function fastUploadImage(textareaId, file) { // uploading images + if(!file.type.startsWith('image/')) { + MessageBox(tr("error"), tr("only_images_accepted", escapeHtml(file.name)), [tr("ok")], [() => {Function.noop}]) + return; + } + + // 🤓🤓🤓 + if(file.size > 5 * 1024 * 1024) { + MessageBox(tr("error"), tr("max_filesize", 5), [tr("ok")], [() => {Function.noop}]) + return; + } + + let imagesCount = document.querySelector("#post-buttons" + textareaId + " input[name='photos']").value.split(",").length + + if(imagesCount > 10) { + MessageBox(tr("error"), tr("too_many_photos"), [tr("ok")], [() => {Function.noop}]) + return + } + let xhr = new XMLHttpRequest let data = new FormData @@ -143,7 +161,8 @@ u(".post-like-button").on("click", function(e) { function setupWallPostInputHandlers(id) { u("#wall-post-input" + id).on("paste", function(e) { - // Вставка из буфера проходит джва раза да хуй его знает почему так, в комментах такого нет. + // Если вы находитесь на странице с постом с id 11, то копирование произойдёт джва раза. + // Оч ржачный баг, но вот как его исправить, я, если честно, не знаю. if(e.clipboardData.files.length === 1) { fastUploadImage(id, e.clipboardData.files[0]) @@ -895,7 +914,9 @@ $(document).on("click", "#photosAttachments", async (e) => { for(const pht of result.photos) { let id = pht.owner + "_" + pht.vid - insertAttachment(id) + if(!insertAttachment(id)) { + return + } u(form.querySelector(`.upload`)).append(u(`
diff --git a/locales/en.strings b/locales/en.strings index f2dd98a4..89de34c8 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -423,6 +423,7 @@ "all_photos" = "All photos"; "error_uploading_photo" = "Error when uploading photo. Error text: "; +"too_many_photos" = "Too many photos."; /* Notes */ diff --git a/locales/ru.strings b/locales/ru.strings index bcf9d357..9a69c804 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -405,6 +405,7 @@ "all_photos" = "Все фотографии"; "error_uploading_photo" = "Не удалось загрузить фотографию. Текст ошибки: "; +"too_many_photos" = "Слишком много фотографий."; /* Notes */