var _res_id;
var _res_type;
var gUserList = new Array();
function share_load(id, type) {
refresh_coop_list(id, type);
}
function refresh_coop_list(id, type) {
$.get(
"../share/coop_get.php",
{
res_id: id,
res_type: type,
},
function (data, status) {
if (status == "success") {
let result = JSON.parse(data);
$("#coop_list").html(render_coop_list(result));
}
}
);
}
function render_coop_list(cooplist) {
let html = "";
if (typeof cooplist == "undefined" || cooplist.length == 0) {
html += gLocal.gui.empty_null_mark;
} else {
for (const coop of cooplist) {
html += '
';
let username;
if (coop.cooperator_type == 0) {
username = coop.user.nickname;
html += '
';
html += "";
html += "
";
html += "
" + username + "
";
} else {
username = coop.user;
html += '
';
html += "";
html += "
";
html += "
";
if (coop.parent_name != "") {
html += coop.parent_name + "/";
}
html += username + "
";
}
html += "
";
let power = [
{ id: 10, string: "查看者" },
{ id: 20, string: "编辑者" },
];
html += "";
html += "
";
html += "
";
html +=
"";
html += "
";
html += "
";
}
}
return html;
}
function username_search_keyup(e, obj) {
var keynum;
if (window.event) {
// IE
keynum = e.keyCode;
} else if (e.which) {
// Netscape/Firefox/Opera
keynum = e.which;
}
var keychar = String.fromCharCode(keynum);
if (keynum == 13) {
} else {
if (obj.value.length > 0) {
let type = $("#user_type").val();
username_search(obj.value, type);
} else {
$("#user_search").html("");
}
}
}
function user_selected(id, name, type) {
if (parseInt(type) == 0) {
gUserList.push({ id: id, name: name, type: type });
$("#user_list").html(render_user_list());
$("#user_search").html("");
} else {
$.get("../group/get.php", { id: id }, function (data, status) {
if (status == "success") {
try {
let result = JSON.parse(data);
gUserList.push({ id: id, name: name, type: type, project: result.children });
$("#user_list").html(render_user_list());
$("#user_search").html("");
} catch (e) {}
}
});
}
}
function render_user_list() {
let html = "
";
let arrIndex = 0;
for (const iterator of gUserList) {
html += "
";
html += "";
if (iterator.type == 1) {
//小组
html += "👥";
} else {
html += "👤";
}
html += iterator.name;
html += "";
html += "删除";
html += "
";
arrIndex++;
}
html += "
";
return html;
}
//从候选列表中删除一个元素
function userlist_del(index) {
let deleted = gUserList.splice(index, 1);
$("#user_list").html(render_user_list());
if (gUserList.length == 0) {
$("#coop_new_tools").hide();
}
}
function username_search(keyword, type) {
//let obj = document.querySelector("#cooperator_type_user");
if (type == 1) {
$.get(
"../ucenter/get.php",
{
username: keyword,
},
function (data, status) {
let result;
try {
result = JSON.parse(data);
} catch (error) {
console(error);
}
let html = "
";
if (result.length > 0) {
$("#coop_new_tools").show();
for (const iterator of result) {
html +=
"