diff options
author | Jonas Kohl | 2024-11-07 18:15:56 +0100 |
---|---|---|
committer | Jonas Kohl | 2024-11-07 18:15:56 +0100 |
commit | dcfff04c97cc4415623c9fc103c581346c87412a (patch) | |
tree | 236a6eff4d11149773c41c059805ce28dfe181f3 /public/site.js | |
parent | 887ee6afe950e1b72f133fc180d43ebd5462eefd (diff) |
Add download button
Diffstat (limited to 'public/site.js')
-rw-r--r-- | public/site.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/public/site.js b/public/site.js index 17a8115..ed7173d 100644 --- a/public/site.js +++ b/public/site.js @@ -11,6 +11,16 @@ $(function() { }); editor.setSize(null, 500); + $("#dlCodeButton").on("click", function() { + var a = $("<a></a>") + .attr("href", "data:text/x-java;charset=UTF-8," + encodeURIComponent(editor.getValue())) + .attr("download", "Program.java") + .css("display", "none") + .appendTo("body"); + a.get(0).click(); + a.remove(); + }); + $("form").on("submit", function(e) { e.preventDefault(); |