var is_login, is_commented, ue, article_status, timestamp_version, learn, videolearn, videoHtml, isPostLevelUser,WorkArticleId, BlogArticleId, BlogArticleSetIt,isSpaceExe,forget_pop,timeOut =0,autoTimer,countTime=0;
$(function() {
layui.use(["layer", "form", "element", "util"],function() {
form = layui.form;layer = layui.layer;element = layui.element;util = layui.util;util.fixbar({top: true});
$(document).on("api.loginpopbox",function(e, callback) {
layer.open({
type: 2,
title: false,
shadeClose: false,
closeBtn: true,
shade: 0.5,
area: ["430px", "510px"],
content: "/account/login.html",
cancel: function (i, l) {parent.window.location.reload();}
});
});
$(document).on("click", ".rlf-forget",function() {
parent.forget_pop = parent.layer.open({
type: 2,
title: false,
shadeClose: false,
closeBtn: true,
shade: 0.5,
area: ["430px", "510px"],
content: "/account/forgot.html"
});
});
$('.dZhmmLink a').click(function(){
parent.layer.close(parent.forget_pop);
});
$("#login,#reg").click(function() {
$(document).trigger("api.loginpopbox")
});
$("#category_gd").on("click",function() {
var catStr = "";
catStr += '
HTML5CSS3jQueryReactAngularJSAJAXBootstrapFoundationPythonGOJavaCC++C#JSPDjangoASP.NETASPXMLRubyPerlServletLuaScalaVBScriptMySQLRedisOracleMongoDBMemcachedSQL ServerFlutterAndroidIOSSwift其他LinuxDockerphpstudyGit其它工具AxurePSHTTPTCP/IP编程基础';
if ($("#course_all").is(".catStr")) {
$(".category_li").remove();
$(".category_gd_a").html('更多 ');
$("#course_all").removeClass("catStr")
} else {
$("#category_gd").before(catStr);
$(".category_gd_a").html('收起 ');
$("#course_all").addClass("catStr")
}
});
$('.category-list-second').hover(function(){
var catStr = "";
catStr += 'HTML5CSS3jQueryReactAngularJSAJAXBootstrapFoundationPythonGOJavaCC++C#JSPDjangoASP.NETASPXMLRubyPerlServletLuaScalaVBScriptMySQLRedisOracleMongoDBMemcachedSQL ServerFlutterAndroidIOSSwift其他LinuxDockerphpstudyGit其它工具AxurePSHTTPTCP/IP编程基础';
$("#category_gd").before(catStr);
$(".category_gd_a").html('收起 ');
$("#course_all").addClass("catStr")
},function(){
$(".category_li").remove();
$(".category_gd_a").html('更多 ');
$("#course_all").removeClass("catStr")
});
var currentfid = $(".category-list-first li.diy-scurse-li-bg").data("id");
var sub_on = $(".category-list-second li.diy-scurse-li-bg");
if (sub_on.length > 0) {
currentfid = sub_on.data("fid");
$(".category-list-first li[data-id='" + currentfid + "']").addClass("diy-scurse-li-bg")
} else {
$(".category-list-second li:first").addClass("diy-scurse-li-bg")
}
$(".sub_all").click(function() {
$(".category-list-first li").each(function(i) {
if (i > 0 && $(this).is(".diy-scurse-li-bg")) {
location.href = $(".category-list-first .diy-scurse-li-bg").find("a").attr("href")
} else {
if (i < 2 && $(this).is(".diy-scurse-li-bg")) {
location.href = "/course.html"
}
}
})
});
$(".ask-comment-answer").click(function() {
if ($(".php-user #login").length > 0) {
$("#login").trigger("click")
} else {
var that = $("#commentinput");
if (that.is(".layui-hide-sm")) {
that.removeClass("layui-hide-sm");
ue = getue_config("js-reply-editor-box")
} else {
that.addClass("layui-hide-sm")
}
}
});
$(document).on("click", "#js-wenda-ci-submit:not(.running)",function() {
var that = $(this),
uecontent = ue.getContent();
var reg = new RegExp("[\\u4e00-\\u9fa5]+", "g");
if (uecontent == "" || !reg.test(uecontent)) {
layer.msg("内容不可纯英文");return false;
}
that.addClass("running").html("回复中...");
$.post("/wenda/reply.html", {ask_id: that.data("qid"),reply_content: uecontent},function(result) {
if (result.status == 1) {
if (result.xuefen == 1) {
layer.alert('回复成功,获取10个学分 更多学分获取方式', {
title: "回复提示",icon: 1,closeBtn: 0,skin: "layui-layer-molv",anim: 4
})
} else {
layer.msg(result.msg, {time: 2000,skin: "layui-layer-molv",icon: 1})
}
that.removeClass("running").html("回复");
reply_data(result.uid, result.avatar, result.nickname, result.floor, result.content, result.ask_id, result.answer_id, result.add_time, result.answer_count)
} else {
layer.msg(result.msg, {icon: 2},function() {
if (result.msg == "绑定手机后即可回复") {
layer.open({type: 2,title: "系统检测到您未绑定手机,绑定后不再弹出",shade: 0.3,area: ["400px", "350px"],content: "/user/bind_phone.html"})
}
});
that.removeClass("running").html("回复")
}
})
});
function reply_data(u, i, n, l, c, ai, an, tm, ac) {
if ($(".no-data-tips").length > 0) {
$(".no-data-tips").hide()
}
var reply_str = '';
$(".ask-reply-all-list").prepend(reply_str);
ue.setContent("");
$(".wrap.layui-clear .master span").html(" (" + ac + ")")
}
$(document).on("click", ".ask-reply-all-list.comments-content .reply",function() {
if ($(this).is(".is_open")) {
$(this).removeClass("is_open");
$(this).parents(".ask_top_ul").find(".release-reply-con").hide()
$(this).parents(".ask_top_ul").find(".wdcdContentReplyss").hide()
} else {
$(this).addClass("is_open");
$(this).parents(".ask_top_ul").find(".release-reply-con").show()
$(this).parents(".ask_top_ul").find(".wdcdContentReplyss").show()
}
});
$(document).on("click", ".php-comment-list.comments-content .course_reply",function() {
if ($(this).is(".is_open")) {
$(this).removeClass("is_open");
$(this).parents(".php-comment-list").find(".release-reply-con").hide()
} else {
$(this).addClass("is_open");
$(this).parents(".php-comment-list").find(".release-reply-con").show()
}
});
$(document).on("click", ".reply-list .reply-item .reply-btn",function() {
$(this).parents(".layui-clear.ask_top_ul").find(".reply").trigger("click")
});
$(document).on("click", ".do-reply-btn:not('.running')",function() {
if ($("#login").length > 0) {
$(document).trigger("api.loginpopbox");
return false
}
var that = $(this);
var id = that.data("id");
// var content = that.prev(".textarea-con").find("#release-reply").val();
var content = $("#release-reply").val();
var reg = new RegExp("[\\u4e00-\\u9fa5]+", "g");
if (content == "" || !reg.test(content)) {
layer.msg("内容不可为纯英文", {icon: 2});
return false
}
that.addClass("running");
$.post("/wenda/reply_answer.html", {id: id,content: content},function(result) {
if (result.code == 1) {
layer.msg(result.msg, {icon: 1},function() {
that.prev(".textarea-con").find("#release-reply").val("");
var answer_str = '';
that.parents(".release-reply-con").before(answer_str);
$(".wrap.layui-clear .master span").html(" (" + result.a + ")");
that.removeClass("running")
})
} else {
layer.msg(result.msg, {
icon: 2
});
that.removeClass("running")
}
})
});
$(document).on("click", '.second-reply-btn:not(".running")',function() {
if ($("#login").length > 0) {
$(document).trigger("api.loginpopbox");return false
}
var that = $(this);
var id = that.data("id");
var content = that.prev(".textarea-con").find("#release-reply").val();
var reg = new RegExp("[\\u4e00-\\u9fa5]+", "g");
if (content == "" || !reg.test(content)) {
layer.msg("内容不可为纯英文", {icon: 2});return false
}
that.addClass("running");
$.post("/course/add_comment.html", {
id: id,
content: content,
learn: learn
},function(result) {
if (result.status == 1) {
layer.msg(result.msg, {icon: 1},function() {
that.prev(".textarea-con").find("#release-reply").val("");
that.parents(".php-comment-list").find(".course_reply").trigger("click");
var course_reply_str = '' + result.comment_ajax.content + '
';
that.parents(".release-reply-con").before(course_reply_str);
that.removeClass("running")
});
is_commented = 1
} else {
layer.msg(result.msg, {icon: 2});
that.removeClass("running")
}
})
});
$(".vodeo-lists-list .chapter-list").click(function() {
var that = $(this).next(".video");
if (that.is(".layui-hide-sm")) {
$(".vodeo-lists-list .video").addClass("layui-hide-sm");
that.removeClass("layui-hide-sm")
} else {
that.addClass("layui-hide-sm")
}
});
try {
if (top.location.hostname != window.location.hostname) {
layer.msg("非法接入,正在为您跳转...", {icon: 2},function() {
try {
window.top.location.href = window.location
} catch(e) {
window.location.href = "https://www.php.cn"
}
})
}
} catch(e) {
layer.msg("非法接入,正在为您跳转...", {icon: 2},function() {
try {
window.top.location.href = window.location
} catch(e) {
window.location.href = "https://www.php.cn"
}
})
}
$(".op.chapter").click(function() {
if ($(this).hasClass("light")) {
$(this).removeClass("light");
$(".section-list").css("right", "-400px")
} else {
$(this).addClass("light");
$(".section-list").css("right", "0px")
}
});
$(".op.question").click(function() {
if ($("#login").length > 0) {
$("#login").trigger("click");return false
}
$(".phpcn-modal-layer .phpcn-modal-title span").html("提问");
$(".phpcn-modal-dialog").html($("#askTpl").html());
$(".phpcn-modal-layer").css({left: ($(window).width() - 654) / 2 + "px", "top": ($(window).height() - 264) / 2 + "px"}).show();
if (ue) {
ue.destroy();ue = null
}
ue = UE.getEditor("container", {
toolbars: [["insertcode", "Bold", "italic", "underline", "snapscreen", "simpleupload", "spechars", "blockquote", "link", "unlink"]],
wordCount: false,
elementPathEnabled: false,
pasteplain: true,
enableContextMenu: false,
allowDivTransToP: false,
initialFrameWidth: 588,
initialFrameHeight: 150,
iframeCssUrl: "/static/ueditor/plugin/js/user_code.css"
})
isSpaceExe = false;
});
$(".op.code_down").click(function() {
if ($("#login").length > 0) {
$("#login").trigger("click");return false
}
$("#code_down_li").trigger("click")
});
var isPostAsk = false;
$(document).on("click", "#js-discuss-submit",function() {
var title = $("#js-qa-title").val();
var content = ue.getContent();
var verify = $(".verify-code-ipt").val();
var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g");
if (!reg.test(content)) {
layer.msg("内容不可为纯英文", {icon: 2});return false
}
if (!new RegExp("[\\u4E00-\\u9FFF]+", "g").test(title)) {
layer.msg("标题不可为纯英文", {icon: 2});return false
}
if (verify == "") {
layer.msg("验证码不能为空", {icon: 2});return false
}
if (isPostAsk == true) {return false}
isPostAsk = true;
$.post("/course/add_wenda.html", {learn: learn,title: title,content: content,verify: verify},function(result) {
if (result.status == 1) {
layer.msg(result.msg, { icon: 1});
$(".js-modal-close").trigger("click");
var data = result.ask_ajax;
var ask_ajax = '';
$(".layui-tab-content .course-code-wenda-inner").prepend(ask_ajax)
} else {
layer.msg(result.msg, {icon: 2});isPostAsk = false
}
})
});
if ($(".php-ask").length > 0) {
$.getScript("/static/js/jQuery.autoIMG.min.js",function() {
$(".php-ask").autoIMG()
});
$(".php-ask .ask_accept").click(function() {
var id = $(this).data("id");
var id1 = $(this).data("id1");
$.post("/wenda/accept.html", {id: id,id1: id1},function(result) {
if (result.code == 1) {
layer.msg(result.msg, {icon: 1},function() {window.location.reload()})
} else {
layer.msg(result.msg, {icon: 2})
}
})
})
}
$(".course_manual_lists").click(function() {
$(".course_manual_lists_second").hide();
$(this).parents(".site-tree-noicon").siblings().removeClass("is_show");
$(".site-tree-noicon").find("em.course_manual_lists").html("展开");
$(".site-tree-noicon").find("i.course_manual_lists").addClass("layui-icon-triangle-r").removeClass("layui-icon-triangle-d");
if ($(this).parents(".site-tree-noicon").is(".is_show")) {
$(this).parents(".site-tree-noicon").removeClass("is_show")
} else {
$(this).parents(".site-tree-noicon").find(".course_manual_lists_second").show();
$(this).parents(".site-tree-noicon").find("em.course_manual_lists").html("收起");
$(this).parents(".site-tree-noicon").find("i.course_manual_lists").addClass("layui-icon-triangle-d").removeClass("layui-icon-triangle-r");
$(this).parents(".site-tree-noicon").addClass("is_show")
}
});
$(".course_manual_index").css("min-height", $(window).height() - $(".header-index").height() - $(".footer_top_margin").height() - 50);
$(".op.notes").click(function() {
// if ($("#login").length > 0) {
// $("#login").trigger("click");return false;
// }
$(".phpcn-modal-layer .phpcn-modal-title span").html("笔记");
$(".phpcn-modal-dialog").html($("#noteTpl").html());
$(".phpcn-modal-layer").css({
left: ($(window).width() - 654) / 2 + "px",
"top": ($(window).height() - 264) / 2 + "px"
}).show();
isSpaceExe = false;
});
$(".js-modal-close").on("click", function() {
$(".phpcn-modal-layer").hide();isSpaceExe=true;
});
$("#js-note-textarea").on("keyup", function() {
$("#js-note-limit").html($("#js-note-textarea").text().length);
if ($("#js-note-textarea").text().length > 1000) {
$("#js-note-limit").addClass("limit-overflow");
$("#js-note-input-fake").addClass("ipt-fake-error")
} else {
$("#js-note-limit").removeClass("limit-overflow");
$("#js-note-input-fake").removeClass("ipt-fake-error")
}
}).on("focus", function() {
$("#js-note-input-fake").addClass("ipt-fake-focus")
}).on("blur", function() {
$("#js-note-input-fake").removeClass("ipt-fake-focus")
});
var isPostNote = false;
$(document).on("click", "#js-note-submit", function() {
var bijicontent = $("#js-note-textarea").val()
// var bijicontent = ue.getContent();
if ($("#js-note-limit").hasClass("limit-overflow")) {
msgshow("最长能输入1000字", "false");return false
}
if (bijicontent.length<=0) {
msgshow("请输入内容", "false");return false
}
if (isPostNote == true) {return false}
isPostNote = true;
$.post("/course/add_note.html", {learn: learn,content: bijicontent}, function(result) {
if (result.status == 1) {
layer.msg(result.msg, {icon: 1});
$(".js-modal-close").trigger("click");
var data = result.note_ajax;
var comment_ajax = '';
$(".note-add").after(comment_ajax);
window.location.reload();
} else {
layer.msg(result.msg, {icon: 2});isPostNote = false
}
})
});
$(document).on("click", ".course-code-comment-submit:not('.running')", function() {
var that = $(this);
var content = $(".php-comment .course-media-code-comment textarea").val();
var postdata = {"learn": learn, "content": content};
var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g");
if (!reg.test($.trim(content)) || content.length < 10) {
layer.msg("内容不能是纯英文或数字,且10个字以上", {icon: 2});return false
}
that.addClass("running");
$.ajax({
url: "/course/add_comment.html",
data: postdata,
type: "post",
cache: false,
dataType: "json",
success: function(result) {
if (result.status == 1) {
layer.msg(result.msg, {icon: 1});
var data = result.comment_ajax;
var comment_ajax = '';
$(".course-media-code-comment").after(comment_ajax);
$(".php-comment .course-media-code-comment textarea").val("");
that.removeClass("running");
is_commented = 1
} else {
layer.msg(result.msg, {icon: 2});that.removeClass("running")
}
},
error: function() {
layer.msg("评论失败", {icon: 2});running = false;that.removeClass("running")
}
})
});
$(document).on("click", ".php-comment-list .course-code-comment-good", function() {
var that = $(this);
var id = that.data("comment_id");
$.post("/course/comment_good.html", {id: id}, function(result) {
if (result.status == 1) {
layer.msg(result.msg, {icon: 1});
that.find("span").html(parseInt(that.find("span").html()) + 1)
} else {
layer.msg(result.msg, {icon: 2})
}
})
});
$(document).on("click", ".comment-info .course-code-note-good", function() {
var that = $(this);
var id = that.data("note_id");
$.post("/course/note_good.html", {id: id}, function(result) {
if (result.status == 1) {
layer.msg(result.msg, {icon: 1});
that.find("span").html(parseInt(that.find("span").html()) + 1)
} else {
layer.msg(result.msg, {icon: 2})
}
})
});
if ($(".js-editor-tab .editor-view .ui-tabs-active").length > 0) {
iframe_set();
code = $("#editor-tabs-html").html();
code = code.replace(/</g, "<");
code = code.replace(/>/g, ">");
editor = ace.edit("editor-tabs-html");
editor.setTheme("ace/theme/vibrant_ink");
editor.getSession().setUseWrapMode(true);
editor.getSession().setMode("ace/mode/php");
editor.setShowPrintMargin(false);
var ifr;
var initresultbox = function() {
ifr = document.createElement("iframe");
ifr.setAttribute("frameborder", "0");
ifr.setAttribute("id", "iframeResult");
document.getElementById("viewPort-content").innerHTML = "";
document.getElementById("viewPort-content").appendChild(ifr);
$("#iframeResult").css({"width": "100%","height": "99%"})
};
initresultbox();
$("#J_EditorReset").click(function() {
editor.getSession().setValue(code);
$("#J_Commit").trigger("click")
});
$("#J_Commit").click(function() {
tmp_code = editor.getSession().getValue();
if (tmp_code.indexOf("= 0 && tmp_code.indexOf("?>") < 0) {
tmp_code += "?>"
}
if (tmp_code.indexOf("
' + data.nickname + "
" + data.content + '
' + data.add_time + ' 0