var _display = "para"; function my_article_init() { my_article_list(); article_add_dlg_init("article_add_div"); } function my_article_list() { $.get( "../article/list.php", { userid: getCookie("userid"), setting: "", }, function (data, status) { if (status == "success") { try { let html = ""; let result = JSON.parse(data); let key = 1; for (const iterator of result) { html += '
'; html += '
'; html += "
" + key++ + "
"; html += "
" + iterator.title + "
"; html += "
" + render_status(iterator.status) + "
"; html += "
Copy Link
"; html += "
Edit
"; html += "
Preview
"; html += "
15
"; html += "
"; } $("#article_list").html(html); } catch (e) { console.error(e); } } else { console.error("ajex error"); } } ); } function render_status(status) { status = parseInt(status); let html = ""; let objStatus = [ { id: 1, name: "私有", tip: "仅自己可见" }, { id: 2, name: "不公开列出", tip: "不能被搜索到,只能通过链接访问" }, { id: 3, name: "公开", tip: "所有人均可看到" }, ]; html += '
'; html += ''; for (const iterator of objStatus) { if (iterator.id == status) { html += "
" + iterator.name + "
"; } } html += '
'; for (const iterator of objStatus) { let active = ""; if (iterator.id == status) { active = "active"; } html += ""; html += "
" + iterator.name + "
"; html += "
" + iterator.tip + "
"; html += "
"; } html += "
"; return html; } function my_article_edit(id) { $.get( "../article/get.php", { id: id, setting: "", }, function (data, status) { if (status == "success") { try { let html = ""; let result = JSON.parse(data); $("#article_collect").attr("a_id", result.id); html += '
'; html += '
'; html += ""; html += ""; html += ""; html += ""; html += ""; html += "Import Data"; html += "
"; html += "
"; html += "
"; html += ""; html += "
"; html += "
"; html += "
"; html += "
"; html += "
"; $("#article_list").html(html); $("#aritcle_status").html(render_status(result.status)); let html_title = ""; $("#article_title").html(html_title); $("#preview_inner").html(note_init(result.content)); note_refresh_new(); add_to_collect_dlg_init(); } catch (e) { console.error(e); } } else { console.error("ajex error"); } } ); } function article_preview() { $("#preview_inner").html(note_init($("#article_content").val())); note_refresh_new(); } function my_article_save() { $.ajax({ type: "POST", //方法类型 dataType: "json", //预期服务器返回的数据类型 url: "../article/my_article_post.php", //url data: $("#article_edit").serialize(), success: function (result) { console.log(result); //打印服务端返回的数据(调试用) if (result.status == 0) { alert("保存成功"); } else { alert("error:" + result.message); } }, error: function (data, status) { alert("异常!" + data.responseText); switch (status) { case "timeout": break; case "error": break; case "notmodified": break; case "parsererror": break; default: break; } }, }); } function course_validate_required(field, alerttxt) { with (field) { if (value == null || value == "") { alert(alerttxt); return false; } else { return true; } } } function course_validate_form(thisform) { with (thisform) { if (course_validate_required(title, "Title must be filled out!") == false) { title.focus(); return false; } } }