(bytes)
| 12177 | } |
| 12178 | |
| 12179 | function formatBytes(bytes) { |
| 12180 | if (bytes === null || typeof bytes === "undefined" || isNaN(bytes) || bytes < 0) return ""; |
| 12181 | const units = ["B", "KB", "MB", "GB", "TB"]; |
| 12182 | let size = bytes; |
| 12183 | let unitIndex = 0; |
| 12184 | while (size >= 1024 && unitIndex < units.length - 1) { |
| 12185 | size /= 1024; |
| 12186 | unitIndex++; |
| 12187 | } |
| 12188 | const precision = size >= 100 ? 0 : (size >= 10 ? 1 : 2); |
| 12189 | const value = size.toFixed(precision).replace(/\.0+$|(\.[0-9]*[1-9])0+$/, "$1"); |
| 12190 | return value + " " + units[unitIndex]; |
| 12191 | } |
| 12192 | |
| 12193 | function updateGalleryHeaderSize(gallery, img, strategy) { |
| 12194 | if (!gallery || !gallery.eleMaps || !gallery.eleMaps['head-left-img-info-size']) return; |
no outgoing calls
no test coverage detected