var _display = "para";
var share_win;
function my_article_init() {
my_article_list();
share_win = iframe_win_init({ container: "share_win", name: "share", width: "500px" });
article_add_dlg_init("article_add_div");
}
function my_article_list() {
$.get(
"../article/list.php",
{
userid: getCookie("userid"),
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.privacy + "
";
html += "
" + gLocal.gui.preview + "
";
html += "
" + gLocal.gui.copy_to_clipboard + "
";
html += "
" + gLocal.gui.share_to + "
";
html += "
";
//列表
for (const iterator of result) {
html += '
";
return html;
}
function setStatus(obj) {}
function my_article_edit(id) {
$.get(
"../article/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.import +
gLocal.gui.text;
html += "
";
html += "
";
html += "
";
html += "" + gLocal.gui.title + "";
html += '';
html += "
";
html += "
";
html += "" + gLocal.gui.sub_title + "";
html += '';
if(!result.subtitle){
result.subtitle="";
}
html += ''
html += '';
html += "
";
html += "";
html += "
";
html += "" + gLocal.gui.status + "";
html += '';
let lang;
if(typeof result.lang == "undefined"){
lang = "en";
}else{
lang = result.lang;
}
//html += '
';
html +=
'' +
gLocal.gui.language_select +
'';
html +='';
html +=' ';
//html +='
';
html += "
";
html += "
";
html += "" + gLocal.gui.introduction + "";
html += "
";
html += "
";
html += "
";
html +=
"";
html += "
";
html += "
";
html += "";
html += "
";
html += "
";
$("#article_list").html(html);
channal_select_init("channal_selector");
tran_lang_select_init("article_lang_select");
$("#aritcle_status").html(render_status(result.status, false));
let html_title =
"";
$("#article_title").html(html_title);
$("#preview_inner").html(note_init(result.content));
note_refresh_new();
add_to_collect_dlg_init();
} catch (e) {
console.error(e);
}
} else {
console.error("ajex error");
}
}
);
}
function article_lang_change() {
let lang = $("#article_lang_select").val();
if (lang.split("_").length == 3) {
$("#article_lang").val(lang.split("_")[2]);
} else {
$("#article_lang").val(lang);
}
}
function article_preview() {
$("#preview_inner").html(note_init($("#article_content").val()));
note_refresh_new();
}
function my_article_custom_book() {
$content = $("#article_content").val();
if ($content == "") {
alert("内容不能为空");
return;
}
if ($content.indexOf("{{") >= 0) {
alert("不能包含句子模版");
return;
}
if (confirm("将此文档转换为自定义书模版吗?") == true) {
document.querySelector("#import_custom_book").checked = true;
my_article_save();
}
}
function my_article_save() {
$.ajax({
type: "POST", //方法类型
dataType: "json", //预期服务器返回的数据类型
url: "../article/my_article_post.php", //url
data: $("#article_edit").serialize(),
success: function (result) {
console.log(result); //打印服务端返回的数据(调试用)
if (result.status == 0) {
alert(gLocal.gui.saved + gLocal.gui.successful);
window.location.reload();
} else {
alert("error:" + result.message);
}
},
error: function (data, status) {
alert("异常!" + data.responseText);
switch (status) {
case "timeout":
break;
case "error":
break;
case "notmodified":
break;
case "parsererror":
break;
default:
break;
}
},
});
}
function course_validate_required(field, alerttxt) {
with (field) {
if (value == null || value == "") {
alert(alerttxt);
return false;
} else {
return true;
}
}
}
function course_validate_form(thisform) {
with (thisform) {
if (course_validate_required(title, gLocal.gui.title_necessary + "!") == false) {
title.focus();
return false;
}
}
}