var urlPapers = "https://localhost:8443/api/1.0/papers";
var urlPaperStatuses = "https://localhost:8443/api/1.0/papers/statuses";

function showPapers(papersElement) {
    getFromRest(urlPapers, function (paperList) {
        paperList.forEach(function (paper, index) {
            $(papersElement).parent().append("<div class='row text-left'>" +
                "                <div class='col-md-12'>" +
                "                <span class='fa-stack fa-1x'>\n" +
                "                  <i class='fa fa-circle fa-stack-2x " + getPaperStatusClass(paper.status) + "'></i>" +
                "                  <i class='fa fa-file-text-o fa-stack-1x fa-inverse'></i>" +
                "                </span>" +
                "                    <a href='paper.html?id=" + paper.id + "" +
                "'><span>" + paper.title + "</span></a>" +
                "                </div></div>");
        });
    });
}

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);
    });
}

function getPaperStatusClass(status) {
    switch (status) {
        case 'DRAFT':
            return "text-draft"
        case 'ON_PREPARATION':
            return "text-primary";
        case 'COMPLETED':
            return "text-success";
        case 'ATTENTION':
            return "text-warning";
        default:
            return "";
    }
}