diff options
| author | RblSb <msrblsb@gmail.com> | 2021-09-27 20:13:55 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2021-09-27 20:14:36 +0300 |
| commit | 1dc2722d509e578b243bfda1a675dcfdb6003941 (patch) | |
| tree | dd78e7e09432177f5ea4ed8a3febbfbf0d5113ec /src/client/Utils.hx | |
| parent | d3c34032ef86163d683ef22906481e0f3196ae79 (diff) | |
Got a bug? Write /dump to chat as admin
And open new issue with received file.
Diffstat (limited to 'src/client/Utils.hx')
| -rw-r--r-- | src/client/Utils.hx | 19 |
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); + } } |
