<script type="text/javascript">
/** 创建笔记基础 **/
function createNote0(title, type) {
    xnote.prompt(title, "", function (noteTitle) {
        var createOption = {};
        createOption.name = noteTitle;
        createOption.parent_id = "{{parent_id}}";
        createOption.type = type;
        createOption._format = "json";
        xnote.http.post("/note/create", createOption, function (resp) {
            if (resp.code == "success") {
                window.location.href = resp.url;
            } else {
                xnote.alert(title + "失败:" + resp.message);
            }
        });
    });
}

/** 创建相册 **/
function createGallery() {
    createNote0("新建相册", "gallery");
}

/** 新建文档 **/
function createDocument() {
    createNote0("新建文档", "md");
}

/** 创建清单 **/
function createList() {
    createNote0("新建清单", "list");
}

/** 创建表格 **/
function createTable() {
    createNote0("新建表格", "csv");
}

/** 创建记事 **/
function createLog() {
    window.location.href = "/note/add?type=log&parent_id={{parent_id}}";
}

function createLogOld() {
    var title = "创建日志";
    var createOption = {};
    createOption.parent_id = "{{parent_id}}";
    createOption.type = "text";
    createOption._format = "json";

    xnote.http.post("/note/create", createOption, function (resp) {
        if (resp.code == "success") {
            window.location.href = resp.url;
        } else {
            xnote.alert(title + "失败:" + resp.message);
        }
    });
}


/** 上传文件 **/
function uploadFile() {

}

xnote.note.defaultParentId = "{{parent_id}}";

</script>
