A pastebin for markdown pages.
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.
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
function $(id) { return document.getElementById(id) }
|
|
|
|
|
|
|
|
|
|
function submitForm() {
|
|
|
|
|
const id = $("id").value;
|
|
|
|
|
const text = $("text").value;
|
|
|
|
|
const name = $("name").value;
|
|
|
|
|
const deletion = id !== "" && text === "";
|
|
|
|
|
if (deletion && !confirm("Do you want to delete this note?")) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const resp = post("/", {
|
|
|
|
|
"id": id,
|
|
|
|
|
"text": text,
|
|
|
|
|
"name": name,
|
|
|
|
|
"password": $("password").value
|
|
|
|
|
}, function (status, responseRaw) {
|
|
|
|
|
const response = JSON.parse(responseRaw);
|
|
|
|
|
if (status < 400 && response.Success) {
|
|
|
|
|
window.location.replace(deletion ? "/" : "/" + response.Payload)
|
|
|
|
|
} else {
|
|
|
|
|
$('feedback').innerHTML = status + ": " + response.Payload;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|