var share_win; function my_collect_init() { my_collect_list(); share_win = iframe_win_init({ container: "share_win", name: "share", width: "500px" }); collect_add_dlg_init("collect_add_div"); } function my_collect_list() { $.get( "../article/collect_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 += "
" + gLocal.gui.copy_link + "
"; html += "
" + gLocal.gui.edit + "
"; html += "
" + gLocal.gui.preview + "
"; html += "
"; html += "share"; html += "
"; html += "
"; } $("#article_list").html(html); } catch (e) { console.error(e); } } else { console.error("ajex error"); } } ); } var _arrArticleList; var _arrArticleOrder = new Array(); function my_collect_edit(id) { $.get( "../article/collect_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 += "
" + gLocal.gui.title + "
"; html += "
"; html += ""; html += "
"; html += "
"; html += "
" + gLocal.gui.sub_title + "
"; html += "
"; html += ""; html += "
"; html += "
"; html += "
" + gLocal.gui.summary + "
"; html += "
"; html += ""; html += "
"; html += "
"; html += "
" + gLocal.gui.status + "
"; html += "
"; html += render_status(result.status, false); html += "
"; html += "
"; html += "
" + gLocal.gui.language + "
"; html += "
"; html += ""; html += "
"; html += ""; html += "
"; html += "
"; html += "
"; _arrArticleList = JSON.parse(result.article_list); html += ""; html += "
"; html += "
"; html += "
"; html += "
"; html += "
"; $("#article_list").html(html); $("#collection_title").html(result.title); $("#ul_article_list").sortable({ update: function (event, ui) { let sortedIDs = $("#ul_article_list").sortable("toArray"); _arrArticleOrder = new Array(); for (const iSorted of sortedIDs) { let newindex = parseInt($("#" + iSorted).attr("article_index")); _arrArticleOrder.push(_arrArticleList[newindex]); } $("#form_article_list").val(JSON.stringify(_arrArticleOrder)); }, }); } catch (e) { console.error(e); } } else { console.error("ajex error"); } } ); } function my_collect_render_article(index, article) { let html = ""; html += "
  • "; html += ""; html += ""; html += ""; html += ""; html += ""; html += article.title; html += ""; html += ""; html += ""; html += "Preview"; html += ""; html += "
  • "; return html; } function article_preview(id) { $.get( "../article/get.php", { id: id, setting: "", }, function (data, status) { if (status == "success") { try { let html = ""; let result = JSON.parse(data); $("#preview_inner").html(note_init(result.content)); note_refresh_new(); } catch (e) { console.error(e.message); } } } ); } function my_collect_save() { $.ajax({ type: "POST", //方法类型 dataType: "json", //预期服务器返回的数据类型 url: "../article/my_collect_post.php", //url data: $("#collect_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 collection_share(id) { share_win.show("../share/share.php?id=" + id + "&type=4"); }