From 8ccf2f9bf55fdf9d707c76aa9074d60d3207fc13 Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Fri, 8 Nov 2024 11:43:34 +0100 Subject: Add permalink option --- public/site.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'public/site.js') diff --git a/public/site.js b/public/site.js index ed7173d..e19d6ef 100644 --- a/public/site.js +++ b/public/site.js @@ -21,6 +21,34 @@ $(function() { a.remove(); }); + $("#permalink").on("click", function() { + $("#loader").show(); + $.ajax({ + type: "POST", + url: location.href, + data: { + code: editor.getValue(), + csrf: csrf, + permalink: "1" + }, + dataType: "json", + success: function(data) { + $("#loader").hide(); + + if (!data.ok) { + alert("Error: " + data.message); + if (data.csrf) + csrf = data.csrf; + return; + } + + csrf = data.csrf; + + location.href = "?c=" + encodeURIComponent(data.data); + } + }); + }); + $("form").on("submit", function(e) { e.preventDefault(); -- cgit v1.2.3