|
@@ -1,4 +1,5 @@
|
|
|
import mime from 'mime-types'
|
|
|
+
|
|
|
|
|
|
|
|
|
* A collection of small utility functions that help with dom manipulation, adding listeners,
|
|
@@ -170,6 +171,28 @@ export function readFile (fileObj) {
|
|
|
return resolve(ev.target.result)
|
|
|
})
|
|
|
reader.readAsDataURL(fileObj)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -202,6 +225,12 @@ export function createImageThumbnail (imgDataURI, newWidth) {
|
|
|
|
|
|
ctx.drawImage(img, 0, 0, newImageWidth, newImageHeight)
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
const thumbnail = canvas.toDataURL('image/png')
|
|
@@ -293,6 +322,33 @@ export function copyToClipboard (textToCopy, fallbackString) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+export function makeWorker (script) {
|
|
|
+ var URL = window.URL || window.webkitURL
|
|
|
+ var Blob = window.Blob
|
|
|
+ var Worker = window.Worker
|
|
|
+
|
|
|
+ if (!URL || !Blob || !Worker || !script) {
|
|
|
+ return null
|
|
|
+ }
|
|
|
+
|
|
|
+ let code = script.toString()
|
|
|
+ code = code.substring(code.indexOf('{') + 1, code.lastIndexOf('}'))
|
|
|
+
|
|
|
+ var blob = new Blob([code])
|
|
|
+ var worker = new Worker(URL.createObjectURL(blob))
|
|
|
+ return worker
|
|
|
+}
|
|
|
+
|
|
|
export function getSpeed (fileProgress) {
|
|
|
if (!fileProgress.bytesUploaded) return 0
|
|
|
|
|
@@ -309,22 +365,6 @@ export function getETA (fileProgress) {
|
|
|
const secondsRemaining = Math.round(bytesRemaining / uploadSpeed * 10) / 10
|
|
|
|
|
|
return secondsRemaining
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
export function prettyETA (seconds) {
|
|
@@ -358,5 +398,7 @@ export default {
|
|
|
secondsToTime,
|
|
|
dataURItoBlob,
|
|
|
dataURItoFile,
|
|
|
- getSpeed
|
|
|
+ getSpeed,
|
|
|
+ getETA,
|
|
|
+ makeWorker
|
|
|
}
|