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.hx25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/client/Utils.hx b/src/client/Utils.hx
index de6b16c..232ca02 100644
--- a/src/client/Utils.hx
+++ b/src/client/Utils.hx
@@ -3,6 +3,7 @@ package client;
import js.Browser.document;
import js.Browser.window;
import js.html.Element;
+import js.html.URL;
class Utils {
public static function isTouch():Bool {
@@ -87,4 +88,28 @@ class Utils {
document.body.removeChild(textarea);
}
}
+
+ public static function browseFileUrl(
+ onFileLoad:(url:String, name:String) -> Void,
+ isBinary = true,
+ revoke = false
+ ):Void {
+ final input = document.createElement("input");
+ input.style.visibility = "hidden";
+ input.setAttribute("type", "file");
+ input.id = "browse";
+ input.onclick = function(e) {
+ e.cancelBubble = true;
+ e.stopPropagation();
+ }
+ input.onchange = function() {
+ final file:Dynamic = (input : Dynamic).files[0];
+ final url = URL.createObjectURL(file);
+ onFileLoad(url, file.name);
+ document.body.removeChild(input);
+ if (revoke) URL.revokeObjectURL(url);
+ }
+ document.body.appendChild(input);
+ input.click();
+ }
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage