ForumPlate.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. Namespace.register("U.MD.D.PB.Pa"); //板块处理
  2. //#region 获取板块信息
  3. //#endregion
  4. //#region 搜索板块
  5. //出现搜索
  6. U.MD.D.PB.Pa.BKSSBK = function (UDOD, UTF) {
  7. var _UDAD = $(UDOD).Child(), _UDID = $("input", UDOD)[1];
  8. if (UTF[1] == "block" || _UDID.value == "") {
  9. _UDAD[0].style.display = UTF[0]; _UDAD[1].style.display = UTF[1];
  10. if (UTF[1] == "block") { $("input", _UDAD[1])[0].focus() };
  11. }
  12. }
  13. //版块内的搜索
  14. U.MD.D.PB.Pa.BSBKSSBKO = function (UDOD) {
  15. var _UDTD = $("#UD_SYSXZBALSTI"),
  16. _UDSD = $("input", _UDTD.Parent())[0],
  17. _UDID = $("input", UDOD.parentNode)[0];
  18. if (_UDID.value != _UDID.defaultValue) {
  19. _UDSD.value = _UDID.value;
  20. U.MD.D.PB.Pa.SBKSSBKO(_UDTD[0]);
  21. }
  22. }
  23. //搜索单个版块
  24. U.MD.D.PB.Pa.SBKSSBKO = function (UDOD, fun) {
  25. var i, _UDE,
  26. _UCE = ["none", "block"],
  27. _UDAD,
  28. _UGE = U.MD.D.H.ET["NT"]["PB"]["BK"],
  29. _UDPD = $(UDOD).Parent(4),
  30. _UDTD = $($(_UDPD).Child()[1]).Child()[1],
  31. _UDID = $("input", _UDPD)[1],
  32. _UDV = _UDID.value.trim();
  33. if (_UDV && _UDID.value != _UDID.defaultValue) {
  34. _UDE = U.Json.select(_UGE, { "UserDirectoryName": _UDV })[0]
  35. if (_UDE) { U.MD.D.PB.DJPBCKMU(_UDE); } //搜索有结果直接打印结果
  36. else {//后台搜索结果
  37. U.A.Request(US.AUTH, ["GetZDKM", _UDV], U.MD.D.PB.Pa.AsynSBKSSBKO, [[$("#UD_SYSXZBALZ")[0], true], _UDTD, _UDV, _UGE, fun]);
  38. return;
  39. }
  40. }
  41. U.MD.D.PB.Pa.XSYCBK(_UDTD, _UCE);
  42. }
  43. //搜索版块异步
  44. U.MD.D.PB.Pa.AsynSBKSSBKO = function (r) {
  45. var i, _UCE,
  46. _context = r.context,
  47. _UDOD = _context[1],
  48. _UDV = _context[2],
  49. _UGE = _context[3],
  50. _UFN = _context[4],
  51. _UDAD = $(_UDOD).Child(),
  52. _UDE = ["block", "none"];
  53. r = r.value;
  54. if ((_UCE = r[0]) && _UCE[0]) {
  55. _UDE = ["none", "block"];
  56. _UGE.push(_UCE[0]);
  57. U.MD.D.PB.DJPBCKMU(_UCE[0]);
  58. } //打印信息
  59. else {
  60. U.MD.D.PB.Pa.PKSBKSSBK(_UDAD[0], r[1], _UDV, _UFN);
  61. } //无搜索结果 显示相关的信息
  62. U.MD.D.PB.Pa.XSYCBK(_UDOD, _UDE); //显示
  63. }
  64. //搜索版块无结果
  65. U.MD.D.PB.Pa.PKSBKSSBK = function (UDOD, UDE, UDV, fun) {
  66. var i, _UDTD, _UDSD;
  67. UDOD.innerText = "";
  68. $$("div",{"className": "UD_SYSXZBATO","innerHTML": "暂时找不到<span> \"" + UDV + "\" </span>版块"}, UDOD);
  69. if (UDE.length) {//有类似的结果
  70. _UDTD = $$("div",{"className": "UD_SYSXZBATC"}, UDOD);
  71. $$("div",{"className": "UD_SYSXZBATCL","innerHTML": "是不是在找?"}, _UDTD);
  72. _UDSD = $$("div",{"className": "UD_SYSXZBATCR"}, _UDTD);
  73. for (i = 0; i < UDE.length; i++) {
  74. $$("div",
  75. {
  76. "className": "UD_SYSXZBATCRO",
  77. "title": UDE[i].UserDirectoryName,
  78. "innerHTML": UDE[i].UserDirectoryName,
  79. "onclick": function () {
  80. U.MD.D.PB.DJPBCKMU(UDE[i]);
  81. }
  82. }, _UDSD);
  83. }
  84. }
  85. // $$("div", { "className": "UD_SYSXZBATD", "innerHTML": "返回上一步 >",
  86. // "onclick": fun || function(){U.MD.D.PB.Pa.XSYCBK(UDOD.parentNode("none", "block");}
  87. //
  88. // }, UDOD);
  89. }
  90. //显示隐藏版块
  91. U.MD.D.PB.Pa.XSYCBK = function (UDPD, UDE) {
  92. var i,
  93. _UDAD = $(UDPD).Child();
  94. UDE = UDE || ["none", "block"];
  95. for (i = 0; i < UDE.length; i++) {
  96. _UDAD[i].style.display = UDE[i];
  97. }
  98. }
  99. //#endregion
  100. //#region 申请版块
  101. //申请版块
  102. U.MD.D.PB.Pa.SQPGHBK = function (UCE, cb) {
  103. if (!U.MD.U.L.isLogin()) {
  104. var i, _UBE, _UDSD,
  105. _UGE = U.MD.D.H.ET["NT"]["PB"],
  106. _UDOD = $("#UD_SYTB").addAttrArray({
  107. "style":
  108. {
  109. "display": "block"
  110. }
  111. }),
  112. _UDTD = $("div#UD_SYTBODLR",
  113. _UDOD[0])[0],
  114. _UDKD = $("input", _UDOD[0])[0];
  115. if (U.UF.C.isString(UCE)) {
  116. _UBE = { PublishedParentID: UCE };
  117. UCE = [];
  118. }
  119. else if (Array.isArray(UCE)) {
  120. _UBE = UCE ? UCE[0] : _UGE["DBK"];
  121. } else {
  122. _UBE = []; _UBE = _UGE["DBK"] || {
  123. "UserDirectoryID": US.FORUMROOTID,
  124. "PublishedParentID": US.FORUMROOTID,
  125. "UserDirectoryName": "学习系统"
  126. };
  127. }
  128. UCE = (_UBE ? U.Json.select(_UGE["BK"], { "PublishedParentID": _UBE["PublishedParentID"] }) : []).concat(UCE || []);
  129. if (!UCE.length) { UCE.push(_UBE) };
  130. _UDTD.innerText = "";
  131. _UDSD = $$("select",
  132. {
  133. "onchange": function () {
  134. U.MD.D.PB.Pa.SZSQPGHBKTS(UCE, _UDKD, this, cb);
  135. }
  136. });
  137. _UDSD.options.length = UCE.length;
  138. for (i = 0; i < UCE.length; i++) {
  139. $(_UDSD.options[i]).addAttrArray({
  140. "text": UCE[i].UserDirectoryName,
  141. "value": UCE[i].UserDirectoryName
  142. });
  143. (!_UBE || (_UBE["UserDirectoryID"] == UCE[i]["UserDirectoryID"])) && (_UDSD.selectedIndex = i)
  144. };
  145. _UDSD.onchange();
  146. _UDTD.appendChild(_UDSD);
  147. new U.UF.UI.form("申请板块",
  148. _UDOD,
  149. {
  150. "resize": function () {
  151. U.MD.D.PB.NSYPBL($("#UD_SYSXZBYPR")[0], 0);
  152. },
  153. "id": "UD_SYTBA",
  154. "style": {
  155. "width": "525px",
  156. "height": "685px"
  157. }
  158. },
  159. {
  160. isnarrow: false,
  161. isenlarge: false
  162. });
  163. _UDKD.focus();
  164. }
  165. //else { U.MD.U.L.loginCallBack = [function(){U.MD.D.H.SYQHL();}]; } //切换会动静页面
  166. }
  167. //设置申请版块确定
  168. U.MD.D.PB.Pa.SZSQPGHBKTS = function (UDE, UDOD, UDTD, cb) {
  169. $("#UD_SYTBOXR")[0].onclick = function () {
  170. U.MD.D.PB.Pa.QDSQPGHBK(UDOD, UDE[UDTD.selectedIndex], cb);
  171. };
  172. }
  173. //申请版块提示
  174. U.MD.D.PB.Pa.SQPGHBKTS = function (UDID, UNS) {
  175. $(UDID).addAttrArray({
  176. "innerHTML": UNS,
  177. "style":
  178. {
  179. "display": "block"
  180. }
  181. });
  182. }
  183. //点击申请版块
  184. U.MD.D.PB.Pa.QDSQPGHBK = function (UDOD, UDE, cb) {
  185. if (!U.MD.D.H.ET.PB.SQ) { //暂无申请
  186. var _UDN, _UTS, _UTF,
  187. _UFT = (event.type != "blur"), //判断时间
  188. _UDE = UDE || U.MD.D.H.ET["NT"]["PB"]["DBK"], //当前所在的板块
  189. _UDPD = $(UDOD).Parent(5),
  190. _UDED = $("i", _UDPD)[0],
  191. _UDTD = $("div", _UDPD);
  192. _UDTD = _UDTD[_UDTD.length - 2];
  193. if ((_UDN = UDOD.value) && _UDN != UDOD.defaultValue) {//如果没有任何输入就不提示
  194. if ((_UTF = U.UF.S.FFZF.test(_UDN)) && _UDN.length) { //输入限制
  195. U.MD.D.H.ET.PB.SQ = true;
  196. U.A.Request(US.AUTH, ["IsDName", _UDN, US.userInfo.userid, _UDE ? (_UDE["UserDirectoryID"] || _UDE["PublishedDirectoryID"]) : US.FORUMROOTID, "1", _UFT],
  197. U.MD.D.PB.Pa.AsynQDSQPGHBK, ["", UDOD, UDE, _UDPD, _UDED, _UFT, cb]); _UTS = "检测中...";
  198. }
  199. U.MD.D.PB.Pa.SQPGHBKTS(_UDED, _UTS || (_UTF ? "输入内容长度不允许大于50" : "不允许输入特殊字符")); //提示
  200. }
  201. }
  202. }
  203. //点击确定或者回车等待建立
  204. U.MD.D.PB.Pa.DDJL = function (UDOD) {
  205. UDOD.onclick(true);
  206. }
  207. //申请版块提示 判断申请的版块是否存在
  208. U.MD.D.PB.Pa.AsynQDSQPGHBK = function (r) {
  209. var _UDAD,
  210. _UTS = "版块名已存在无法建立",
  211. _context = r.context,
  212. _UDID = _context[1],
  213. _UDE = _context[2],
  214. _UDPD = _context[3],
  215. _UDED = _context[4],
  216. _UTD = _context[5],
  217. _UCB = _context[6];
  218. U.MD.D.H.ET.PB.SQ = false;
  219. if (_UTD && r.value.UserDirectoryID) {
  220. U.MD.D.PB.Pa.AsynSSQPGHBK(r);
  221. } //直接请求数据返回
  222. else {//查看是否为特殊字符
  223. 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); } //版块名允许建立
  224. if (r === 0) { _UTS = "此板块已有申请信息, 等待审核!" }; if (r === 1) { _UTS = "此板块信息含有不法信息无法建立!" }; U.MD.D.PB.Pa.SQPGHBKTS(_UDED, _UTS);
  225. }
  226. }
  227. //确定申请版块
  228. U.MD.D.PB.Pa.SSQPGHBK = function (UDOD, UDID, UDPD, UDE, cb) {
  229. var _UDED = $("i", UDPD)[0],
  230. _UDN = UDID.value;
  231. U.MD.D.H.ET.PB.SQ = true;
  232. U.MD.D.PB.Pa.SQPGHBKTS(_UDED, "等待服务器响应");
  233. 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]);
  234. }
  235. //确定申请版块
  236. U.MD.D.PB.Pa.AsynSSQPGHBK = function (r) {
  237. 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;
  238. _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), "服务器繁忙,请重新填写...")); //提示
  239. if (_UCB) { _UCB(r) }; //回调
  240. }
  241. //直接通过建立后使用
  242. U.MD.D.PB.Pa.SQZJTT = function (UDE, UCE) {
  243. var _UGE = U.MD.D.H.ET["NT"]["PB"],
  244. _UTF = UDE && UDE["Child"],
  245. _UIF = US.userInfo;
  246. if (_UTF) { UDE["Child"].push(UCE) };
  247. if (_UTF || UDE["PublishedParentID"] == US.FORUMROOTID) {
  248. //U.UF.C.AddObj(UCE, { UserName: _UIF.UserName, UserThumbnailImageHead: _UIF.UserThumbnailImageHead })
  249. UCE.UserName = _UIF.UserName;
  250. UCE.UserThumbnailImageHead = _UIF.UserThumbnailImageHead;
  251. _UGE["BK"].push(UCE);
  252. if (!_UTF) {
  253. U.MD.D.PB.PBCKMU($("#UD_SYSXZBYPL")[0], [UCE], null, true).onclick();
  254. }
  255. else {
  256. U.MD.D.PB.XJBKMU($("#UD_SYSXZBYT")[0], UDE["Child"], UDE)
  257. }
  258. }
  259. }
  260. //通过板块名字获取板块
  261. U.MD.D.PB.Pa.GetBKID = function (UDN, UPID, cb) {
  262. U.A.Request(US.CD, [US.DB, "UseStudio_Blog", "UB_P_S_GetPND", UPID || US.EMPTYGUID, UDN], U.MD.D.PB.Pa.AsynGetBKID, ["", cb]);
  263. // U.A.Request(US.AUTH,"pb.GetBKID", [UDN, UPID || US.EMPTYGUID]), U.MD.D.PB.Pa.AsynGetBKID, ["", cb];
  264. }
  265. //获取板块异步
  266. U.MD.D.PB.Pa.AsynGetBKID = function (r) {
  267. var _context = r.context,
  268. _UCB = _context[1];
  269. r = r.value; if (_UCB) { _UCB(r) };
  270. }
  271. //删除板块
  272. U.MD.D.PB.Pa.SCBK = function (UDID, UTF, cb) {
  273. if (!U.MD.U.L.isLogin()) {
  274. 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];
  275. // U.A.Request(US.AUTH,"pb.DeleteSubject", [US.userInfo.userid, UDID, UTF ? 1 : 0]), U.MD.D.PB.Pa.AsynSCBK, ["", UDID, cb];
  276. }
  277. }
  278. //删除板块异步
  279. U.MD.D.PB.Pa.AsynSCBK = function (r) {
  280. var i,
  281. _UGE = U.MD.D.H.ET["NT"]["PB"]["BK"],
  282. _context = r.context,
  283. _UDID = _context[1],
  284. _UCB = _context[2];
  285. r = r.value;
  286. if (r == 1) {
  287. _UKE = U.Json.del(_UGE, { UserDirectoryID: _UDID });
  288. for (i = 0; i < _UKE.length; i++) {
  289. _UKE = _UKE.concat(U.Json.del(_UGE, { UserDirectoryParentID: _UKE[i].UserDirectoryID }));
  290. } //删除子目录
  291. }
  292. if (_UCB) { _UCB(r) };
  293. }
  294. //修改板块信息
  295. U.MD.D.PB.Pa.XGBKX = function (UDID, USN, UPID, cb) {
  296. if (!U.MD.U.L.isLogin()) {
  297. 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];
  298. }
  299. // 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]; }
  300. }
  301. //修改板块
  302. U.MD.D.PB.Pa.AsynXGBKX = function (r) {
  303. var _context = r.context, _UCB = _context[1]; r = r.value; if (_UCB) { _UCB(r) };
  304. }
  305. //#endregion
  306. //#region 版块收藏区域
  307. //添加收藏版块
  308. U.MD.D.PB.Pa.SCYMHBK = function (UBE, UDOD, fun) {
  309. if (!U.MD.U.L.isLogin() && (!UBE["IF"] || UBE["IF"][2] != 2)) {//添加版块收藏
  310. var _UDE = ["您确认要收藏该版块吗", "AddCollect", [US.userInfo.userid, UBE.UserDirectoryID || UBE.PublishedDirectoryID]];
  311. if (UBE["IF"] && UBE["IF"][2]) { _UDE[0] = "您取消版块收藏吗", _UDE[1] = "DCollect", _UDE[2].splice(1, 0, "") };
  312. U.Alert("服务器同步中...");
  313. U.A.Request(US.AUTH, "pb." + _UDE[1], _UDE[2], U.MD.D.PB.Pa.AsynSCYMHBK, ["", UBE, UDOD, fun]); //添加或者删除收藏
  314. }
  315. }
  316. //推荐类添加回调
  317. U.MD.D.PB.Pa.TJSCYMHBK = function (UBE, UDOD, UDE) {
  318. if (!UBE["IF"]) {
  319. UBE["IF"] = [null, null, UDE ? 0 : 1];
  320. } else {
  321. UBE["IF"][2] = (UDE = (UDE && UBE["IF"][2])) ? 0 : 1;
  322. }
  323. $(UDOD).addAttrArray({
  324. "innerHTML": UDE ? "添加爱好" : "取消爱好",
  325. "className": UDOD.className.replace(" UD_SYSXRAHRCOTCOO", "") + (UDE ? "" : " UD_SYSXRAHRCOTCOO")
  326. });
  327. }
  328. //异步添加收藏
  329. U.MD.D.PB.Pa.AsynSCYMHBK = function (r) {
  330. var _UCE,
  331. _UTF = ["取消爱好",
  332. 1,
  333. 1,
  334. " UD_SYSXZBELSLXO"],
  335. _UDE = US.userInfo["SC"],
  336. _UBK = U.MD.D.H.ET["NT"]["PB"]["BK"],
  337. _context = r.context,
  338. _UBE = _context[1],
  339. _UDOD = _context[2],
  340. _UFN = _context[3],
  341. _DID = _UBE.UserDirectoryID;
  342. r = r.value;
  343. if (r && !_UFN) {
  344. _UCE = U.Json.select(_UBK, { "UserDirectoryID": _DID })[0];
  345. if (_UBE["IF"] && _UBE["IF"][2]) {
  346. if (_UDE) { U.Json.del(_UDE, { "UserDirectoryID": _DID }) };
  347. _UTF[0] = "添加爱好";
  348. _UTF[1] = 0;
  349. _UTF[2] = -1;
  350. _UTF[3] = "";
  351. U.Alert("取消对该版块的关注");
  352. } //取消收藏后
  353. else {
  354. if (_UDE) { _UDE.unshift(_UBK || _UBE) }; U.Alert("收藏成功")
  355. } //添加收藏后
  356. _UBE["DCF"] += _UTF[2]; _UBE["IF"][2] = _UTF[1]; //版块变化
  357. if (_UDOD) { $[$("#UD_SYSXZBELSLX")[0], _context[2]].addAttrArray({ "innerText": _UTF[0], "className": "UD_SYSXZBELSLX" + (_UTF[3] || "") }) }; //修改添加或者取消
  358. }
  359. else { U.Alert("版块已收藏"); }
  360. if (_UFN) { _UFN(_UBE, _UDOD, r) };
  361. }
  362. //获取用户所有的收藏
  363. U.MD.D.PB.Pa.ZSYMHBK = function (UP) {
  364. if (US.userInfo.userid) { //用户收藏版块
  365. 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]); //打印搜藏
  366. 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] }; //获取用户收藏的版块
  367. // (_UDE) && (U.A.Request(US.AUTH,"pb.GetCollect", [US.userInfo.userid, _UPE * 50 - 50, _UPE * 50]), U.MD.D.PB.Pa.AsynZSYMHBK, ["", UP]); //获取用户收藏的版块
  368. }
  369. else { parent.U.Alert("请登录"); } //未登录展示
  370. }
  371. //获取用户收藏异步
  372. U.MD.D.PB.Pa.AsynZSYMHBK = function (r) {
  373. var _context = r.context;
  374. US.userInfo["SC"] = r = r.value; //用户收藏
  375. U.MD.D.H.PZSYMHBK();
  376. }
  377. //#endregion