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.hx19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/client/Utils.hx b/src/client/Utils.hx
index 818dfdf..2c887ba 100644
--- a/src/client/Utils.hx
+++ b/src/client/Utils.hx
@@ -1,5 +1,6 @@
package client;
+import haxe.io.Mime;
import js.Browser.document;
import js.Browser.navigator;
import js.Browser.window;
@@ -126,4 +127,22 @@ class Utils {
document.body.appendChild(input);
input.click();
}
+
+ public static function saveFile(name:String, mime:Mime, data:String):Void {
+ final blob = new js.html.Blob([data], {
+ type: mime
+ });
+ final url = URL.createObjectURL(blob);
+ final a = document.createElement("a");
+ untyped a.download = name;
+ untyped a.href = url;
+ a.onclick = function(e) {
+ e.cancelBubble = true;
+ e.stopPropagation();
+ }
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ URL.revokeObjectURL(url);
+ }
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage