mirror of
https://github.com/javl/image2cpp.git
synced 2026-07-27 19:56:07 +00:00
simplify allsamesize button
This commit is contained in:
+1
-1
@@ -71,7 +71,7 @@
|
|||||||
<ul id="image-size-settings"></ul>
|
<ul id="image-size-settings"></ul>
|
||||||
<div id="only-images-file-error" class="msg error-msg">Only images file type are allowed</div>
|
<div id="only-images-file-error" class="msg error-msg">Only images file type are allowed</div>
|
||||||
<div class="no-file-selected" class="msg">No files selected</div>
|
<div class="no-file-selected" class="msg">No files selected</div>
|
||||||
<button id="all-same-size">Apply first image size to all images</button>
|
<button id="all-same-size" onclick="allSameSize()">Apply first image size to all images</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
+17
-21
@@ -22,8 +22,6 @@ const settings = {
|
|||||||
rotation: 0,
|
rotation: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
let allSameSizeButton;
|
|
||||||
|
|
||||||
function bitswap(b) {
|
function bitswap(b) {
|
||||||
if (settings.bitswap) {
|
if (settings.bitswap) {
|
||||||
// eslint-disable-next-line no-bitwise, no-mixed-operators, no-param-reassign
|
// eslint-disable-next-line no-bitwise, no-mixed-operators, no-param-reassign
|
||||||
@@ -695,25 +693,21 @@ function handleTextInput(drawMode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function allSameSize(_images, files) {
|
// eslint-disable-next-line no-unused-vars
|
||||||
if (_images.length() > 1 && _images.length() === files.length) {
|
function allSameSize() {
|
||||||
// multiple images settings container
|
if (images.length() > 1) {
|
||||||
// var imageSizeSettings = document.getElementById("image-size-settings");
|
|
||||||
const inputs = document.querySelectorAll('#image-size-settings input');
|
const inputs = document.querySelectorAll('#image-size-settings input');
|
||||||
// all images same size button
|
// all images same size button
|
||||||
allSameSizeButton.onclick = () => {
|
for (let i = 2; i < inputs.length; i++) {
|
||||||
for (let i = 2; i < inputs.length; i++) {
|
if (inputs[i].name === 'width') {
|
||||||
if (inputs[i].name === 'width') {
|
inputs[i].value = inputs[0].value;
|
||||||
inputs[i].value = inputs[0].value;
|
inputs[i].oninput();
|
||||||
inputs[i].oninput();
|
|
||||||
}
|
|
||||||
if (inputs[i].name === 'height') {
|
|
||||||
inputs[i].value = inputs[1].value;
|
|
||||||
inputs[i].oninput();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
if (inputs[i].name === 'height') {
|
||||||
allSameSizeButton.style.display = 'block';
|
inputs[i].value = inputs[1].value;
|
||||||
|
inputs[i].oninput();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -833,7 +827,7 @@ function handleImageSelection(evt) {
|
|||||||
imageSizeSettings.removeChild(imageEntry);
|
imageSizeSettings.removeChild(imageEntry);
|
||||||
|
|
||||||
fileInputColumn.removeChild(fileInputColumnEntry);
|
fileInputColumn.removeChild(fileInputColumnEntry);
|
||||||
if (imageSizeSettings.children.length === 1) {
|
if (imageSizeSettings.children.length <= 1) {
|
||||||
document.getElementById('all-same-size').style.display = 'none';
|
document.getElementById('all-same-size').style.display = 'none';
|
||||||
}
|
}
|
||||||
if (images.length() === 0) {
|
if (images.length() === 0) {
|
||||||
@@ -867,8 +861,11 @@ function handleImageSelection(evt) {
|
|||||||
canvasContainer.appendChild(canvas);
|
canvasContainer.appendChild(canvas);
|
||||||
|
|
||||||
images.push(img, canvas, file.name.split('.')[0]);
|
images.push(img, canvas, file.name.split('.')[0]);
|
||||||
|
if (images.length() > 1) {
|
||||||
|
document.getElementById('all-same-size').style.display = 'block';
|
||||||
|
}
|
||||||
placeImage(images.last());
|
placeImage(images.last());
|
||||||
allSameSize(images, files);
|
// allSameSize(images, files);
|
||||||
};
|
};
|
||||||
img.src = file.target.result;
|
img.src = file.target.result;
|
||||||
};
|
};
|
||||||
@@ -1121,7 +1118,6 @@ function updateRadio(fieldName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.onload = () => {
|
window.onload = () => {
|
||||||
allSameSizeButton = document.getElementById('all-same-size');
|
|
||||||
document.getElementById('copy-button').disabled = true;
|
document.getElementById('copy-button').disabled = true;
|
||||||
|
|
||||||
// Add events to the file input button
|
// Add events to the file input button
|
||||||
|
|||||||
Reference in New Issue
Block a user