Add initial project files

This commit is contained in:
Igor Martyniuk
2026-09-01 13:03:41 +03:00
parent 22e111bb44
commit 74cb5b6176
1841 changed files with 242819 additions and 30 deletions
+22
View File
@@ -0,0 +1,22 @@
/// <reference lib="dom" />
/**
* Downloads a file by providing a link.
* @param href - The URL of the file to download.
* @param name - The name of the downloaded file. Default is "file".
* @param target - The target window or frame for the downloaded file. Default is "_blank".
* @example
* // Example usage:
* downloadFileByLink("https://example.com/file.pdf", "myFile", "_self");
*/
export const downloadFileByLink = (href: string, name = 'file', target = '_blank'): void => {
const link = document.createElement('a');
link.href = href;
link.download = name;
link.target = target;
link.style.visibility = 'hidden';
link.setAttribute('target', '_blank');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};