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/index.php | 1 + public/site.js | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/public/index.php b/public/index.php index e767a65..b6ac78e 100644 --- a/public/index.php +++ b/public/index.php @@ -150,6 +150,7 @@ $csrf = csrf_token();
+
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