All CSS used are prefixed with afus-, uuid v4 for each upload group

Set uuid v4 for each upload group as ".uploadQueueUid"
Add max upload files as ".uploadQueueMax"
Change to upload files to ".uploadQueueOpen" (from ".uploadQueueMax")

Extract retrun message from two types for messages that could come
from the server
This commit is contained in:
2024-09-17 15:50:39 +09:00
parent 960d396aae
commit c53eea0b42
5 changed files with 86 additions and 4 deletions

View File

@@ -243,6 +243,7 @@ if (isset($_POST['action'])) {
$ajax_data = [
'msg' => [],
'file_uid' => null,
'file_crc' => null,
'file_url' => null,
'file_name' => null,
'file_size' => null,
@@ -263,6 +264,7 @@ if (isset($_POST['action'])) {
if ($status == 'success') {
// basic file id data
$file_uid = null;
$file_crc = null;
$file_url = null;
$file_name = null;
$file_size = null;
@@ -279,6 +281,7 @@ if (isset($_POST['action'])) {
$file_name = $_FILES[$upload_name]['name'];
$file_size = humanReadableByteFormat($_FILES[$upload_name]['size']);
$file_size_raw = $_FILES[$upload_name]['size'];
$file_crc = hash('sha256', file_get_contents($folder . $file_uid) ?: '');
// correct the image rotation
// $this->correctImageOrientation(BASE.TMP.$file_uid);
// make a copy to layout/cache/images for file url
@@ -289,6 +292,7 @@ if (isset($_POST['action'])) {
$ajax_data = [
'msg' => $file_upload_message,
'file_uid' => $file_uid,
'file_crc' => $file_crc,
'file_url' => $file_url,
'file_name' => $file_name,
'file_size' => $file_size,

View File

@@ -45,6 +45,28 @@ CSS Other
.uploaded { margin-top: 20px; }
.title { font-size: 1.5em; font-weight: bold; margin-bottom: 10px; }
.afus-status-delete {
color: orange;
font-weight: bold;
}
.afus-status-progress {
color: rgb(37, 140, 191);
}
.afus-status-progress-bar {
height: 10px;
}
.afus-status-progress-bar::slider-fill {
background-color: orange;
}
.afus-status-abort {
color: red;
}
.afus-status-error {
color: red;
font-weight: bold;
font-size: 1.2em;
}
.file-upload label div {
text-align: center;
color: #e60012;

View File

@@ -93,6 +93,16 @@ function ajaxWrapper(call_id, queryString = {}, control = {}, url = 'backend.php
});
}
/**
* uuid4 creator
* @returns {String} uuid4
*/
function uuidv4() {
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
(+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)
);
}
/**
* FILE CHANGE:
* helper call for ajax file upload on file selected
@@ -331,6 +341,9 @@ $(document).ready(function () {
form_parameters: {'parameter_a': 'Value 123'},
auto_submit: false,
function_options: {action_box_id: 'actionBox-alt', 'other': 'free'},
translation: {
remove: "REMOVE"
},
fileChange: fileChangeFunction,
fileChangeAll: fileChangeFunctionAll,
fileRemove: fileRemoveFunction,