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 {
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 += "
";
switch (parseInt(iterator.power)) {
case 0:
html += gLocal.gui.owner;
break;
case 1:
html += gLocal.gui.manager;
break;
case 2:
html += gLocal.gui.member;
break;
default:
break;
}
html += "
";
if (result.file && result.file.length > 0) {
for (const iterator of result.file) {
html += '
';
html += "
" + key+ "
";
html += "
";
//资源类型
html += "";
html += "
";
html += "
";
html += viewLink+iterator.res_title+"" ;
html += "";
html += "
";
html += "
";
switch (parseInt(iterator.power)) {
case 10:
html += gLocal.gui.read_only;
break;
case 20:
html += gLocal.gui.write;
break;
case 30:
break;
default:
break;
}
html += "
";
html += "
";
//可用的操作
html += doing;
html += "
";
html += "
";
}
} else {
html += "没有共享文档 在译经楼中添加";
}
html += "
";
$("#my_group_list").html(html);
guide_init();
} 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 += "
";
//if (iterator.owner == getCookie("userid"))
{
html +=
"";
}
html += "
";
html += "
";
}
} else {
html += "这是一个安静的地方";
}
html += "
";
$("#member_list").html(html);
} catch (e) {
console.error(e);
}
} else {
console.error("ajex error");
}
}
);
}
function user_selected(id) {
$.post(
"../group/member_put.php",
{
userid: id,
groupid: gGroupId,
},
function (data) {
let error = JSON.parse(data);
if (error.status == 0) {
user_select_cancel();
alert("ok");
location.reload();
} else {
user_select_cancel();
alert(error.message);
}
}
);
}
function user_select_new() {
$.post(
"../group/my_group_put.php",
{
name: $("#user_select_title").val(),
parent: parentid,
},
function (data) {
let error = JSON.parse(data);
if (error.status == 0) {
alert("ok");
user_select_cancel();
location.reload();
} else {
alert(error.message);
}
}
);
}
function group_del(group_id) {
if (
confirm(
"此操作将删除组/项目。\n以及切断分享到此组/项目文件的链接。\n但是不会删除该文件。\n此操作不能恢复。仍然要删除吗!"
)
) {
$.post(
"../group/group_del.php",
{
groupid: group_id,
},
function (data) {
let error = JSON.parse(data);
if (error.status == 0) {
alert("ok");
location.reload();
} else {
alert(error.message);
}
}
);
}
}
function member_del(group_id, user_id) {
if (confirm("此操作将移除成员。\n此操作不能恢复。仍然要移除吗!")) {
$.post(
"../group/member_del.php",
{
groupid: group_id,
userid: user_id,
},
function (data) {
let error = JSON.parse(data);
if (error.status == 0) {
alert("ok");
location.reload();
} else {
alert(error.message);
}
}
);
}
}