From dcfff04c97cc4415623c9fc103c581346c87412a Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Thu, 7 Nov 2024 18:15:56 +0100 Subject: Add download button --- public/site.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'public/site.js') 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 = $("") + .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(); -- cgit v1.2.3