var my_file_title = "";
var my_file_status = "all"; //recycle
var my_file_order = "DESC"; //ASC
function file_search_keyup() {
file_list_refresh();
}
function recycleInit() {
ntf_init();
file_list_refresh();
}
function indexInit() {
ntf_init();
file_list_refresh();
}
function time_standardize(date) {
var today_date = new Date();
var Local_time = date.toLocaleTimeString();
//將時間去掉秒的信息
if (Local_time && Local_time.split(":").length == 3) {
var Local_time_string = Local_time.split(":")[0] + ":" + Local_time.split(":")[1];
Local_time_string += Local_time.split(":")[2].slice(2);
} else {
var Local_time_string = d.toLocaleTimeString();
}
if (date.toLocaleDateString() == today_date.toLocaleDateString()) {
//如果是今天的消息,只显示时间
return Local_time_string;
} else if (date.toLocaleDateString().slice(0, 5) == today_date.toLocaleDateString().slice(0, 5)) {
//如果是今年但非今天的消息,只显示月日
var date_length = date.toLocaleDateString().length;
return date.toLocaleDateString().slice(5, date_length);
} else {
//如果不是今年的消息,显示年月日
return date.toLocaleDateString();
}
}
//显示最近查看列表
function file_list_refresh() {
var d = new Date();
$.get(
"getfilelist.php",
{
t: d.getTime(),
keyword: my_file_title,
status: $("#id_index_status").val(),
orderby: "accese_time",
order: "DESC",
currLanguage: $("#id_language").val(),
},
function (data, status) {
try {
let file_list = JSON.parse(data);
let html = "";
for (x in file_list) {
html += '
';
html += '
';
html += "';
html += "';
html += "
";
html += '
";
html += '
';
if (
(file_list[x].parent_id && file_list[x].parent_id.length > 10) ||
parseInt(file_list[x].share) == 1
) {
html += "";
}
html += "
";
html += '
';
let d = new Date();
let today_date = d.toLocaleDateString();
d.setTime(file_list[x].accese_time);
let Local_time = "";
Local_time = time_standardize(d);
/*
if(d.getHours()<=9){
Local_time +=":0"+d.getHours();
}
else{
Local_time += ":"+d.getHours();
}
if(d.getMinutes()<=9){
Local_time +=":0"+d.getMinutes();
}
else{
Local_time += ":"+d.getMinutes();
}
let Local_date = d.toLocaleDateString();
if(today_date==Local_date){
html += gLocal.gui.today+Local_time;
}
else{
html += Local_date;
}
*/
html += Local_time;
html += "
";
html += '
';
if (file_list[x].file_size < 102) {
$str_size = file_list[x].file_size + "B";
} else if (file_list[x].file_size < 1024 * 902) {
$str_size = (file_list[x].file_size / 1024).toFixed(0) + "KB";
} else {
$str_size = (file_list[x].file_size / (1024 * 1024)).toFixed(1) + "MB";
}
html += $str_size;
if (!(file_list[x].doc_info && file_list[x].doc_info.length > 1)) {
html +=
"
转数据库格式";
}
html += "
";
html += "
";
html += '
';
html += '' + gLocal.gui.copy_share_link + "";
html +=
"";
html += " ";
html += "
";
html += "
";
}
html += "";
$("#userfilelist").html(html);
} catch (e) {
console.error(e.message);
}
}
);
}
function showUserFilaList() {
file_list_refresh();
}
function title_change(id, title) {
let newTitle = prompt("新的标题", title);
if (newTitle) {
_doc_info_title_change(id, newTitle, function (data, status) {
let result = JSON.parse(data);
if (result.error == false) {
$("#title_" + id).text(newTitle);
} else {
alert(result.message);
}
});
}
}
function share_link_copy_to_clipboard(id) {
let host = location.protocol + '//' + location.host;
copy_to_clipboard(host+"/app/studio/project.php?op=open&doc_id=" + id);
}
function mydoc_file_select(doSelect) {
if (doSelect) {
$("#file_tools").show();
$("#file_filter").hide();
$(".file_select_checkbox").show();
$(".file_select_checkbox").css("display", "inline-block");
if ($("#id_index_status").val() == "recycle") {
$("#button_group_recycle").show();
$("#button_group_nomal").hide();
} else {
$("#button_group_recycle").hide();
$("#button_group_nomal").show();
}
} else {
$("#file_tools").hide();
$("#file_filter").show();
$(".file_select_checkbox").hide();
}
}
function file_del() {
var file_list = new Array();
var file_count = $("#file_count").val();
for (var i = 0; i < file_count; i++) {
if (document.getElementById("file_check_" + i).checked) {
file_list.push($("#file_id_" + i).val());
}
}
if (file_list.length > 0) {
$.post(
"./file_index.php",
{
op: "delete",
file: file_list.join(),
},
function (data, status) {
ntf_show(data);
file_list_refresh();
}
);
}
}
//彻底删除
function file_remove() {
var file_list = new Array();
var file_count = $("#file_count").val();
for (var i = 0; i < file_count; i++) {
if (document.getElementById("file_check_" + i).checked) {
file_list.push($("#file_id_" + i).val());
}
}
if (file_list.length > 0) {
$.post(
"./file_index.php",
{
op: "remove",
file: file_list.join(),
},
function (data, status) {
ntf_show(data);
file_list_refresh();
}
);
}
}
//从回收站中恢复
function file_restore() {
var file_list = new Array();
var file_count = $("#file_count").val();
for (var i = 0; i < file_count; i++) {
if (document.getElementById("file_check_" + i).checked) {
file_list.push($("#file_id_" + i).val());
}
}
if (file_list.length > 0) {
$.post(
"./file_index.php",
{
op: "restore",
file: file_list.join(),
},
function (data, status) {
ntf_show(data);
file_list_refresh();
}
);
}
}
function file_share(isShare) {
var file_list = new Array();
var file_count = $("#file_count").val();
for (var i = 0; i < file_count; i++) {
if (document.getElementById("file_check_" + i).checked) {
file_list.push($("#file_id_" + i).val());
}
}
if (file_list.length > 0) {
if (isShare) {
var share = 1;
} else {
var share = 0;
}
$.post(
"./file_index.php",
{
op: "share",
share: share,
file: file_list.join(),
},
function (data, status) {
alert(data);
//mydoc_file_select(false);
file_list_refresh();
}
);
}
}
function file_show_coop_win(doc_id) {
let xFileHead = document.getElementById("coop_show_" + doc_id);
let xCoopWin = document.getElementById("rs_doc_coop_win");
xFileHead.appendChild(xCoopWin);
coop_init(doc_id, "rs_doc_coop_win_inner");
coop_list();
}
function file_coop_win_close() {
let xShell = document.getElementById("rs_doc_coop_shell");
let xCoopWin = document.getElementById("rs_doc_coop_win");
xShell.appendChild(xCoopWin);
}