You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
886 B
29 lines
886 B
"use strict"; |
|
|
|
function $(id) { return document.getElementById(id) } |
|
|
|
function toggleButton() { $('publish-button').disabled = !$('tos').checked } |
|
|
|
function submitForm(token) { |
|
var id = $("id").value; |
|
var text = $("text").value; |
|
var deletion = id != "" && text == ""; |
|
if (deletion && !confirm("Do you want to delete this note?")) { |
|
return; |
|
} |
|
var resp = post("/", { |
|
"id": id, |
|
"text": text, |
|
"tos": $("tos").value, |
|
"password": $("password").value, |
|
"token": token |
|
}, function (status, responseRaw) { |
|
var response = JSON.parse(responseRaw); |
|
if (status < 400 && response.Success) { |
|
window.location.replace(deletion ? "/" : "/" + response.Payload) |
|
} else { |
|
grecaptcha.reset(); |
|
$('feedback').innerHTML = status + ": " + response.Payload; |
|
} |
|
}) |
|
}
|
|
|