aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/Utils.hx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/Utils.hx')
-rw-r--r--src/client/Utils.hx21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/client/Utils.hx b/src/client/Utils.hx
index 2234a1b..54025aa 100644
--- a/src/client/Utils.hx
+++ b/src/client/Utils.hx
@@ -6,6 +6,7 @@ import js.Browser.navigator;
import js.Browser.window;
import js.html.Blob;
import js.html.Element;
+import js.html.File;
import js.html.FileReader;
import js.html.URL;
import js.html.audio.AudioContext;
@@ -181,6 +182,26 @@ class Utils {
input.click();
}
+ /** Don't extract data for bigger files. **/
+ public static function browseJsFile(
+ onFileSelected:(file:File) -> Void
+ ):Void {
+ final input = document.createInputElement();
+ input.style.visibility = "hidden";
+ input.type = "file";
+ input.id = "browse";
+ input.onclick = e -> {
+ e.cancelBubble = true;
+ e.stopPropagation();
+ }
+ input.onchange = e -> {
+ final file = input.files[0] ?? return;
+ onFileSelected(file);
+ }
+ document.body.appendChild(input);
+ input.click();
+ }
+
public static function saveFile(name:String, mime:Mime, data:String):Void {
final blob = new Blob([data], {
type: mime
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage