From 5e4f137dbaf3a822ea8febed19ef508d02e6eef3 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Wed, 5 Sep 2018 13:31:51 +0400 Subject: [PATCH] add method for create paper --- src/main/resources/public/js/papers.js | 16 ++++++++++++++-- src/main/resources/templates/papers.html | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/resources/public/js/papers.js b/src/main/resources/public/js/papers.js index f428ff3..c7b721f 100644 --- a/src/main/resources/public/js/papers.js +++ b/src/main/resources/public/js/papers.js @@ -1,7 +1,7 @@ -var urlPaperList = "https://localhost:8443/api/1.0/papers"; +var urlPapers = "https://localhost:8443/api/1.0/papers"; function showPapers(papersElement) { - getFromRest(urlPaperList, function (paperList) { + getFromRest(urlPapers, function (paperList) { paperList.forEach(function (paper, index) { $(papersElement).parent().append("
" + "
" + @@ -14,4 +14,16 @@ function showPapers(papersElement) { "
"); }); }); +} + +function addPaper(title, status, comment, locked) { + var paperData = JSON.stringify({ + "title": title, + "status": status, + "comment": comment, + "locked": locked + }); + postToRest(urlPapers, paperData, function(data) { + alert(data); + }); } \ No newline at end of file diff --git a/src/main/resources/templates/papers.html b/src/main/resources/templates/papers.html index 013fbc7..81b6952 100644 --- a/src/main/resources/templates/papers.html +++ b/src/main/resources/templates/papers.html @@ -34,6 +34,8 @@