diff options
Diffstat (limited to 'public/site.js')
-rw-r--r-- | public/site.js | 28 |
1 files changed, 28 insertions, 0 deletions
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(); |