var _my_channal = null; var gChannelId; var get_channel_list_callback = null; channal_list(); var share_win; function channal_list_init() { my_channal_list(); share_win = iframe_win_init({ container: "share_win", name: "share", width: "500px" }); channal_add_dlg_init("channal_add_div"); } function channal_list() { $.post("../channal/get.php", {}, function (data) { try { _my_channal = JSON.parse(data); if (get_channel_list_callback) { get_channel_list_callback(); } } catch (e) { console.error(e); } }); } function channal_getById(id) { for (const iterator of _my_channal) { if (iterator.id == id) { return iterator; } } return false; } function my_channal_list() { $.get( "../channal/get.php", { setting: "", }, function (data, status) { if (status == "success") { try { let html = ""; let result = JSON.parse(data); let key = 1; //表头 html += '
'; html += '
'; html += "
No.
"; html += "
" + gLocal.gui.title + "
"; html += "
" + gLocal.gui.owner + "
"; html += "
" + gLocal.gui.privacy + "
"; html += "
" + gLocal.gui.permission + "
"; html += "
" + gLocal.gui.edit + "
"; html += "
" + gLocal.gui.collaborate + "
"; html += "
"; //列表 for (const iterator of result) { html += '
'; html += '
'; html += "
" + key++ + "
"; html += "
"; html += ""; html += iterator.name; html += ""; html += "
"; html += "
"; if (parseInt(iterator.power) == 30) { html += gLocal.gui.your; } else { html += ""; html += iterator.nickname; html += ""; } html += "
"; html += "
"; let arrStatus = [ { id: 0, string: gLocal.gui.disable }, { id: 10, string: "🔐"+gLocal.gui.private }, { id: 30, string: "🌐"+gLocal.gui.public }, ]; for (const status of arrStatus) { if (parseInt(iterator.status) == status.id) { html += status.string; } } //render_status(iterator.status) + html += "
"; switch (parseInt(iterator.power)) { case 10: html += "
"; html += gLocal.gui.read_only; html += "
"; html += "
"; html += "
"; html += "
"; html += "
"; break; case 20: html += "
"; html += gLocal.gui.write; html += "
"; html += "
"; html += "✏️" + gLocal.gui.edit + "
"; html += "
"; break; case 30: html += "
"; html += gLocal.gui.owner; html += "
"; html += "
"; html += "✏️" + gLocal.gui.edit + "
"; html += " 🔑"+gLocal.gui.share_to+""; html += "
"; break; default: break; } html += "
"; } $("#my_channal_list").html(html); guide_init(); } catch (e) { console.error(e); } } else { console.error("ajex error"); } } ); } function channel_share(id) { share_win.show("../share/share.php?id=" + id + "&type=2"); } /* 编辑channel信息 */ function my_channal_edit(id) { gChannelId = id; $.get( "../channal/my_channal_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 += '
'; html += "
" + gLocal.gui.title + "
"; html += "
"; html += ""; html += "
"; html += "
"; html += "
"; html += "
" + gLocal.gui.introduction + "
"; html += "
"; html += ""; html += "
"; html += "
"; html += '
'; html += '
' + gLocal.gui.language_select + "
"; html += '
'; html += ' '; html += "
"; html += "
"; html += '
'; html += '
' + gLocal.gui.privacy + "
"; html += '
'; let arrStatus = [ { id: 0, string: gLocal.gui.disable, note: gLocal.gui.disable_note }, { id: 10, string: gLocal.gui.private, note: gLocal.gui.private_note }, { id: 30, string: gLocal.gui.public, note: gLocal.gui.public_note }, ]; html += ""; html += "" + status_note + "[" + gLocal.gui.infomation + "]"; html += "
"; html += "
"; html += "
"; /* 旧的channel分享方式 删除 html += "
"; html += "

" + gLocal.gui.cooperators + "

"; html += ""; html += "
"; html += ""; html += "
"; html += "
"; if (typeof result.coop == "undefined" || result.coop.length == 0) { html += gLocal.gui.empty_null_mark; } else { for (const coop of result.coop) { html += '
'; if (coop.type == 0) { html += '
' + gLocal.gui.personal + "
"; html += "
" + coop.user_name.nickname + "
"; } else { html += '
' + gLocal.gui.group + "
"; html += "
" + coop.user_name.name + "
"; } html += "
" + coop.power + "
"; html += "
"; html += ""; html += "
"; html += "
"; } } html += "
"; html += "
"; */ $("#channal_info").html(html); user_select_dlg_init("add_coop_user_dlg"); tran_lang_select_init("channal_lang_select"); //$("#aritcle_status").html(render_status(result.status)); $("#channal_title").html(result.name); $("#preview_inner").html(); } catch (e) { console.error(e); } } else { console.error("ajex error"); } } ); } function add_coop_user() { user_select_dlg_show(); } function user_selected(id) { $.post( "../channal/coop_new_user.php", { userid: id, channel_id: gChannelId, }, function (data) { let error = JSON.parse(data); if (error.status == 0) { user_select_cancel(); alert("ok"); location.reload(); } else { alert(error.message); } } ); } function status_change(obj) { let arrStatus = [ { id: 0, string: gLocal.gui.disable, note: gLocal.gui.disable_note }, { id: 10, string: gLocal.gui.private, note: gLocal.gui.private_note }, { id: 30, string: gLocal.gui.public, note: gLocal.gui.public_note }, ]; let newStatus = $(obj).val(); for (const iterator of arrStatus) { if (parseInt(newStatus) == iterator.id) { $("#status_help").html(iterator.note); } } } function channal_lang_change() { let lang = $("#channal_lang_select").val(); if (lang.split("_").length == 3) { $("#channal_lang").val(lang.split("_")[2]); } else { $("#channal_lang").val(lang); } } function my_channal_save() { $.ajax({ type: "POST", //方法类型 dataType: "json", //预期服务器返回的数据类型 url: "../channal/my_channal_post.php", //url data: $("#channal_edit").serialize(), success: function (result) { console.log(result); //打印服务端返回的数据(调试用) if (result.status == 0) { alert("保存成功"); } else { alert("error:" + result.message); } }, error: function (data, status) { alert("异常!" + status + data.responseText); switch (status) { case "timeout": break; case "error": break; case "notmodified": break; case "parsererror": break; default: break; } }, }); }