mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-07-23 23:11:04 -04:00
Show file name and size on download page
This commit is contained in:
parent
409af9b991
commit
d01c37c59d
42 changed files with 373 additions and 3 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
## 1.7.7 (not yet released)
|
||||
* ADDED: Switching templates using the web ui (#1501)
|
||||
* ADDED: Show file name and size on download page (#603)
|
||||
* CHANGED: Passing large data structures by reference to reduce memory consumption (#858)
|
||||
* CHANGED: Removed use of ctype functions and polyfill library for ctype
|
||||
* CHANGED: Upgrading libraries to: DOMpurify 3.2.6, ip-lib 1.20.0
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* Simon Rupf - current developer and maintainer
|
||||
* rugk - security review, doc improvment, JS refactoring & various other stuff
|
||||
* R4SAS - python client, compression, blob URI to support larger attachments
|
||||
* Mikhail Romanov - UI improvements, theme switching, clipboard support, multi-file upload, bugfixes, code refactoring
|
||||
|
||||
## Past contributions
|
||||
|
||||
|
@ -33,7 +34,6 @@
|
|||
* Mounir Idrassi & J. Mozdzen - secure YOURLS integration
|
||||
* Felipe Nakandakari - enabled AWS SDK to use default credential provider chain in the S3 Storage backend
|
||||
* Aaron Sherber - cache control headers for API calls & use of `shortenviayourls` in query parameters
|
||||
* Mikhail Romanov - UI improvements, theme switching, clipboard support, multi-file upload, bugfixes, code refactoring
|
||||
|
||||
## Translations
|
||||
* Hexalyse - French
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "إكسابايت",
|
||||
"ZiB": "زيتابايت",
|
||||
"YiB": "يوتابايت",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "التنسيق",
|
||||
"Plain Text": "نص عادي",
|
||||
"Source Code": "كود مصدر",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Формат",
|
||||
"Plain Text": "Чист текст",
|
||||
"Source Code": "Изходен код",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Text sense format",
|
||||
"Source Code": "Codi font",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "Eo",
|
||||
"ZiB": "Zo",
|
||||
"YiB": "Yo",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Furmatu",
|
||||
"Plain Text": "Testu in chjaru",
|
||||
"Source Code": "Codice di fonte",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Formát",
|
||||
"Plain Text": "Prostý text",
|
||||
"Source Code": "Zdrojový kód",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Nur Text",
|
||||
"Source Code": "Quellcode",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Μορφοποίηση",
|
||||
"Plain Text": "Απλό κείμενο",
|
||||
"Source Code": "Πηγαίος Κώδικας",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Plain Text",
|
||||
"Source Code": "Source Code",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Formato",
|
||||
"Plain Text": "Texto sin formato",
|
||||
"Source Code": "Código fuente",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Formaat",
|
||||
"Plain Text": "Lihttekst",
|
||||
"Source Code": "Lähtekood",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Formaatti",
|
||||
"Plain Text": "Perusteksti",
|
||||
"Source Code": "Lähdekoodi",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "Eio",
|
||||
"ZiB": "Zio",
|
||||
"YiB": "Yio",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Texte brut",
|
||||
"Source Code": "Code source",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "פורמט",
|
||||
"Plain Text": "טקסט פשוט",
|
||||
"Source Code": "קוד מקור",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Plain Text",
|
||||
"Source Code": "Source Code",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Formátum",
|
||||
"Plain Text": "Egyszerű szöveg",
|
||||
"Source Code": "Forráskód",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Teks Biasa",
|
||||
"Source Code": "Kode Sumber",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Formato",
|
||||
"Plain Text": "Solo Testo",
|
||||
"Source Code": "Codice Sorgente",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "形式",
|
||||
"Plain Text": "プレーンテキスト",
|
||||
"Source Code": "ソースコード",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Plain Text",
|
||||
"Source Code": "Source Code",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Plain Text",
|
||||
"Source Code": "Source Code",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Plain Text",
|
||||
"Source Code": "Source Code",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Plain Text",
|
||||
"Source Code": "Source Code",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Formatas",
|
||||
"Plain Text": "Grynasis tekstas",
|
||||
"Source Code": "Pirminis kodas",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Formaat",
|
||||
"Plain Text": "Platte tekst",
|
||||
"Source Code": "Broncode",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Ren Tekst",
|
||||
"Source Code": "Kildekode",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "Eio",
|
||||
"ZiB": "Zio",
|
||||
"YiB": "Yio",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Tèxte brut",
|
||||
"Source Code": "Còdi font",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Czysty tekst",
|
||||
"Source Code": "Kod źródłowy",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Formato",
|
||||
"Plain Text": "Texto sem formato",
|
||||
"Source Code": "Código fonte",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Formatare",
|
||||
"Plain Text": "Text neformatat",
|
||||
"Source Code": "Cod sursă",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "Эбайт",
|
||||
"ZiB": "Збайт",
|
||||
"YiB": "Йбайт",
|
||||
"KB": "КБ",
|
||||
"MB": "МБ",
|
||||
"GB": "ГБ",
|
||||
"TB": "ТБ",
|
||||
"PB": "ПБ",
|
||||
"EB": "ЭБ",
|
||||
"ZB": "ЗБ",
|
||||
"YB": "ЙБ",
|
||||
"Format": "Формат",
|
||||
"Plain Text": "Обычный текст",
|
||||
"Source Code": "Исходный код",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Formát",
|
||||
"Plain Text": "Čistý text",
|
||||
"Source Code": "Zdrojový kód",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EB",
|
||||
"ZiB": "ZB",
|
||||
"YiB": "YB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Surov tekst",
|
||||
"Source Code": "Odprta koda",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Plain Text",
|
||||
"Source Code": "Source Code",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "รูปแบบ",
|
||||
"Plain Text": "ข้อความล้วน",
|
||||
"Source Code": "ซอร์สโค้ด",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Düz Yazı",
|
||||
"Source Code": "Kaynak Kodu",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "Ебайт",
|
||||
"ZiB": "Збайт",
|
||||
"YiB": "Йбайт",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "Формат",
|
||||
"Plain Text": "Звичайний текст",
|
||||
"Source Code": "Вихідний код",
|
||||
|
|
|
@ -164,6 +164,14 @@
|
|||
"EiB": "EiB",
|
||||
"ZiB": "ZiB",
|
||||
"YiB": "YiB",
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
"TB": "TB",
|
||||
"PB": "PB",
|
||||
"EB": "EB",
|
||||
"ZB": "ZB",
|
||||
"YB": "YB",
|
||||
"Format": "格式",
|
||||
"Plain Text": "纯文本",
|
||||
"Source Code": "源代码",
|
||||
|
|
|
@ -591,6 +591,32 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||
return expirationDate;
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert Bytes to KB/MB/GB
|
||||
*
|
||||
* @name Helper.formatBytes
|
||||
* @function
|
||||
*
|
||||
* @param {number} bytes
|
||||
* @return {string}
|
||||
*/
|
||||
me.formatBytes = function (bytes)
|
||||
{
|
||||
let result = '';
|
||||
const kilobyte = 1000;
|
||||
const decimalPoint = 2;
|
||||
const sizes = [I18n._('B'), I18n._('KB'), I18n._('MB'), I18n._('GB')];
|
||||
const index = Math.floor(Math.log(bytes) / Math.log(kilobyte));
|
||||
|
||||
if (bytes > 0) {
|
||||
result = parseFloat((bytes / Math.pow(kilobyte, index)).toFixed(decimalPoint)) + ' ' + sizes[index];
|
||||
} else {
|
||||
result = `0 ${I18n._('B')}`;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* resets state, used for unit testing
|
||||
*
|
||||
|
@ -3000,7 +3026,9 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||
|
||||
if (typeof fileName !== 'undefined') {
|
||||
attachmentLink.attr('download', fileName);
|
||||
template.append(fileName);
|
||||
|
||||
const fileSize = me.getAttachmentSize(attachmentData);
|
||||
template.append(`(${fileName}, ${fileSize})`);
|
||||
}
|
||||
|
||||
// sanitize SVG preview
|
||||
|
@ -3202,6 +3230,25 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||
return attachmentData.substring(5, mimeTypeEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attachment size in B/KB/MB/GB
|
||||
*
|
||||
* @name AttachmentViewer.getAttachmentSize
|
||||
* @function
|
||||
* @param {string} attachmentData - Base64 string
|
||||
*/
|
||||
me.getAttachmentSize = function(attachmentData)
|
||||
{
|
||||
const base64Start = attachmentData.indexOf(',') + 1;
|
||||
const rawData = attachmentData.substring(base64Start);
|
||||
const decodedData = rawData.length > 0 ? atob(rawData) : '';
|
||||
|
||||
const buf = new Uint8Array(decodedData.length);
|
||||
const bytes = new Blob([buf]).size;
|
||||
|
||||
return Helper.formatBytes(bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* moves the attachment link to another element
|
||||
*
|
||||
|
|
|
@ -290,5 +290,31 @@ describe('Helper', function () {
|
|||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('formatBytes', function () {
|
||||
jsc.property('returns 0 B for 0 bytes', function () {
|
||||
return $.PrivateBin.Helper.formatBytes(0) === '0 B';
|
||||
});
|
||||
|
||||
jsc.property('formats bytes < 1000 as B', function () {
|
||||
return $.PrivateBin.Helper.formatBytes(500) === '500 B';
|
||||
});
|
||||
|
||||
jsc.property('formats kilobytes correctly', function () {
|
||||
return $.PrivateBin.Helper.formatBytes(1500) === '1.5 KB';
|
||||
});
|
||||
|
||||
jsc.property('formats megabytes correctly', function () {
|
||||
return $.PrivateBin.Helper.formatBytes(2 * 1000 * 1000) === '2 MB';
|
||||
});
|
||||
|
||||
jsc.property('formats gigabytes correctly', function () {
|
||||
return $.PrivateBin.Helper.formatBytes(3.45 * 1000 * 1000 * 1000) === '3.45 GB';
|
||||
});
|
||||
|
||||
jsc.property('rounds to two decimal places', function () {
|
||||
return $.PrivateBin.Helper.formatBytes(1234567) === '1.23 MB';
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ class Configuration
|
|||
'js/kjua-0.9.0.js' => 'sha512-CVn7af+vTMBd9RjoS4QM5fpLFEOtBCoB0zPtaqIDC7sF4F8qgUSRFQQpIyEDGsr6yrjbuOLzdf20tkHHmpaqwQ==',
|
||||
'js/legacy.js' => 'sha512-UxW/TOZKon83n6dk/09GsYKIyeO5LeBHokxyIq+r7KFS5KMBeIB/EM7NrkVYIezwZBaovnyNtY2d9tKFicRlXg==',
|
||||
'js/prettify.js' => 'sha512-puO0Ogy++IoA2Pb9IjSxV1n4+kQkKXYAEUtVzfZpQepyDPyXk8hokiYDS7ybMogYlyyEIwMLpZqVhCkARQWLMg==',
|
||||
'js/privatebin.js' => 'sha512-m6RrsOsz4RgIWXDzgRghQDx6aegFCpkpqURwhfXwE/rNWhe/1rPJaLR+FXII82iTWo0n9JCzSbqrDqkYVPI50w==',
|
||||
'js/privatebin.js' => 'sha512-rRy19m1V347H457Vcvy0IpbuohAuvIPgVY4s+FgoSn9avqFj3lYA4W/Ewz3DS+BekCUvVm9I8/YMbW82PzgFmQ==',
|
||||
'js/purify-3.2.6.js' => 'sha512-zqwL4OoBLFx89QPewkz4Lz5CSA2ktU+f31fuECkF0iK3Id5qd3Zpq5dMby8KwHjIEpsUgOqwF58cnmcaNem0EA==',
|
||||
'js/rawinflate-0.3.js' => 'sha512-g8uelGgJW9A/Z1tB6Izxab++oj5kdD7B4qC7DHwZkB6DGMXKyzx7v5mvap2HXueI2IIn08YlRYM56jwWdm2ucQ==',
|
||||
'js/showdown-2.1.0.js' => 'sha512-WYXZgkTR0u/Y9SVIA4nTTOih0kXMEd8RRV6MLFdL6YU8ymhR528NLlYQt1nlJQbYz4EW+ZsS0fx1awhiQJme1Q==',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue