var _my_channal = null;
var get_channel_list_callback = null;
channal_list();
function group_list_init() {
if (typeof gGroupId == "undefined") {
my_group_list();
group_add_dlg_init("group_add_div");
$("#button_new_group").show();
} else {
$("#button_new_sub_group").show();
group_list(gGroupId, gList);
team_add_dlg_init("sub_group_add_div");
$("#member_list_shell").css("visibility", "visible");
member_list(gGroupId);
//初始化用户选择对话框
user_select_dlg_init("user_select_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_group_list() {
$.get("../group/list.php", {}, function (data, status) {
if (status == "success") {
try {
let html = "";
let result = JSON.parse(data);
let key = 1;
if (result.length > 0) {
for (const iterator of result) {
html += '
';
html += "
" + key++ + "
";
html += "
" + iterator.group_name + "
";
html += "
";
if (iterator.power == 1) {
html += "拥有者";
}
html += "
";
html +=
"
";
html += "
";
}
} else {
html += "你没有加入任何工作组 现在 创建 你的工作组。";
}
$("#my_group_list").html(html);
} catch (e) {
console.error(e);
}
} else {
console.error("ajex error");
}
});
}
function group_list(id, list) {
$.get(
"../group/get.php",
{
id: id,
list: list,
},
function (data, status) {
if (status == "success") {
try {
let html = "";
let result = JSON.parse(data);
let key = 1;
html += "";
html += "
" + gLocal.gui.introduction + " ";
html += result.info.description;
html += "";
$("#curr_group").html("/ " + result.info.name + " ");
if (result.parent) {
$("#parent_group").html(
" / " +
result.parent.name +
" "
);
} else {
//子小组列表
html += "";
html += "
" + gLocal.gui.sub_group + " ";
if (result.children && result.children.length > 0) {
for (const iterator of result.children) {
html += '
';
html += "
" + key++ + "
";
html += "
" + iterator.name + "
";
html += "
";
if (iterator.power == 1) {
html += "拥有者";
}
html += "
";
html +=
"
";
html += "
";
}
} else {
html += "尚未设置小组";
}
html += "
";
}
//共享文件列表
key = 1;
html += "";
html += "
" + gLocal.gui.collaborate + " ";
if (result.file && result.file.length > 0) {
for (const iterator of result.file) {
html += '
';
html += "
" + key++ + "
";
html += "
" + iterator.title + "
";
html += "
";
switch (iterator.power) {
case 10:
html += gLocal.gui.read_only;
break;
case 20:
break;
case 30:
html += gLocal.gui.write;
break;
default:
break;
}
html += "
";
html +=
"
";
html += "
";
}
} else {
html += "没有共享文档 在译经楼中添加";
}
html += "
";
$("#my_group_list").html(html);
} catch (e) {
console.error(e);
}
} else {
console.error("ajex error");
}
}
);
}
function member_list(id) {
$.get(
"../group/list_member.php",
{
id: id,
},
function (data, status) {
if (status == "success") {
try {
let html = "";
let result = JSON.parse(data);
$("#member_number").html("(" + result.length + ")");
//子小组列表
html += "";
if (result && result.length > 0) {
for (const iterator of result) {
html += '
';
html += "
" + iterator.user_info.nickname + "
";
html += "
";
if (iterator.power == 1) {
html += "拥有者";
}
html += "
";
html += "
";
html += "
";
html += "
";
}
} else {
html += "这是一个安静的地方";
}
html += "
";
$("#member_list").html(html);
} catch (e) {
console.error(e);
}
} else {
console.error("ajex error");
}
}
);
}
/*
编辑channel信息
*/
function my_channal_edit(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 += "
" + 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 += "
";
let status_note = "";
for (const iterator of arrStatus) {
html += "" + iterator.string + " ";
}
html += " ";
html +=
"
" +
status_note +
" [" +
gLocal.gui.infomation +
"]";
html += " ";
html += "
";
html += "
";
html += "";
$("#channal_info").html(html);
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 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;
}
},
});
}