Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
web-ui
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WEBGDE-Components
web-ui
Commits
d53b7153
Commit
d53b7153
authored
Oct 09, 2023
by
Owen Ryan Ang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
file picker code adjustment
parent
89892ed8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
24 deletions
+33
-24
generateFields.js
...bContent/WebGde-Widgets/DataInputWidget/generateFields.js
+33
-24
No files found.
WebGde/WebContent/WebGde-Widgets/DataInputWidget/generateFields.js
View file @
d53b7153
...
...
@@ -1163,6 +1163,7 @@ const inputFileUpload = (key, validation) => {
// Add an event listener to handle when a file is selected
input
.
addEventListener
(
'change'
,
(
event
)
=>
{
const
file
=
event
.
target
.
files
[
0
];
console
.
log
(
file
)
if
(
file
)
{
// Create hidden inputs for fname and file content
...
...
@@ -1256,30 +1257,38 @@ const inputFileUpload = (key, validation) => {
}
}
else
{
// Display the filename only for unsupported file types
filename
.
textContent
=
file
.
name
;
filename
.
style
.
display
=
'inline'
;
document
.
getElementById
(
`
${
key
}
_buttonsContainer-video`
).
style
.
display
=
'none'
;
x
.
style
.
display
=
'block'
;
x
.
style
.
position
=
'absolute'
;
// Set the hidden inputs for filename and empty file content
hiddenFnameInput
.
value
=
file
.
name
;
hiddenFnameInput
.
display
=
''
;
hiddenFileContentInput
.
value
=
''
;
// Empty content for unsupported file types
hiddenFileContentInput
.
display
=
''
;
// Remove the file on 'x' click
document
.
getElementById
(
`
${
key
}
_x`
).
addEventListener
(
'click'
,
()
=>
{
filename
.
style
.
display
=
'none'
;
document
.
getElementById
(
`
${
key
}
_buttonsContainer-video`
).
style
.
display
=
'flex'
;
input
.
value
=
''
;
x
.
style
.
display
=
'none'
;
// Clear the hidden fields
container2
.
removeChild
(
hiddenFnameInput
);
container2
.
removeChild
(
hiddenFileContentInput
);
});
const
reader
=
new
FileReader
();
reader
.
readAsDataURL
(
file
);
reader
.
onload
=
(
e
)
=>
{
// Display the filename only for unsupported file types
const
fileInput
=
document
.
getElementById
(
`
${
key
}
_attachedMedia`
);
const
fullPath
=
fileInput
.
value
;
console
.
log
(
fileInput
);
// const filename = fullPath.split('\\').pop().split('/').pop();
filename
.
textContent
=
fullPath
.
split
(
'
\
\'
).pop().split('
/
').pop();
filename.style.display = '
inline
';
document.getElementById(`${key}_buttonsContainer-video`).style.display = '
none
';
x.style.display = '
block
';
x.style.position = '
absolute
';
// Set the hidden inputs for filename and empty file content
hiddenFnameInput.value = fullPath.split('
\\
').pop().split('
/
').pop();
hiddenFnameInput.display = '';
hiddenFileContentInput.value = e.target.result;
hiddenFileContentInput.display = '';
// Remove the file on '
x
' click
document.getElementById(`${key}_x`).addEventListener('
click
', () => {
filename.style.display = '
none
';
document.getElementById(`${key}_buttonsContainer-video`).style.display = '
flex
';
input.value = '';
x.style.display = '
none
';
// Clear the hidden fields
container2.removeChild(hiddenFnameInput);
container2.removeChild(hiddenFileContentInput);
});
}
}
}
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment