A mirror of my website's source code.

By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

 PostEdit.html

View raw Download
text/html • 1.2 kiB
HTML document, ASCII text
        
            
1
<form>
2
<input type="text" name="editing" id="BlogFileName">
3
<label for="BlogFileName">Blog post to edit.</label><br>
4
<button>Edit</button><br>
5
<em>Note: if none is selected, a new one will be created.</em>
6
</form>
7
8
<b id="NoPostFound" style="display:none">Cannot edit a non-existant post.</b>
9
10
<form id="mainform" action="/DevHelp/.BlogBuilder" method="post">
11
<input type="text" name="title" placeholder="Insert title..."><br>
12
<textarea name="Body"></textarea><br>
13
<button>Post</button>
14
</form>
15
16
<script>
17
const query = new URLSearchParams(location.search);
18
var NewPost = !query.has("editing") || query.get("editing") == "";
19
20
if (!NewPost) {
21
fetch(`/blog/${query.get("editing")}.md`)
22
.then(res => {
23
if (!res.ok) {
24
NewPost = true;
25
return "";
26
}
27
return res.text()
28
})
29
.then(res => {
30
if (res == "") {
31
document.querySelector("#mainform").style.display = "none";
32
document.querySelector("#NoPostFound").style.display = "block";
33
return;
34
}
35
36
})
37
}
38
</script>