-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
414 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,36 @@ | ||
export function copyTextFromInput(input, copyBtn) { | ||
if (input.value !== '') { | ||
navigator.clipboard.writeText(input.value); | ||
copyBtn.setAttribute('href', './img/sprite.svg#check'); | ||
setTimeout(() => { | ||
copyBtn.removeAttribute('href', './img/sprite.svg#check'); | ||
}, 350); | ||
} | ||
const inputValue = input.innerText; | ||
|
||
if (inputValue !== '') { | ||
navigator.clipboard.writeText(inputValue); | ||
copyBtn.setAttribute('href', './img/sprite.svg#check'); | ||
setTimeout(() => { | ||
copyBtn.removeAttribute('href', './img/sprite.svg#check'); | ||
}, 350); | ||
} | ||
} | ||
|
||
export function downloadFile(filename, data) { | ||
const blob = new Blob([data], { type: 'text/plain' }); | ||
const url = URL.createObjectURL(blob); | ||
const blob = new Blob([data], { type: 'text/plain' }); | ||
const url = URL.createObjectURL(blob); | ||
|
||
const a = document.createElement('a'); | ||
a.href = url; | ||
a.download = filename; | ||
a.click(); | ||
const a = document.createElement('a'); | ||
a.href = url; | ||
a.download = filename; | ||
a.click(); | ||
|
||
URL.revokeObjectURL(url); | ||
URL.revokeObjectURL(url); | ||
} | ||
|
||
export async function handleTextFiles(files, fileCallback) { | ||
const promises = [...files].map(fileCallback); | ||
await Promise.all(promises); | ||
const promises = [...files].map(fileCallback); | ||
await Promise.all(promises); | ||
} | ||
|
||
export async function handleDrop(e, dropCallback) { | ||
e.preventDefault(); | ||
let dt = e.dataTransfer; | ||
let files = dt.files; | ||
e.preventDefault(); | ||
let dt = e.dataTransfer; | ||
let files = dt.files; | ||
|
||
dropCallback(files) | ||
dropCallback(files); | ||
} |
Oops, something went wrong.