Skip to content

Commit

Permalink
Fix fix fix languages
Browse files Browse the repository at this point in the history
  • Loading branch information
tiritibambix committed Jan 12, 2025
1 parent 4d14ab6 commit 7fa1c71
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
36 changes: 17 additions & 19 deletions templates/resize.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<html lang="{{ session.get('lang', 'en') }}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Resize Options</title>
<title>{{ _('Resize Options') }}</title>
<style>
:root {
--clr-primary-a0: #808080;
Expand Down Expand Up @@ -205,7 +205,7 @@ <h4>{{ _('Resize Image: %(filename)s', filename=filename) }}</h4>
</select>
</div>
{% if image_type %}
<div class="format-info">
<div class="image-info">
<small>
{% if image_type.has_transparency %}
{{ _('This image contains transparency.') }}
Expand All @@ -230,31 +230,29 @@ <h4>{{ _('Resize Image: %(filename)s', filename=filename) }}</h4>
const keepRatioCheckbox = document.getElementById('keep_ratio');

function syncDimensions(changedInput, otherInput, originalWidth, originalHeight) {
if (!keepRatioCheckbox.checked) return;

const value = parseInt(changedInput.value, 10);
if (!isNaN(value)) {
const ratio = (changedInput.id === 'width')
? originalHeight / originalWidth
: originalWidth / originalHeight;
otherInput.value = Math.round(value * ratio);
if (keepRatioCheckbox.checked && changedInput.value) {
const ratio = originalHeight / originalWidth;
const newValue = Math.round(
changedInput === widthInput
? changedInput.value * ratio
: changedInput.value / ratio
);
otherInput.value = newValue;
}
}

[widthInput, heightInput].forEach(input => {
input.addEventListener('input', () => {
const originalWidth = parseInt(widthInput.dataset.originalWidth, 10);
const originalHeight = parseInt(heightInput.dataset.originalHeight, 10);
syncDimensions(input, input === widthInput ? heightInput : widthInput, originalWidth, originalHeight);

if (input === widthInput) {
syncDimensions(widthInput, heightInput, originalWidth, originalHeight);
} else {
syncDimensions(heightInput, widthInput, originalWidth, originalHeight);
}
});
});

keepRatioCheckbox.addEventListener('change', () => {
if (!keepRatioCheckbox.checked) {
widthInput.value = '';
heightInput.value = '';
}
});
});
</script>
</body>
Expand Down
5 changes: 2 additions & 3 deletions templates/resize_batch.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="{{ session.get('lang', 'en') }}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Expand Down Expand Up @@ -141,7 +141,7 @@
<body>
<div class="container">
<h1>{{ _('Batch Resize') }}</h1>
<form action="/resize_batch" method="post">
<form action="{{ url_for_with_lang('resize_batch') }}" method="post">
<input type="hidden" name="filenames" value="{{ ','.join(files) }}">
<fieldset>
<legend>{{ _('Resize Options') }}</legend>
Expand Down Expand Up @@ -224,7 +224,6 @@ <h1>{{ _('Batch Resize') }}</h1>
</small>
</div>
{% endif %}

{% if image_types %}
<div class="images-info">
<small>
Expand Down

0 comments on commit 7fa1c71

Please sign in to comment.