123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- Namespace.register("U.MD.D.PB.Re"); //pb回复处理
- //#region 回复
- /*
- * 获取回复内容
- *
- * @param {object} 帖子信息
- * @param {number} 目录信息
- * @param {string} 显示当前回复内容很的回复ID
- * @param {element} 帖子内容区域
- * @returns {Object}
- */
- U.MD.D.PB.Re.RPMHBK = function (UDE, UP, URID) {
- var _UDOD = $("#UD_SYPCLRR")[0], //回复打印的内容
- _UCE = U.MD.D.D.FYGBL(UDE.Reply, UP, [10, 100]); //获取当前页回复数据
- if (UP == 1) { _UDOD.innerText = "" }; //第一页打印处理
- if (_UCE[0]) {
- if (_UCE[0].length) {
- U.MD.D.PB.Re.PRPMHBK(_UCE[0], _UDOD, UDE, URID); //打印回复的内容
- }
- return true;
- }
- else {
- U.A.Request(US.CD, [US.DB, "UseStudio_Blog", "UB_P_S_SelectArticleAllReply", UDE.ArticleID, (_UCE[1] - 1) * 100, _UCE[1] * 100]), U.MD.D.PB.Re.AsynRPMHBK, ["", UDE, UP, _UCE[1], URID]; //获取回复
- // U.A.Request(US.AUTH,"pb.ReplyList", [UDE.ArticleID, (_UCE[1] - 1) * 100, _UCE[1] * 100]), U.MD.D.PB.Re.AsynRPMHBK, ["", UDE, UP, _UCE[1], URID]; //获取回复
- }
- }
- //分页滚动加载
- U.MD.D.PB.Re.FGRPMHBK = function () {
- U.MD.D.PB.Re.RPMHBK(U.MD.D.H.ET["NT"]["PB"]["DWZ"], this.P + 2); //滚动加载监听出发
- }
- //获取回复异步
- U.MD.D.PB.Re.AsynRPMHBK = function (r) {
- var i,
- _context = r.context,
- _UDE = _context[1]; //帖子信息
- r = r.value;
- if (_UDE.Reply == null) { _UDE.Reply = [] }; _UDE.Reply[_context[2]] = []; //给回复添加实体
- for (i = 0; i < r.length; i++) { //生成回复分类
- if (!r[i].ReplyParentID) {
- _UDE.Reply[_context[2]].push(r[i]); //回复添加到回复实体里
- r[i]["RR"] = U.Json.select(r, { "ReplyParentID": r[i].ReplyID }); //设置回复的回复
- }
- }
- U.MD.D.PB.Re.RPMHBK(_UDE, _context[2], _context[4]); //获取回复成功 同时打印回复
- }
- /*
- * 获取回复内容
- *
- * @param {object} 回复信息
- * @param {element} 元素
- * @param {object} 帖子信息
- * @param {string} 当前回复信息的位置id
- * @returns {Object}
- */
- U.MD.D.PB.Re.PRPMHBK = function (UDE, UDOD, UAE, URID) {
- var i, j, _UCE, _UDBD, _UDTD, _UDSD, _UDND, _UDID, _UDKD, _UDLD, _UDMD, _UIMG,
- _UIF = US.userInfo,
- _UDFD = $$("frag");
- /*
- 此处为样式打印输出
- */
- for (i = 0; i < UDE.length; i++) {
- _UCE = UDE[i]["RR"] || [];
- _UDTD = $$("div",{"className": "UD_SYPCLRRO"}, _UDFD);
- if (URID == UDE[i].ReplyID) { _UDBD = _UDTD };
- _UDSD = $$("div",{"className": "UD_SYPCLRROS"}, _UDTD);
- _UDND = $$("div",{"className": "UD_SYPCLRROSA"}, _UDSD);
- _UDID = $$("div",{"className": "UD_SYPCLRROL"}, _UDND);
- $$("img",
- {
- "onerror": U.MD.C.imgError,
- "alt": UDE[i].UserNickName,
- "onclick": function () {
- U.MD.U.V.ViewOtherUserInfo(UDE[i].ReplyAddUserID);
- },
- "src": U.MD.C.getHeadImage(UDE[i].UserThumbnailImageHead)
- }, _UDID);
- _UDID = $$("div",{"className": "UD_SYPCLRROR"}, _UDND);
- _UDKD = $$("div",{"className": "UD_SYPCLRRORS"}, _UDID);
- $$("div",{"className": "UD_SYPCLRRORSN UTDF","innerHTML": UDE[i].UserNickName}, _UDKD);
- $$("div",{"className": "UD_SYPCLRRORST","innerHTML": U.UF.D.getDateInterval(UDE[i].ReplyAddTime)}, _UDKD);
- _UDKD = $$("div",{"className": "UD_SYPCLRRORX"}, _UDID);
- _UDLD = $$("div",{"className": "UD_SYPCLRRORXC"}, _UDKD);
- _UDMD = $$("div",{"className": "UD_SYPCLRRORXCO","innerHTML": UDE[i].ReplyContent}, _UDLD);
- $("a", _UDMD).addAttrArray({ "target": "_blank" });
- _UDMD = $("img", _UDMD);
- _UIMG = [];
- for (j = 0; j < _UDMD.length; j++) {
- _UIMG.push({ "Time": UDE.ArticleAddTime,
- "Thm": _UDMD[j].src,
- "Img": _UDMD[j].alt.indexOf(US.FILESYSTEMURL) > -1 ? _UDMD[j].alt : _UDMD[j].src
- });
- _UDMD.addAttrArray({ "style": { "cssText": "" },
- "onclick": function () {
- U.UF.EV.stopBubble();
- U.MD.I.Img(_UIF, _UIMG, j);
- }
- }, j);
- }
- _UDID = $$("div",{"className": "UD_SYPCLRROM"}, _UDND);
- _UDID = $$("div",{"className": "UD_SYPCLRROMO"}, _UDID);
- $$("div",
- {
- "className": "UD_SYPCLRROMA",
- "innerHTML": "回复" + (_UCE.length > 0 ? "(" + _UCE.length + ")" : ""),
- "onclick": function () {
- U.MD.D.PB.Re.XPRPMHBK(_UDSD, UDE[i], UAE);
- }
- }, _UDID);
- if (UDE[i].ReplyAddUserID == US.userInfo.userid) {
- $$("div",
- {
- "className": "UD_SYBFOZTK UD_SYBFOZTKO",
- "style":
- {
- "margin": "0 0 0 5px"
- },
- "title": "删除",
- "innerHTML": "删除",
- "onclick": function () {
- U.UF.UI.Confirm("是否撤销评论", function () { U.MD.D.Blog.R.SCPHFRGBL(UDE, UDE[i], UAE, _UDTD) });
- }
- }, _UDID);
- }
- _UDSD = $$("div",{"className": "UD_SYPCLRROX"}, _UDTD);
- for (j = 0; (_UCE && j < _UCE.length); j++) {
- _UDID = $$("div",{"className": "UD_SYPCLRROXO"}, _UDSD);
- if (URID == _UCE[j].ReplyID) { _UDBD = _UDID };
- _UDKD = $$("div",{"className": "UD_SYPCLRROL"}, _UDID);
- $$("img",
- {
- "onerror": U.MD.C.imgError,
- "alt": _UCE[j].UserNickName,
- "onclick": function () {
- U.MD.U.V.ViewOtherUserInfo(_UCE[j].ReplyAddUserID);
- },
- "src": U.MD.C.getHeadImage(_UCE[j].UserThumbnailImageHead)
- }, _UDKD);
- _UDKD = $$("div",{"className": "UD_SYPCLRROXOR"}, _UDID);
- _UDLD = $$("div",{"className": "UD_SYPCLRROXORS"}, _UDKD);
- $$("div",{"className": "UD_SYPCLRROXORSO","innerHTML": _UCE[j].UserNickName}, _UDLD);
- $$("span",{"className": "UD_SYPCLRROXORSS","innerHTML": "回复"}, _UDLD);
- $$("div",{"className": "UD_SYPCLRROXORSO","innerHTML": _UCE[j].ParentUserNickName,"style":{"marginLeft": "5px"}}, _UDLD);
- _UDLD = $$("div",{"className": "UD_SYPCLRRORX"}, _UDKD);
- _UDMD = $$("div",{"className": "UD_SYPCLRRORXC"}, _UDLD);
- $$("div",{"className": "UD_SYPCLRRORXCO","innerHTML": _UCE[j].ReplyContent}, _UDMD);
- _UDKD = $$("div",{"className": "UD_SYPCLRROM"}, _UDID);
- _UDKD = $$("div",{"className": "UD_SYPCLRROMO"
- }, _UDKD);
- $$("div",
- {
- "className": "UD_SYPCLRROMA",
- "innerHTML": "回复",
- "onclick": function () {
- U.MD.D.PB.Re.XPRPMHBK(_UDID, _UCE[j], UAE, UDE[i]);
- }
- }, _UDKD);
- if (_UCE[j].ReplyAddUserID == US.userInfo.userid) {
- $$("div",
- {
- "className": "UD_SYBFOZTK UD_SYBFOZTKO",
- "style": {
- "margin": "0 0 0 5px"
- },
- "title": "删除",
- "innerHTML": "删除",
- "onclick": function () {
- U.UF.UI.Confirm("是否撤销评论", function () { U.MD.D.Blog.R.SCPHFRGBL(_UCE, _UCE[j], UAE, _UDID) });
- }
- }, _UDKD);
- }
- }
- }
- UDOD.appendChild(_UDFD);
- if (_UDBD) { _UDBD.scrollIntoView(false), $(UDOD).Parent(2).scrollLeft = 0 }; //默认滚动到指定的回复位置
- }
- //#region 功能区域
- //添加回复显示
- U.MD.D.PB.Re.XPRPMHBK = function (UDOD, UDE, UAE, UPE) {
- if (!U.MD.U.L.isLogin()) {
- var _UDAD, _UDKD,
- _UDED = $("#UD_SYPCLRCL")[0],
- _UDAD = $(UDOD).Child();
- if (_UDAD[_UDAD.length - 1].className != "UD_SYPCLRC") {
- if (_UDED == null) { _UDED = $("#UD_SYPCLRC")[0].cloneNode(true), $(_UDED).addAttrArray({ "id": "UD_SYPCLRCL" }) };
- _UDKD = $($($(_UDED).Child()[0]).Child()[0]).addAttrArray({ "innerText": "发表评论...", "id": "" })[0]; //清理评论框
- (_UDAD = $("div", _UDED))[_UDAD.length - 1].onclick = function () {
- U.MD.D.PB.Re.APRPMHBK(UDE, _UDKD, UAE, UPE || UDE);
- };
- UDOD.appendChild(_UDED); _UDKD.focus(); //添加回复框
- }
- else { $(_UDAD[_UDAD.length - 1]).remove(); }
- }
- }
- //添加回复
- U.MD.D.PB.Re.APRPMHBK = function (UDE, UDOD, UAE, UPE) {
- var _UTH = UDOD.innerHTML, _UTF = "请先登录", _URID = UDE ? (UDE.ReplyParentID || UDE.ReplyID) : "";
- if (US.userInfo.userid) { //发表帖子
- _UTF = "回复的内容部能为空";
- if (UDOD.innerText.trim().length > 0 && _UTH != "发表评论...") {
- _UTF = "正在回帖请稍等";
- U.A.Request(US.AUTH, ["ReportReply", UAE.ArticleID, UDOD.innerHTML, _URID, UDE ? UDE.ReplyAddUserID : ""]), U.MD.D.PB.Re.AsynAPRPMHBK, ["", UDE, UAE, UDOD.innerHTML, UPE]; UDOD.innerHTML = "";
- }
- }
- U.Alert(_UTF);
- }
- //添加回复异步
- U.MD.D.PB.Re.AsynAPRPMHBK = function (r) {
- var i, _URE,
- _UST = "服务器繁忙",
- _context = r.context,
- _UDE = _context[1],
- _UAID = _context[3],
- _UAE = _context[4] || _context[2];
- r = r.value;
- if (r) {
- (_UDE ? _UAE["RR"] : _UAE["Reply"][1]).unshift((_URE = new U.MD.D.PB.Re.TPRPMHBK[_UDE ? _UDE.UserNickName : "", U.UF.D.toTimeStamp(new Date()), US.userInfo.userid, _UAID, r, _UDE ? (_UDE.ReplyParentID || _UDE.ReplyID) : "", _UDE ? _UDE.ReplyAddUserID : "", US.userInfo.UserNickName, US.userInfo.UserThumbnailImageHead]));
- $("#UD_SYPCLCD div")[4].innerHTML = (_UAE.ArticleReplayNumber++) + 1; U.MD.D.PB.Re.RPMHBK(_context[2], 1); _UST = "发表回复成功";
- }
- U.Alert(_UST);
- }
- //回复的实体
- U.MD.D.PB.Re.TPRPMHBK = function (UDE) {
- this.ParentUserNickName = UDE[0];
- this.ReplyAddTime = UDE[1];
- this.ReplyAddUserID = UDE[2];
- this.ReplyContent = UDE[3];
- this.ReplyID = UDE[4];
- this.ReplyParentID = UDE[5];
- this.ReplyVerifyUserID = UDE[6];
- this.UserNickName = UDE[7];
- this.UserThumbnailImageHead = UDE[8];
- this.RR = [];
- }
- //#endregion
- //#endregion
|