-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepo.js
49 lines (45 loc) · 1.56 KB
/
repo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
async function createArticle() {
let title = document.getElementById('article_title').value;
let content = document.getElementById('article_content').value;
let response = await axios.post('/create_article', { title: title, content: content });
if (response.data.success) {
window.location.reload();
} else {
alert(response.data.error);
}
}
async function editArticle(articleId) {
let title = prompt('Enter new title:');
let content = prompt('Enter new content:');
let response = await axios.post('/edit_article', { article_id: articleId, title: title, content: content });
if (response.data.success) {
window.location.reload();
} else {
alert(response.data.error);
}
}
async function deleteArticle(articleId) {
let response = await axios.post('/delete_article', { article_id: articleId });
if (response.data.success) {
window.location.reload();
} else {
alert(response.data.error);
}
}
async function addComment(articleId) {
let content = document.getElementById('comment_content_' + articleId).value;
let response = await axios.post('/add_comment', { article_id: articleId, content: content });
if (response.data.success) {
window.location.reload();
} else {
alert(response.data.error);
}
}
async function deleteComment(commentId) {
let response = await axios.post('/delete_comment', { comment_id: commentId });
if (response.data.success) {
window.location.reload();
} else {
alert(response.data.error);
}
}