|
24 | 24 | }); |
25 | 25 |
|
26 | 26 | function changePattern(element) { |
27 | | - console.log("Pattern changed", element.value); |
28 | 27 | let patternType = element.value; |
29 | 28 | const files = document.getElementsByName("tree-line"); |
30 | 29 |
|
|
60 | 59 | if (element.checked) { |
61 | 60 | sliderContainer.classList.add('hidden'); |
62 | 61 | manualSizeInput.classList.remove('hidden'); |
63 | | -
|
64 | | - if (!manualSizeValueInput.value || manualSizeValueInput.value.trim() === '') { |
65 | | - manualSizeValueInput.value = "1024"; |
| 62 | + const sizeUnit = sizeUnitInput.value; |
| 63 | + const maxValue = sizeUnit === 'kb' ? 100 * 1024 : 100; |
| 64 | + manualSizeValueInput.max = maxValue; |
| 65 | + if (parseInt(manualSizeValueInput.value) > maxValue) { |
| 66 | + manualSizeValueInput.value = maxValue; |
66 | 67 | } |
67 | 68 | hiddenSizeInput.value = manualSizeValueInput.value || "1024"; |
68 | 69 | } else { |
|
72 | 73 | const sliderValue = document.getElementById('file_size').value; |
73 | 74 | hiddenSizeInput.value = sliderValue; |
74 | 75 | } |
75 | | -
|
76 | | - console.log("Use manual input: " + hiddenInput.value); |
77 | | - console.log("Manual size value: " + hiddenSizeInput.value); |
78 | 76 | } |
79 | 77 |
|
80 | 78 | function updateManualSizeValue(element) { |
81 | 79 | const hiddenSizeInput = document.getElementById('max_file_size_manual'); |
82 | 80 | hiddenSizeInput.value = element.value || "1024"; |
83 | | - console.log("Manual size updated to: " + hiddenSizeInput.value + "KB"); |
84 | 81 | } |
85 | 82 |
|
86 | 83 | function updateSizeUnit(element) { |
|
90 | 87 | const sizeUnit = element.value; |
91 | 88 | const currentValue = parseInt(manualSizeValueInput.value); |
92 | 89 |
|
93 | | - // Update the hidden size unit input |
94 | 90 | hiddenSizeUnitInput.value = sizeUnit; |
95 | 91 |
|
96 | | - // Update the max attribute of the manual size input |
97 | 92 | const maxValue = sizeUnit === 'kb' ? 100 * 1024 : 100; |
98 | 93 | manualSizeValueInput.max = maxValue; |
99 | 94 |
|
100 | | - // If switching to MB and current value is over 100, set it to 100 |
101 | 95 | if (sizeUnit === 'mb' && currentValue > 100) { |
102 | 96 | manualSizeValueInput.value = 100; |
103 | | - // Also update the hidden input |
104 | 97 | hiddenSizeInput.value = 100; |
105 | 98 | } |
106 | 99 |
|
107 | 100 | console.log("Size unit changed to: " + sizeUnit.toUpperCase()); |
108 | 101 | } |
109 | 102 |
|
110 | | - // Add input validation to prevent values over max |
111 | 103 | document.getElementById('max_file_size_manual_input').addEventListener('input', function() { |
112 | 104 | const maxValue = parseInt(this.max); |
113 | 105 | const currentValue = parseInt(this.value); |
|
0 commit comments