| 577 | |
| 578 | // Returns a nicely formatted filesize |
| 579 | filesize(size) { |
| 580 | let selectedSize = 0; |
| 581 | let selectedUnit = "b"; |
| 582 | |
| 583 | if (size > 0) { |
| 584 | let units = ["tb", "gb", "mb", "kb", "b"]; |
| 585 | |
| 586 | for (let i = 0; i < units.length; i++) { |
| 587 | let unit = units[i]; |
| 588 | let cutoff = Math.pow(this.options.filesizeBase, 4 - i) / 10; |
| 589 | |
| 590 | if (size >= cutoff) { |
| 591 | selectedSize = size / Math.pow(this.options.filesizeBase, 4 - i); |
| 592 | selectedUnit = unit; |
| 593 | break; |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | selectedSize = Math.round(10 * selectedSize) / 10; // Cutting of digits |
| 598 | } |
| 599 | |
| 600 | return `<strong>${selectedSize}</strong> ${this.options.dictFileSizeUnits[selectedUnit]}`; |
| 601 | } |
| 602 | |
| 603 | // Adds or removes the `dz-max-files-reached` class from the form. |
| 604 | _updateMaxFilesReachedClass() { |