Compare commits
3 Commits
511ff90a98
...
d02bcfe484
Author | SHA1 | Date | |
---|---|---|---|
d02bcfe484 | |||
0d81b8da79 | |||
2fa432b6b8 |
151
package-lock.json
generated
151
package-lock.json
generated
|
@ -1746,6 +1746,17 @@
|
||||||
"integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==",
|
"integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"ansi-styles": {
|
||||||
|
"version": "4.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
|
||||||
|
"integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/color-name": "^1.1.1",
|
||||||
|
"color-convert": "^2.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cacache": {
|
"cacache": {
|
||||||
"version": "13.0.1",
|
"version": "13.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/cacache/-/cacache-13.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/cacache/-/cacache-13.0.1.tgz",
|
||||||
|
@ -1772,6 +1783,34 @@
|
||||||
"unique-filename": "^1.1.1"
|
"unique-filename": "^1.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"chalk": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"ansi-styles": "^4.1.0",
|
||||||
|
"supports-color": "^7.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"color-convert": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"color-name": "~1.1.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"color-name": {
|
||||||
|
"version": "1.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||||
|
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
"find-cache-dir": {
|
"find-cache-dir": {
|
||||||
"version": "3.3.1",
|
"version": "3.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz",
|
||||||
|
@ -1793,6 +1832,13 @@
|
||||||
"path-exists": "^4.0.0"
|
"path-exists": "^4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"has-flag": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
"locate-path": {
|
"locate-path": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
|
||||||
|
@ -1857,6 +1903,16 @@
|
||||||
"minipass": "^3.1.1"
|
"minipass": "^3.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"supports-color": {
|
||||||
|
"version": "7.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz",
|
||||||
|
"integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"has-flag": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"terser-webpack-plugin": {
|
"terser-webpack-plugin": {
|
||||||
"version": "2.3.8",
|
"version": "2.3.8",
|
||||||
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-2.3.8.tgz",
|
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-2.3.8.tgz",
|
||||||
|
@ -1873,6 +1929,21 @@
|
||||||
"terser": "^4.6.12",
|
"terser": "^4.6.12",
|
||||||
"webpack-sources": "^1.4.3"
|
"webpack-sources": "^1.4.3"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"vue-loader-v16": {
|
||||||
|
"version": "npm:vue-loader@16.0.0-beta.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.0.0-beta.5.tgz",
|
||||||
|
"integrity": "sha512-ciWfzNefqWlmzKznCWY9hl+fPP4KlQ0A9MtHbJ/8DpyY+dAM8gDrjufIdxwTgC4szE4EZC3A6ip/BbrqM84GqA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/mini-css-extract-plugin": "^0.9.1",
|
||||||
|
"chalk": "^3.0.0",
|
||||||
|
"hash-sum": "^2.0.0",
|
||||||
|
"loader-utils": "^1.2.3",
|
||||||
|
"merge-source-map": "^1.1.0",
|
||||||
|
"source-map": "^0.6.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -10914,86 +10985,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"vue-loader-v16": {
|
|
||||||
"version": "npm:vue-loader@16.0.0-beta.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.0.0-beta.5.tgz",
|
|
||||||
"integrity": "sha512-ciWfzNefqWlmzKznCWY9hl+fPP4KlQ0A9MtHbJ/8DpyY+dAM8gDrjufIdxwTgC4szE4EZC3A6ip/BbrqM84GqA==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"@types/mini-css-extract-plugin": "^0.9.1",
|
|
||||||
"chalk": "^3.0.0",
|
|
||||||
"hash-sum": "^2.0.0",
|
|
||||||
"loader-utils": "^1.2.3",
|
|
||||||
"merge-source-map": "^1.1.0",
|
|
||||||
"source-map": "^0.6.1"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"ansi-styles": {
|
|
||||||
"version": "4.2.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
|
|
||||||
"integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"@types/color-name": "^1.1.1",
|
|
||||||
"color-convert": "^2.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"chalk": {
|
|
||||||
"version": "3.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz",
|
|
||||||
"integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"ansi-styles": "^4.1.0",
|
|
||||||
"supports-color": "^7.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"color-convert": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"color-name": "~1.1.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"color-name": {
|
|
||||||
"version": "1.1.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
|
||||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"has-flag": {
|
|
||||||
"version": "4.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
|
||||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"source-map": {
|
|
||||||
"version": "0.6.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
|
||||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"supports-color": {
|
|
||||||
"version": "7.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz",
|
|
||||||
"integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"has-flag": "^4.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"vue-style-loader": {
|
"vue-style-loader": {
|
||||||
"version": "4.1.2",
|
"version": "4.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.2.tgz",
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "block-renderer",
|
"name": "block-renderer",
|
||||||
"description": "Content renderer for JSON blocks from Editor.js",
|
"description": "Content renderer for JSON blocks from Editor.js",
|
||||||
"version": "0.1.0",
|
"version": "0.1.3",
|
||||||
"private": true,
|
|
||||||
"author": "KingOfDog <info@kingofdog.de>",
|
"author": "KingOfDog <info@kingofdog.de>",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
3
src/assets/svg/custom.svg
Normal file
3
src/assets/svg/custom.svg
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="40">
|
||||||
|
<path d="M17 0l15 14V3v34a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V3a3 3 0 0 1 3-3h20-6zm0 2H3a1 1 0 0 0-1 1v34a1 1 0 0 0 1 1h26a1 1 0 0 0 1-1V14H17V2zm2 10h7.926L19 4.602V12z"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 240 B |
6
src/assets/svg/standard.svg
Normal file
6
src/assets/svg/standard.svg
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="40">
|
||||||
|
<g fill="#A8ACB8" fill-rule="evenodd">
|
||||||
|
<path fill-rule="nonzero" d="M17 0l15 14V3v34a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V3a3 3 0 0 1 3-3h20-6zm0 2H3a1 1 0 0 0-1 1v34a1 1 0 0 0 1 1h26a1 1 0 0 0 1-1V14H17V2zm2 10h7.926L19 4.602V12z"/>
|
||||||
|
<path d="M7 22h18v2H7zm0 4h18v2H7zm0 4h18v2H7z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 364 B |
81
src/components/AttachesBlock.vue
Normal file
81
src/components/AttachesBlock.vue
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
<template>
|
||||||
|
<div class="attaches-block">
|
||||||
|
<div
|
||||||
|
:data-extension="data.file.extension"
|
||||||
|
:style="{ color: color }"
|
||||||
|
class="attaches-block-file-icon"
|
||||||
|
>
|
||||||
|
<svg>
|
||||||
|
<use
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
v-bind:xlink:href="color ? customIcon : standardIcon"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="attaches-block-file-info">
|
||||||
|
<p class="attaches-block-title">{{ data.file.name }}</p>
|
||||||
|
<p class="attaches-block-size">{{ data.file.size | byteFormatter }}</p>
|
||||||
|
</div>
|
||||||
|
<a :href="data.file.url" class="attaches-block-file download-button"></a>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import byteFormatter from "../filters/byteFormatter";
|
||||||
|
|
||||||
|
const extensions = {
|
||||||
|
doc: "#3e74da",
|
||||||
|
docx: "#3e74da",
|
||||||
|
odt: "#3e74da",
|
||||||
|
pdf: "#d47373",
|
||||||
|
rtf: "#656ecd",
|
||||||
|
tex: "#5a5a5b",
|
||||||
|
txt: "#5a5a5b",
|
||||||
|
pptx: "#e07066",
|
||||||
|
ppt: "#e07066",
|
||||||
|
mp3: "#eab456",
|
||||||
|
mp4: "#f676a6",
|
||||||
|
xls: "#3f9e64",
|
||||||
|
html: "#2988f0",
|
||||||
|
htm: "#2988f0",
|
||||||
|
png: "#f676a6",
|
||||||
|
jpg: "#f67676",
|
||||||
|
jpeg: "#f67676",
|
||||||
|
gif: "#f6af76",
|
||||||
|
zip: "#4f566f",
|
||||||
|
rar: "#4f566f",
|
||||||
|
exe: "#e26f6f",
|
||||||
|
svg: "#bf5252",
|
||||||
|
key: "#e07066",
|
||||||
|
sketch: "#df821c",
|
||||||
|
ai: "#df821c",
|
||||||
|
psd: "#388ae5",
|
||||||
|
dmg: "#e26f6f",
|
||||||
|
json: "#2988f0",
|
||||||
|
csv: "#3f9e64"
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
filters: {
|
||||||
|
byteFormatter
|
||||||
|
},
|
||||||
|
props: ["data"],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
standardIcon: require("@/assets/svg/standard.svg"),
|
||||||
|
customIcon: require("@/assets/svg/custom.svg")
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
color() {
|
||||||
|
return extensions[this.data.file.extension];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.attaches-block-file-icon::before {
|
||||||
|
content: attr(data-extension);
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -10,29 +10,33 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import AttachesBlock from "./AttachesBlock";
|
||||||
import EmbedBlock from "./EmbedBlock";
|
import EmbedBlock from "./EmbedBlock";
|
||||||
import HeaderBlock from "./HeaderBlock";
|
import HeaderBlock from "./HeaderBlock";
|
||||||
import ImageBlock from "./ImageBlock";
|
import ImageBlock from "./ImageBlock";
|
||||||
|
import LinkBlock from "./LinkBlock";
|
||||||
import ListBlock from "./ListBlock";
|
import ListBlock from "./ListBlock";
|
||||||
import ParagraphBlock from "./ParagraphBlock";
|
import ParagraphBlock from "./ParagraphBlock";
|
||||||
import QuoteBlock from "./QuoteBlock";
|
import QuoteBlock from "./QuoteBlock";
|
||||||
import WarningBlock from "./WarningBlock";
|
import WarningBlock from "./WarningBlock";
|
||||||
|
|
||||||
const componentTypes = {
|
const componentTypes = {
|
||||||
|
attaches: AttachesBlock,
|
||||||
embed: EmbedBlock,
|
embed: EmbedBlock,
|
||||||
header: HeaderBlock,
|
header: HeaderBlock,
|
||||||
image: ImageBlock,
|
image: ImageBlock,
|
||||||
|
link: LinkBlock,
|
||||||
list: ListBlock,
|
list: ListBlock,
|
||||||
paragraph: ParagraphBlock,
|
paragraph: ParagraphBlock,
|
||||||
quote: QuoteBlock,
|
quote: QuoteBlock,
|
||||||
warning: WarningBlock,
|
warning: WarningBlock
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ["content"],
|
props: ["content"],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
blocks: [],
|
blocks: []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -45,20 +49,20 @@ export default {
|
||||||
if (!this.content.blocks) {
|
if (!this.content.blocks) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.blocks = this.content.blocks.map((block) => ({
|
this.blocks = this.content.blocks.map(block => ({
|
||||||
component: componentTypes[block.type],
|
component: componentTypes[block.type],
|
||||||
type: block.type,
|
type: block.type,
|
||||||
data: block.data,
|
data: block.data
|
||||||
}));
|
}));
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
content() {
|
content() {
|
||||||
if (this.content) {
|
if (this.content) {
|
||||||
this.prepareBlocks();
|
this.prepareBlocks();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
22
src/components/LinkBlock.vue
Normal file
22
src/components/LinkBlock.vue
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<template>
|
||||||
|
<div class="link-block">
|
||||||
|
<div class="link-block-meta">
|
||||||
|
<div class="link-block-title">{{data.meta.title}}</div>
|
||||||
|
<p class="link-block-description">{{data.meta.description}}</p>
|
||||||
|
<div class="link-block-anchor">{{domain}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="link-block-image" :style="{ 'background-image': data.meta.image.url }"></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: ["data"],
|
||||||
|
computed: {
|
||||||
|
domain() {
|
||||||
|
return this.data.link.replace(/(https|http):\/\//, "").split(/[/?#]/)[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
30
src/filters/byteFormatter.js
Normal file
30
src/filters/byteFormatter.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
module.exports = function(size) {
|
||||||
|
var result;
|
||||||
|
|
||||||
|
switch (true) {
|
||||||
|
case size === null || size === "" || isNaN(size):
|
||||||
|
result = "-";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case size >= 0 && size < 1024:
|
||||||
|
result = size + " B";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case size >= 1024 && size < Math.pow(1024, 2):
|
||||||
|
result = Math.round((size / 1024) * 100) / 100 + " KiB";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case size >= Math.pow(1024, 2) && size < Math.pow(1024, 3):
|
||||||
|
result = Math.round((size / Math.pow(1024, 2)) * 100) / 100 + " MiB";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case size >= Math.pow(1024, 3) && size < Math.pow(1024, 4):
|
||||||
|
result = Math.round((size / Math.pow(1024, 3)) * 100) / 100 + " GiB";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
result = Math.round((size / Math.pow(1024, 4)) * 100) / 100 + " TiB";
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user