forked from rDrama/rDrama
give user an error in the UI if they try to submit more than 4 files
parent
466867afd1
commit
55eabc0871
|
@ -297,7 +297,13 @@ function escapeHTML(unsafe) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function changename(s1,s2) {
|
function changename(s1,s2) {
|
||||||
let files = document.getElementById(s2).files;
|
const files = document.getElementById(s2).files;
|
||||||
|
if (files.length > 4)
|
||||||
|
{
|
||||||
|
alert("You can't upload more than 4 files at one time!")
|
||||||
|
document.getElementById(s2).files = null
|
||||||
|
return
|
||||||
|
}
|
||||||
let filename = '';
|
let filename = '';
|
||||||
for (const e of files) {
|
for (const e of files) {
|
||||||
filename += e.name.substr(0, 20) + ', ';
|
filename += e.name.substr(0, 20) + ', ';
|
||||||
|
|
|
@ -283,10 +283,17 @@ function post_comment(fullname, hide){
|
||||||
|
|
||||||
document.onpaste = function(event) {
|
document.onpaste = function(event) {
|
||||||
var focused = document.activeElement;
|
var focused = document.activeElement;
|
||||||
if (focused.id.includes('reply-form-body-')) {
|
const files = event.clipboardData.files
|
||||||
files = event.clipboardData.files
|
|
||||||
if (files.length)
|
if (files.length > 4)
|
||||||
{
|
{
|
||||||
|
alert("You can't upload more than 4 files at one time!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!files.length) return
|
||||||
|
|
||||||
|
if (focused.id.includes('reply-form-body-')) {
|
||||||
var fullname = focused.dataset.fullname;
|
var fullname = focused.dataset.fullname;
|
||||||
f=document.getElementById('file-upload-reply-' + fullname);
|
f=document.getElementById('file-upload-reply-' + fullname);
|
||||||
try {
|
try {
|
||||||
|
@ -299,11 +306,7 @@ document.onpaste = function(event) {
|
||||||
}
|
}
|
||||||
catch(e) {}
|
catch(e) {}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (focused.id.includes('comment-edit-body-')) {
|
else if (focused.id.includes('comment-edit-body-')) {
|
||||||
files = event.clipboardData.files
|
|
||||||
if (files.length)
|
|
||||||
{
|
|
||||||
var id = focused.dataset.id;
|
var id = focused.dataset.id;
|
||||||
f=document.getElementById('file-edit-reply-' + id);
|
f=document.getElementById('file-edit-reply-' + id);
|
||||||
let filename = ''
|
let filename = ''
|
||||||
|
@ -313,11 +316,7 @@ document.onpaste = function(event) {
|
||||||
f.files = files;
|
f.files = files;
|
||||||
document.getElementById('filename-edit-reply-' + id).textContent = filename;
|
document.getElementById('filename-edit-reply-' + id).textContent = filename;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (focused.id.includes('post-edit-box-')) {
|
else if (focused.id.includes('post-edit-box-')) {
|
||||||
files = event.clipboardData.files
|
|
||||||
if (files.length)
|
|
||||||
{
|
|
||||||
var id = focused.dataset.id;
|
var id = focused.dataset.id;
|
||||||
f=document.getElementById('file-upload-edit-' + id);
|
f=document.getElementById('file-upload-edit-' + id);
|
||||||
let filename = ''
|
let filename = ''
|
||||||
|
@ -328,7 +327,6 @@ document.onpaste = function(event) {
|
||||||
document.getElementById('filename-show-edit-' + id).textContent = filename;
|
document.getElementById('filename-show-edit-' + id).textContent = filename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function handle_action(type, cid, thing) {
|
function handle_action(type, cid, thing) {
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,14 @@ function updatebgselection(){
|
||||||
document.onpaste = function(event) {
|
document.onpaste = function(event) {
|
||||||
var focused = document.activeElement;
|
var focused = document.activeElement;
|
||||||
if (focused.id == 'bio-text') {
|
if (focused.id == 'bio-text') {
|
||||||
files = event.clipboardData.files
|
const files = event.clipboardData.files
|
||||||
|
|
||||||
|
if (files.length > 4)
|
||||||
|
{
|
||||||
|
alert("You can't upload more than 4 files at one time!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (files.length)
|
if (files.length)
|
||||||
{
|
{
|
||||||
f=document.getElementById('file-upload');
|
f=document.getElementById('file-upload');
|
||||||
|
|
|
@ -55,6 +55,12 @@ function hide_image() {
|
||||||
document.onpaste = function(event) {
|
document.onpaste = function(event) {
|
||||||
files = event.clipboardData.files
|
files = event.clipboardData.files
|
||||||
|
|
||||||
|
if (files.length > 4)
|
||||||
|
{
|
||||||
|
alert("You can't upload more than 4 files at one time!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
filename = files[0]
|
filename = files[0]
|
||||||
|
|
||||||
if (filename)
|
if (filename)
|
||||||
|
|
Loading…
Reference in New Issue