Namespace.register("U.MD.D.PB.Pa"); //板块处理 //#region 获取板块信息 //#endregion //#region 搜索板块 //出现搜索 U.MD.D.PB.Pa.BKSSBK = function (UDOD, UTF) { var _UDAD = $(UDOD).Child(), _UDID = $("input", UDOD)[1]; if (UTF[1] == "block" || _UDID.value == "") { _UDAD[0].style.display = UTF[0]; _UDAD[1].style.display = UTF[1]; if (UTF[1] == "block") { $("input", _UDAD[1])[0].focus() }; } } //版块内的搜索 U.MD.D.PB.Pa.BSBKSSBKO = function (UDOD) { var _UDTD = $("#UD_SYSXZBALSTI"), _UDSD = $("input", _UDTD.Parent())[0], _UDID = $("input", UDOD.parentNode)[0]; if (_UDID.value != _UDID.defaultValue) { _UDSD.value = _UDID.value; U.MD.D.PB.Pa.SBKSSBKO(_UDTD[0]); } } //搜索单个版块 U.MD.D.PB.Pa.SBKSSBKO = function (UDOD, fun) { var i, _UDE, _UCE = ["none", "block"], _UDAD, _UGE = U.MD.D.H.ET["NT"]["PB"]["BK"], _UDPD = $(UDOD).Parent(4), _UDTD = $($(_UDPD).Child()[1]).Child()[1], _UDID = $("input", _UDPD)[1], _UDV = _UDID.value.trim(); if (_UDV && _UDID.value != _UDID.defaultValue) { _UDE = U.Json.select(_UGE, { "UserDirectoryName": _UDV })[0] if (_UDE) { U.MD.D.PB.DJPBCKMU(_UDE); } //搜索有结果直接打印结果 else {//后台搜索结果 U.A.Request(US.AUTH, ["GetZDKM", _UDV], U.MD.D.PB.Pa.AsynSBKSSBKO, [[$("#UD_SYSXZBALZ")[0], true], _UDTD, _UDV, _UGE, fun]); return; } } U.MD.D.PB.Pa.XSYCBK(_UDTD, _UCE); } //搜索版块异步 U.MD.D.PB.Pa.AsynSBKSSBKO = function (r) { var i, _UCE, _context = r.context, _UDOD = _context[1], _UDV = _context[2], _UGE = _context[3], _UFN = _context[4], _UDAD = $(_UDOD).Child(), _UDE = ["block", "none"]; r = r.value; if ((_UCE = r[0]) && _UCE[0]) { _UDE = ["none", "block"]; _UGE.push(_UCE[0]); U.MD.D.PB.DJPBCKMU(_UCE[0]); } //打印信息 else { U.MD.D.PB.Pa.PKSBKSSBK(_UDAD[0], r[1], _UDV, _UFN); } //无搜索结果 显示相关的信息 U.MD.D.PB.Pa.XSYCBK(_UDOD, _UDE); //显示 } //搜索版块无结果 U.MD.D.PB.Pa.PKSBKSSBK = function (UDOD, UDE, UDV, fun) { var i, _UDTD, _UDSD; UDOD.innerText = ""; $$("div",{"className": "UD_SYSXZBATO","innerHTML": "暂时找不到 \"" + UDV + "\" 版块"}, UDOD); if (UDE.length) {//有类似的结果 _UDTD = $$("div",{"className": "UD_SYSXZBATC"}, UDOD); $$("div",{"className": "UD_SYSXZBATCL","innerHTML": "是不是在找?"}, _UDTD); _UDSD = $$("div",{"className": "UD_SYSXZBATCR"}, _UDTD); for (i = 0; i < UDE.length; i++) { $$("div", { "className": "UD_SYSXZBATCRO", "title": UDE[i].UserDirectoryName, "innerHTML": UDE[i].UserDirectoryName, "onclick": function () { U.MD.D.PB.DJPBCKMU(UDE[i]); } }, _UDSD); } } // $$("div", { "className": "UD_SYSXZBATD", "innerHTML": "返回上一步 >", // "onclick": fun || function(){U.MD.D.PB.Pa.XSYCBK(UDOD.parentNode("none", "block");} // // }, UDOD); } //显示隐藏版块 U.MD.D.PB.Pa.XSYCBK = function (UDPD, UDE) { var i, _UDAD = $(UDPD).Child(); UDE = UDE || ["none", "block"]; for (i = 0; i < UDE.length; i++) { _UDAD[i].style.display = UDE[i]; } } //#endregion //#region 申请版块 //申请版块 U.MD.D.PB.Pa.SQPGHBK = function (UCE, cb) { if (!U.MD.U.L.isLogin()) { var i, _UBE, _UDSD, _UGE = U.MD.D.H.ET["NT"]["PB"], _UDOD = $("#UD_SYTB").addAttrArray({ "style": { "display": "block" } }), _UDTD = $("div#UD_SYTBODLR", _UDOD[0])[0], _UDKD = $("input", _UDOD[0])[0]; if (U.UF.C.isString(UCE)) { _UBE = { PublishedParentID: UCE }; UCE = []; } else if (Array.isArray(UCE)) { _UBE = UCE ? UCE[0] : _UGE["DBK"]; } else { _UBE = []; _UBE = _UGE["DBK"] || { "UserDirectoryID": US.FORUMROOTID, "PublishedParentID": US.FORUMROOTID, "UserDirectoryName": "学习系统" }; } UCE = (_UBE ? U.Json.select(_UGE["BK"], { "PublishedParentID": _UBE["PublishedParentID"] }) : []).concat(UCE || []); if (!UCE.length) { UCE.push(_UBE) }; _UDTD.innerText = ""; _UDSD = $$("select", { "onchange": function () { U.MD.D.PB.Pa.SZSQPGHBKTS(UCE, _UDKD, this, cb); } }); _UDSD.options.length = UCE.length; for (i = 0; i < UCE.length; i++) { $(_UDSD.options[i]).addAttrArray({ "text": UCE[i].UserDirectoryName, "value": UCE[i].UserDirectoryName }); (!_UBE || (_UBE["UserDirectoryID"] == UCE[i]["UserDirectoryID"])) && (_UDSD.selectedIndex = i) }; _UDSD.onchange(); _UDTD.appendChild(_UDSD); new U.UF.UI.form("申请板块", _UDOD, { "resize": function () { U.MD.D.PB.NSYPBL($("#UD_SYSXZBYPR")[0], 0); }, "id": "UD_SYTBA", "style": { "width": "525px", "height": "685px" } }, { isnarrow: false, isenlarge: false }); _UDKD.focus(); } //else { U.MD.U.L.loginCallBack = [function(){U.MD.D.H.SYQHL();}]; } //切换会动静页面 } //设置申请版块确定 U.MD.D.PB.Pa.SZSQPGHBKTS = function (UDE, UDOD, UDTD, cb) { $("#UD_SYTBOXR")[0].onclick = function () { U.MD.D.PB.Pa.QDSQPGHBK(UDOD, UDE[UDTD.selectedIndex], cb); }; } //申请版块提示 U.MD.D.PB.Pa.SQPGHBKTS = function (UDID, UNS) { $(UDID).addAttrArray({ "innerHTML": UNS, "style": { "display": "block" } }); } //点击申请版块 U.MD.D.PB.Pa.QDSQPGHBK = function (UDOD, UDE, cb) { if (!U.MD.D.H.ET.PB.SQ) { //暂无申请 var _UDN, _UTS, _UTF, _UFT = (event.type != "blur"), //判断时间 _UDE = UDE || U.MD.D.H.ET["NT"]["PB"]["DBK"], //当前所在的板块 _UDPD = $(UDOD).Parent(5), _UDED = $("i", _UDPD)[0], _UDTD = $("div", _UDPD); _UDTD = _UDTD[_UDTD.length - 2]; if ((_UDN = UDOD.value) && _UDN != UDOD.defaultValue) {//如果没有任何输入就不提示 if ((_UTF = U.UF.S.FFZF.test(_UDN)) && _UDN.length) { //输入限制 U.MD.D.H.ET.PB.SQ = true; U.A.Request(US.AUTH, ["IsDName", _UDN, US.userInfo.userid, _UDE ? (_UDE["UserDirectoryID"] || _UDE["PublishedDirectoryID"]) : US.FORUMROOTID, "1", _UFT], U.MD.D.PB.Pa.AsynQDSQPGHBK, ["", UDOD, UDE, _UDPD, _UDED, _UFT, cb]); _UTS = "检测中..."; } U.MD.D.PB.Pa.SQPGHBKTS(_UDED, _UTS || (_UTF ? "输入内容长度不允许大于50" : "不允许输入特殊字符")); //提示 } } } //点击确定或者回车等待建立 U.MD.D.PB.Pa.DDJL = function (UDOD) { UDOD.onclick(true); } //申请版块提示 判断申请的版块是否存在 U.MD.D.PB.Pa.AsynQDSQPGHBK = function (r) { var _UDAD, _UTS = "版块名已存在无法建立", _context = r.context, _UDID = _context[1], _UDE = _context[2], _UDPD = _context[3], _UDED = _context[4], _UTD = _context[5], _UCB = _context[6]; U.MD.D.H.ET.PB.SQ = false; if (_UTD && r.value.UserDirectoryID) { U.MD.D.PB.Pa.AsynSSQPGHBK(r); } //直接请求数据返回 else {//查看是否为特殊字符 if (!U.UF.C.isNumber((r = r.value))) { _UTS = "板块有效,请发送申请"; _UDAD = $("div", _UDPD); _UDAD.addAttrArray({ "onclick": function () { U.MD.D.PB.Pa.SSQPGHBK(this, _UDID, _UDPD, _UDE, _UCB); } }, _UDAD.length - 3); } //版块名允许建立 if (r === 0) { _UTS = "此板块已有申请信息, 等待审核!" }; if (r === 1) { _UTS = "此板块信息含有不法信息无法建立!" }; U.MD.D.PB.Pa.SQPGHBKTS(_UDED, _UTS); } } //确定申请版块 U.MD.D.PB.Pa.SSQPGHBK = function (UDOD, UDID, UDPD, UDE, cb) { var _UDED = $("i", UDPD)[0], _UDN = UDID.value; U.MD.D.H.ET.PB.SQ = true; U.MD.D.PB.Pa.SQPGHBKTS(_UDED, "等待服务器响应"); U.A.Request(US.AUTH, ["addRoot", _UDN, US.userInfo.userid, UDE ? (UDE["UserDirectoryID"] || UDE["PublishedDirectoryID"]) : US.FORUMROOTID, "1"], U.MD.D.PB.Pa.AsynSSQPGHBK, ["", UDID, UDE, UDPD, _UDED, false, cb]); } //确定申请版块 U.MD.D.PB.Pa.AsynSSQPGHBK = function (r) { var _context = r.context, _UDID = _context[1], UDE = _context[2], _UDPD = _context[3], _UDED = _context[4], _UCB = _context[6]; r = r.value; U.MD.D.H.ET.PB.SQ = false; _UDID.value = _UDID.defaultValue; U.Alert(r.UserDirectoryID ? (r.IsPublishToStudy == 2 ? ($("#UD_SYTBOXL")[0].onclick(), U.MD.D.PB.Pa.SQZJTT(UDE, r), "板块申请成功") : "申请版块成功,请等待审核...") : ((_UDID.focus() || true), "服务器繁忙,请重新填写...")); //提示 if (_UCB) { _UCB(r) }; //回调 } //直接通过建立后使用 U.MD.D.PB.Pa.SQZJTT = function (UDE, UCE) { var _UGE = U.MD.D.H.ET["NT"]["PB"], _UTF = UDE && UDE["Child"], _UIF = US.userInfo; if (_UTF) { UDE["Child"].push(UCE) }; if (_UTF || UDE["PublishedParentID"] == US.FORUMROOTID) { //U.UF.C.AddObj(UCE, { UserName: _UIF.UserName, UserThumbnailImageHead: _UIF.UserThumbnailImageHead }) UCE.UserName = _UIF.UserName; UCE.UserThumbnailImageHead = _UIF.UserThumbnailImageHead; _UGE["BK"].push(UCE); if (!_UTF) { U.MD.D.PB.PBCKMU($("#UD_SYSXZBYPL")[0], [UCE], null, true).onclick(); } else { U.MD.D.PB.XJBKMU($("#UD_SYSXZBYT")[0], UDE["Child"], UDE) } } } //通过板块名字获取板块 U.MD.D.PB.Pa.GetBKID = function (UDN, UPID, cb) { U.A.Request(US.CD, [US.DB, "UseStudio_Blog", "UB_P_S_GetPND", UPID || US.EMPTYGUID, UDN], U.MD.D.PB.Pa.AsynGetBKID, ["", cb]); // U.A.Request(US.AUTH,"pb.GetBKID", [UDN, UPID || US.EMPTYGUID]), U.MD.D.PB.Pa.AsynGetBKID, ["", cb]; } //获取板块异步 U.MD.D.PB.Pa.AsynGetBKID = function (r) { var _context = r.context, _UCB = _context[1]; r = r.value; if (_UCB) { _UCB(r) }; } //删除板块 U.MD.D.PB.Pa.SCBK = function (UDID, UTF, cb) { if (!U.MD.U.L.isLogin()) { U.A.Request(US.CD, [US.DB, "UseStudio_Blog", "UB_P_D_DeleteSubject", US.userInfo.userid, UDID, UTF ? 1 : 0]), U.MD.D.PB.Pa.AsynSCBK, ["", UDID, cb]; // U.A.Request(US.AUTH,"pb.DeleteSubject", [US.userInfo.userid, UDID, UTF ? 1 : 0]), U.MD.D.PB.Pa.AsynSCBK, ["", UDID, cb]; } } //删除板块异步 U.MD.D.PB.Pa.AsynSCBK = function (r) { var i, _UGE = U.MD.D.H.ET["NT"]["PB"]["BK"], _context = r.context, _UDID = _context[1], _UCB = _context[2]; r = r.value; if (r == 1) { _UKE = U.Json.del(_UGE, { UserDirectoryID: _UDID }); for (i = 0; i < _UKE.length; i++) { _UKE = _UKE.concat(U.Json.del(_UGE, { UserDirectoryParentID: _UKE[i].UserDirectoryID })); } //删除子目录 } if (_UCB) { _UCB(r) }; } //修改板块信息 U.MD.D.PB.Pa.XGBKX = function (UDID, USN, UPID, cb) { if (!U.MD.U.L.isLogin()) { U.A.Request(US.CD, [US.DB, "UseStudio_Blog", "UU_P_U_ModifyDirectory", US.userInfo.userid, UDID, USN, UPID || US.EMPTYGUID]), U.MD.D.PB.Pa.AsynXGBKX, ["", cb]; } // if (!U.MD.U.L.isLogin()) { U.A.Request(US.AUTH,"pb.ModifySubjectBG", [US.userInfo.userid, UDID, USN, UPID || US.EMPTYGUID]), U.MD.D.PB.Pa.AsynXGBKX, ["", cb]; } } //修改板块 U.MD.D.PB.Pa.AsynXGBKX = function (r) { var _context = r.context, _UCB = _context[1]; r = r.value; if (_UCB) { _UCB(r) }; } //#endregion //#region 版块收藏区域 //添加收藏版块 U.MD.D.PB.Pa.SCYMHBK = function (UBE, UDOD, fun) { if (!U.MD.U.L.isLogin() && (!UBE["IF"] || UBE["IF"][2] != 2)) {//添加版块收藏 var _UDE = ["您确认要收藏该版块吗", "AddCollect", [US.userInfo.userid, UBE.UserDirectoryID || UBE.PublishedDirectoryID]]; if (UBE["IF"] && UBE["IF"][2]) { _UDE[0] = "您取消版块收藏吗", _UDE[1] = "DCollect", _UDE[2].splice(1, 0, "") }; U.Alert("服务器同步中..."); U.A.Request(US.AUTH, "pb." + _UDE[1], _UDE[2], U.MD.D.PB.Pa.AsynSCYMHBK, ["", UBE, UDOD, fun]); //添加或者删除收藏 } } //推荐类添加回调 U.MD.D.PB.Pa.TJSCYMHBK = function (UBE, UDOD, UDE) { if (!UBE["IF"]) { UBE["IF"] = [null, null, UDE ? 0 : 1]; } else { UBE["IF"][2] = (UDE = (UDE && UBE["IF"][2])) ? 0 : 1; } $(UDOD).addAttrArray({ "innerHTML": UDE ? "添加爱好" : "取消爱好", "className": UDOD.className.replace(" UD_SYSXRAHRCOTCOO", "") + (UDE ? "" : " UD_SYSXRAHRCOTCOO") }); } //异步添加收藏 U.MD.D.PB.Pa.AsynSCYMHBK = function (r) { var _UCE, _UTF = ["取消爱好", 1, 1, " UD_SYSXZBELSLXO"], _UDE = US.userInfo["SC"], _UBK = U.MD.D.H.ET["NT"]["PB"]["BK"], _context = r.context, _UBE = _context[1], _UDOD = _context[2], _UFN = _context[3], _DID = _UBE.UserDirectoryID; r = r.value; if (r && !_UFN) { _UCE = U.Json.select(_UBK, { "UserDirectoryID": _DID })[0]; if (_UBE["IF"] && _UBE["IF"][2]) { if (_UDE) { U.Json.del(_UDE, { "UserDirectoryID": _DID }) }; _UTF[0] = "添加爱好"; _UTF[1] = 0; _UTF[2] = -1; _UTF[3] = ""; U.Alert("取消对该版块的关注"); } //取消收藏后 else { if (_UDE) { _UDE.unshift(_UBK || _UBE) }; U.Alert("收藏成功") } //添加收藏后 _UBE["DCF"] += _UTF[2]; _UBE["IF"][2] = _UTF[1]; //版块变化 if (_UDOD) { $[$("#UD_SYSXZBELSLX")[0], _context[2]].addAttrArray({ "innerText": _UTF[0], "className": "UD_SYSXZBELSLX" + (_UTF[3] || "") }) }; //修改添加或者取消 } else { U.Alert("版块已收藏"); } if (_UFN) { _UFN(_UBE, _UDOD, r) }; } //获取用户所有的收藏 U.MD.D.PB.Pa.ZSYMHBK = function (UP) { if (US.userInfo.userid) { //用户收藏版块 var _UPE = 1, _UDE = US.userInfo["SC"]; (_UDE) && (_UPE = U.MD.D.D.FYGBL(_UDE, UP, [30, 300]), U.MD.D.H.PZSYMHBK((_UDE = _UPE[0])), _UPE = _UPE[1]); //打印搜藏 if (_UDE) { U.A.Request(US.CD, [US.DB, "UseStudio_Blog", "UB_P_S_GetUserPBCollect", US.userInfo.userid, US.userInfo.userid, _UPE * 50 - 50, _UPE * 50]), U.MD.D.PB.Pa.AsynZSYMHBK, ["", UP] }; //获取用户收藏的版块 // (_UDE) && (U.A.Request(US.AUTH,"pb.GetCollect", [US.userInfo.userid, _UPE * 50 - 50, _UPE * 50]), U.MD.D.PB.Pa.AsynZSYMHBK, ["", UP]); //获取用户收藏的版块 } else { parent.U.Alert("请登录"); } //未登录展示 } //获取用户收藏异步 U.MD.D.PB.Pa.AsynZSYMHBK = function (r) { var _context = r.context; US.userInfo["SC"] = r = r.value; //用户收藏 U.MD.D.H.PZSYMHBK(); } //#endregion