mirror of
https://github.com/javl/image2cpp.git
synced 2026-07-27 19:56:07 +00:00
Merge pull request #48 from harry48225/uploaded-image-list
Add list of uploaded files in select image section
This commit is contained in:
+28
-2
@@ -137,6 +137,12 @@
|
|||||||
margin: 3px 0;
|
margin: 3px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.file-input-entry {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
button,
|
button,
|
||||||
input[type="file"] {
|
input[type="file"] {
|
||||||
background: #00CB99;
|
background: #00CB99;
|
||||||
@@ -233,7 +239,7 @@
|
|||||||
|
|
||||||
<section class="section bottom-divider">
|
<section class="section bottom-divider">
|
||||||
<section class="sub-section">
|
<section class="sub-section">
|
||||||
<div class="column">
|
<div class="column" id="file-input-column">
|
||||||
<h2 class="sub-section-title">1. Select image</h2>
|
<h2 class="sub-section-title">1. Select image</h2>
|
||||||
<input type="file" id="file-input" name="file-input" multiple/><br />
|
<input type="file" id="file-input" name="file-input" multiple/><br />
|
||||||
</div>
|
</div>
|
||||||
@@ -653,6 +659,8 @@
|
|||||||
fileInput.addEventListener("click", function(){this.value = null;}, false);
|
fileInput.addEventListener("click", function(){this.value = null;}, false);
|
||||||
fileInput.addEventListener("change", handleImageSelection, false);
|
fileInput.addEventListener("change", handleImageSelection, false);
|
||||||
|
|
||||||
|
var fileInputColumn = document.getElementById("file-input-column");
|
||||||
|
|
||||||
// Filetypes accepted by the file picker
|
// Filetypes accepted by the file picker
|
||||||
var fileTypes = ["jpg", "jpeg", "png", "bmp", "gif", "svg"];
|
var fileTypes = ["jpg", "jpeg", "png", "bmp", "gif", "svg"];
|
||||||
|
|
||||||
@@ -962,7 +970,16 @@
|
|||||||
var img = new Image();
|
var img = new Image();
|
||||||
|
|
||||||
img.onload = function(){
|
img.onload = function(){
|
||||||
|
const fileInputColumnEntry = document.createElement("div");
|
||||||
|
fileInputColumnEntry.className = "file-input-entry";
|
||||||
|
|
||||||
|
const fileInputColumnEntryLabel = document.createElement("span");
|
||||||
|
fileInputColumnEntryLabel.textContent = file.name;
|
||||||
|
|
||||||
|
const fileInputColumnEntryRemoveButton = document.createElement("button");
|
||||||
|
fileInputColumnEntryRemoveButton.className = "remove-button";
|
||||||
|
fileInputColumnEntryRemoveButton.innerHTML = "remove";
|
||||||
|
|
||||||
var canvas = document.createElement("canvas");
|
var canvas = document.createElement("canvas");
|
||||||
|
|
||||||
var imageEntry = document.createElement("li");
|
var imageEntry = document.createElement("li");
|
||||||
@@ -1009,11 +1026,13 @@
|
|||||||
var rb = document.createElement("button");
|
var rb = document.createElement("button");
|
||||||
rb.className = "remove-button";
|
rb.className = "remove-button";
|
||||||
rb.innerHTML = "remove";
|
rb.innerHTML = "remove";
|
||||||
rb.onclick = function() {
|
|
||||||
|
const removeButtonOnClick = function() {
|
||||||
var image = images.get(img);
|
var image = images.get(img);
|
||||||
canvasContainer.removeChild(image.canvas);
|
canvasContainer.removeChild(image.canvas);
|
||||||
images.remove(image);
|
images.remove(image);
|
||||||
imageSizeSettings.removeChild(imageEntry);
|
imageSizeSettings.removeChild(imageEntry);
|
||||||
|
fileInputColumn.removeChild(fileInputColumnEntry);
|
||||||
if(imageSizeSettings.children.length == 1) {
|
if(imageSizeSettings.children.length == 1) {
|
||||||
allSameSizeButton.style.display = "none";
|
allSameSizeButton.style.display = "none";
|
||||||
}
|
}
|
||||||
@@ -1021,6 +1040,13 @@
|
|||||||
update();
|
update();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
rb.onclick = removeButtonOnClick;
|
||||||
|
fileInputColumnEntryRemoveButton.onclick = removeButtonOnClick;
|
||||||
|
|
||||||
|
fileInputColumnEntry.appendChild(fileInputColumnEntryLabel);
|
||||||
|
fileInputColumnEntry.appendChild(fileInputColumnEntryRemoveButton);
|
||||||
|
fileInputColumn.appendChild(fileInputColumnEntry);
|
||||||
|
|
||||||
imageEntry.appendChild(fn);
|
imageEntry.appendChild(fn);
|
||||||
imageEntry.appendChild(w);
|
imageEntry.appendChild(w);
|
||||||
imageEntry.appendChild(document.createTextNode(" x "));
|
imageEntry.appendChild(document.createTextNode(" x "));
|
||||||
|
|||||||
Reference in New Issue
Block a user