2023-02-16 12:30:06 +00:00
|
|
|
function saveText() {
|
|
|
|
let x = document.getElementById("text").value;
|
|
|
|
|
|
|
|
const options = {method: 'POST', body: JSON.stringify({text: x}), headers: { 'Content-Type': 'application/json' }};
|
|
|
|
|
2023-02-16 13:35:42 +00:00
|
|
|
fetch(location.protocol + '/api/edit', options)
|
2023-02-16 12:30:06 +00:00
|
|
|
.then((response) => response.text())
|
|
|
|
.then(data => {
|
|
|
|
redirectOrNot(data);
|
|
|
|
})
|
|
|
|
.catch(err => console.error(err));
|
|
|
|
}
|
|
|
|
|
|
|
|
async function redirectOrNot(res) {
|
2023-02-16 13:35:42 +00:00
|
|
|
let url = location.protocol
|
2023-02-16 12:30:06 +00:00
|
|
|
location.href = url+res
|
2023-02-16 13:35:42 +00:00
|
|
|
}
|