some fixesx

This commit is contained in:
lalka2016 2023-09-20 20:30:49 +03:00
parent 638d6f9879
commit d883115a80
3 changed files with 25 additions and 2 deletions

View file

@ -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(`
<div class="upload-item" id="aP" data-id="${pht.owner + "_" + pht.vid}">

View file

@ -423,6 +423,7 @@
"all_photos" = "All photos";
"error_uploading_photo" = "Error when uploading photo. Error text: ";
"too_many_photos" = "Too many photos.";
/* Notes */

View file

@ -405,6 +405,7 @@
"all_photos" = "Все фотографии";
"error_uploading_photo" = "Не удалось загрузить фотографию. Текст ошибки: ";
"too_many_photos" = "Слишком много фотографий.";
/* Notes */