U.F.S.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. Namespace.register("U.F.S");
  2. U.F.S.SearchPostion; //搜索的时候判断位置
  3. /**
  4. * 搜索好友
  5. *
  6. * @param {object} 用户信息
  7. * @param {element} 打印显示的元素
  8. * @param {object} 回调函数
  9. * @param {object} 搜索的类型
  10. * F 好友
  11. * G 群
  12. * "" 好友和群
  13. */
  14. U.F.S.SearchFriendsOrGroupForm = function (inputs, el, cb, typename) {
  15. var _searchfriendinfo = [], //搜索好友的数组
  16. _searchvalue = inputs.value, //获取搜索的内容
  17. _isserch = U.F.S.SearchFriendsKeyboardHandle(el, inputs) //是否允许搜索
  18. ;
  19. //判断用户键盘输入的内容,是否需要进行搜索
  20. if (_isserch) {
  21. _searchfriendinfo;
  22. //获取搜索好友的值
  23. if (!typename || typename == "F") {
  24. _searchfriendinfo = _searchfriendinfo.concat(_$(US.Friend[1]).Like({ "FriendsDescript": _searchvalue, "UserNickName": _searchvalue, "UserName": _searchvalue })); //获取用户好友
  25. }
  26. //获取搜索群的值
  27. if (!typename || typename == "G") {
  28. _searchfriendinfo = _searchfriendinfo.concat(_$(US.Friend[2]).Like({ "GroupManageName": _searchvalue })); //获取好友群
  29. }
  30. //显示清空
  31. el.style.display = "block";
  32. el.innerText = "";
  33. //搜索好友的打印
  34. U.F.S.PrintSearchFriends(_searchfriendinfo, el, cb);
  35. };
  36. }
  37. /**
  38. * 搜索键盘的处理
  39. *
  40. * @param {object} 用户信息
  41. */
  42. U.F.S.SearchFriendsKeyboardHandle = function (el, inputs) {
  43. var _keycode = event ? event.keyCode : 0, //获取键盘的值
  44. _childs = $(el).Child(), //搜索的内容子元素
  45. _searchvalue = inputs.value, //搜索的值
  46. _position = U.F.S.SearchPostion, //搜索的位置
  47. _searchel = _childs[_position] //搜索得到的元素
  48. ;
  49. //判断搜索的值是否存在,不存在则隐藏
  50. if (_searchvalue == "" || _searchvalue == inputs.defaultValue) {
  51. el.style.display = "none";
  52. }
  53. //如果搜索的内容存在,同时用户执行了回车处理
  54. else if (_position > -1 && _keycode == 13 || _keycode == 10 && _childs[_position].onmousedown) {
  55. _childs[_position].onmousedown();
  56. }
  57. //如果不是上下键,那么允许用户继续搜索
  58. else if (_keycode != 38 && _keycode != 40) {
  59. U.F.S.SearchPostion = -1; //搜索选择的位置设置为-1
  60. return true;
  61. }
  62. return false;
  63. }
  64. /**
  65. * 打印搜索好友
  66. *
  67. * @param {object} 用户信息
  68. */
  69. U.F.S.PrintSearchFriends = function (friendinfo, el, cb) {
  70. var i,
  71. _name,
  72. _tempel,
  73. _temponeel,
  74. _temptwoel,
  75. _frag = $$("frag"),
  76. _childs = $(el).Child();
  77. //没有搜索到好友的提示
  78. if (!friendinfo[0]) {
  79. $$("div", { "className": "UD_SYSSZJDB", "innerText": "很抱歉,没有找到您搜索的好友" }, el);
  80. }
  81. else {
  82. //循环打印搜索的好友
  83. for (i = 0; i < friendinfo.length; i++) {
  84. //搜索的名字
  85. _name = (friendinfo[i].GroupManageName || friendinfo[i].FriendsDescript || friendinfo[i].UserNickName || friendinfo[i].UserName);
  86. //打印的样式
  87. _tempel = $$("div", { "title": "点击查看", "className": "UD_SYSSZJD UTDF", "onmousemove": [[U.F.S.SwitchSearchFriendsOrGroup, [el, i + _childs.length]]], "onmousedown": [[(cb || U.F.W.PopupFriendsForm), [friendinfo[i]]], [U.F.S.HideSearchFriendsOrGroupForm, [el]]] }, _frag);
  88. _temponeel = $$("div", { "className": "UD_SYSSZJDZ" }, _tempel);
  89. _temptwoel = $$("div", { "className": "UD_SYSSZJDA", "title": _name }, _temponeel);
  90. if (friendinfo[i].GroupManageID) {
  91. U.F.PrintGroupHeadImage(friendinfo[i], _temptwoel);
  92. }
  93. else {
  94. $$("img", { "onerror": U.M.ImgError, "className": "UD_SYSSZJDAO", "src": U.M.GetImgU(friendinfo[i].UserThumbnailImageHead) }, _temptwoel);
  95. }
  96. $$("div", { "className": "UD_SYSSZJDN", "innerHTML": _name }, _temponeel);
  97. }
  98. el.appendChild(_frag);
  99. }
  100. U.F.S.SearchPostion = -1; //搜索选择的位置设置为-1
  101. return _childs;
  102. }
  103. /**
  104. * 上下切换搜索的好友或者群
  105. *
  106. * @param {element} 切换元素
  107. * @param {number} 当前所在的位置
  108. */
  109. U.F.S.SwitchSearchFriendsOrGroup = function (el, switchposition) {
  110. var _switchel,
  111. _top,
  112. _scrolltop,
  113. _keycode = event.keyCode, //键盘码
  114. _childs = $(el).Child(), //获取所有搜索的值
  115. _isswitch = _keycode == 38 ? -1 : _keycode == 40 ? 1 : null, //如果键盘向上则-1 向下+1
  116. _postion = U.F.S.SearchPostion, //当前选择好友或者去的位置
  117. _nowswitchel = _childs[switchposition] //之前聚焦显示的元素
  118. ;
  119. //判断是否需要重新选择
  120. if (_isswitch || (switchposition != null && switchposition != _postion)) {
  121. //如果需要指定切换到那个位置
  122. if (switchposition != null) {
  123. U.F.S.SearchPostion = switchposition;
  124. }
  125. //上下切换的处理
  126. else {
  127. U.F.S.SearchPostion += _isswitch; //加上上下的处理 如果键盘向上则-1 向下+1
  128. switchposition = U.F.S.SearchPostion;
  129. }
  130. _switchel = _childs[switchposition]; //判断选择好友或者群有没有元素
  131. //选择的位置
  132. if (_switchel) {
  133. _switchel.className = "UD_SYSSZJD UTDF UD_SYSSZJDO"; //取消上一个
  134. _nowswitchel.className = "UD_SYSSZJD UTDF"; //当前聚焦的元素设置
  135. //下面计算需要显示的元素是否在滚动条可见范围,如果不在,那么滚动滚动条设置
  136. _top = _switchel.offsetTop;
  137. _scrolltop = el.scrollTop;
  138. if (_top > el.offsetHeight + _scrolltop - 40) {
  139. el.scrollTop = _top + _UDTD.offsetHeight - el.offsetHeight;
  140. }
  141. if (_top < el.scrollTop) {
  142. el.scrollTop = _top; //滚动条的位置
  143. }
  144. }
  145. else {
  146. //如果位置大于最后一个,则位置设置为最后一个
  147. if (switchposition > _childs.length - 1) {
  148. U.F.S.SearchPostion = _childs.length - 1;
  149. }
  150. if (switchposition < 0) {
  151. U.F.S.SearchPostion = 0; //设置位置
  152. }
  153. }
  154. }
  155. }
  156. /**
  157. * 隐藏
  158. *
  159. * @param {element} 切换元素
  160. * @param {number} 当前所在的位置
  161. */
  162. U.F.S.HideSearchFriendsOrGroupForm = function (el) {
  163. $("body")[0].focus();
  164. el.style.display = "none";
  165. }
  166. //#region 窗体搜索
  167. //弹出群搜索
  168. U.F.S.TCSS = function () {
  169. var _UDTD, _UDOD,
  170. _UDE = U.UI.Form({ resize: U.F.S.SSCTSize, id: "UD_SYF_S",
  171. "style": { "width": "70%", "height": "70%" },
  172. "content": "<div class='UD_SYF_SCT'>群文档查看</div><div class='UD_SYF_SCX'></div><div class='UD_SYF_SCD'></div>",
  173. "title": '<div class="UD_SYF_STO UD_SYF_STR">群文档搜索查看区域</div><div class="UD_SYF_STD" onmousedown="U.M.StopBubble();"><div class="UD_SYF_STDL"><input value="群文档搜索" onblur="U.MR.InputTip(this,[\'\',\'群文档搜索\']);" onfocus="U.MR.InputTip(this,[\'群文档搜索\',\'\']);" placeholder="群文档搜索" onkeyup="U.M.returnkeylogin([{\'obj\': $(this).parentg(2).Child()[1],\'event\':\'onclick\'}])" /></div><div class="UD_SYF_STDR" onclick="U.F.S.SSCT(this, 1, 1)">搜索</div></div>'
  174. }); //生成窗体
  175. _UDOD = _UDE.PSO;
  176. $(_UDOD).find("input")[0].focus();
  177. U.F.S.SSCTSize(_UDE.be);
  178. U.F.S.QHSSCT($(_UDE.body).Child()[1], 1);
  179. return _UDE.be;
  180. }
  181. //Ftp弹出搜索
  182. U.F.S.FTCSS = function () {
  183. var _UDTD, _UDOD,
  184. _UDE = U.UI.Form({ resize: U.F.S.SSCTSize, id: "UD_SYF_F",
  185. "style": { "width": "70%", "height": "70%" },
  186. "content": "<div class='UD_SYF_SCT'>FTP查看</div><div class='UD_SYF_SCX'></div><div class='UD_SYF_SCD'></div>",
  187. "title": '<div class="UD_SYF_STO UD_SYF_STR">FTP共享区域查看</div><div class="UD_SYF_STD" onmousedown="U.M.StopBubble();"><div class="UD_SYF_STDL"><input value="FTP搜索" onblur="U.MR.InputTip(this,[\'\',\'FTP搜索\']);" onfocus="U.MR.InputTip(this,[\'FTP搜索\',\'\']);" placeholder="FTP搜索" onkeyup="U.M.returnkeylogin([{\'obj\': $(this).parentg(2).Child()[1],\'event\':\'onclick\'}])" /></div><div class="UD_SYF_STDR" onclick="U.F.S.SSCT(this, 1, 0)">搜索</div></div>'
  188. }); //生成窗体
  189. _UDOD = _UDE.PSO;
  190. $(_UDOD).find("input")[0].focus();
  191. U.F.S.SSCTSize(_UDE.be);
  192. U.F.S.QHSSCT($(_UDE.body).Child()[1], 0);
  193. return _UDOD;
  194. }
  195. //点击切换查看
  196. U.F.S.QHSSCT = function (UDOD, UIE) {
  197. var _UDID = $(UDOD).parentg(3).find("input")[0],
  198. _searchvalue = _UDID.value;
  199. if (_searchvalue != "" && _searchvalue != _UDID.defaultValue) {
  200. U.F.S.SSCT($("#UD_SYF_S").find(".UD_SYF_STDR")[0], 1);
  201. }
  202. else {
  203. U.F.S.RMQY(1, UIE, UDOD);
  204. }
  205. }
  206. //热门信息滚动加载
  207. U.F.S.RMQYGD = function (UTF, UDOD) {
  208. U.F.S.RMQY(this.P + 2, UTF, UDOD); //滚动加载
  209. }
  210. //获取热门的群或者好友
  211. U.F.S.RMQY = function (UP, UTF, UDOD) {
  212. UP = UP || this.P + 2;
  213. var i, _UE = UP * 80,
  214. _US = _UE - 79;
  215. (UP == 1) && ($(UDOD).Parent().onscroll = U.M.SSCH({ "AF": U.M.apply(null, [[U.F.S.RMQYGD, [UTF, UDOD]]]) }).SCH());
  216. if (UTF) {
  217. U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "RecommendGroups", _US, _UE], U.F.S.AsynRMQY, [UP > 1 ? [$(UDOD).parentg().Child()[2], 1] : [UDOD, true], UDOD, UTF]);
  218. }
  219. else {
  220. U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "GetFtpHotUser", _US, _UE], U.F.S.AsynRMQY, [UP > 1 ? [$(UDOD).parentg().Child()[2], 1] : [UDOD, true], UDOD, UTF]);
  221. }
  222. }
  223. //热门群或者好友获取异步
  224. U.F.S.AsynRMQY = function (r) {
  225. var context = r.context,
  226. _UDOD = context[1],
  227. _UTF = context[2];
  228. r = r.value;
  229. U.F.S.PSSCT(r, _UDOD, _UTF);
  230. if (r.length < 80) { $(_UDOD).Parent().onscroll = null; }
  231. }
  232. //滚动加载
  233. U.F.S.GDSSCT = function (UDOD) {
  234. var _UDE = UDOD.PT,
  235. _UIE = (_UDE[1]++) + 1;
  236. U.F.S.SSCT($(UDOD).parentg(2).find(".UD_SYF_STDR")[0], _UIE);
  237. }
  238. //搜索框点击
  239. U.F.S.SSCT = function (UDOD, UP, UTF) {
  240. UDOD = $(UDOD);
  241. var _UE = UP * 80, _US = _UE - 79,
  242. _UDTD = UDOD.parentg(3).find(".UD_SYF_SCX")[0],
  243. _UDID = UDOD.parentg().find("input")[0], _searchvalue = UP > 1 ? _UDTD.PT[0] : _UDID.value,
  244. _UME = [_searchvalue, _US, _UE];
  245. _UDTD.PT = UP == 1 ? [_searchvalue, 1, UTF] : _UDTD.PT; (UP == 1) && (_UDTD.innerHTML = "");
  246. if (_searchvalue != "" && _searchvalue != _UDID.defaultValue) {
  247. (!UTF && _UME.unshift(US.userInfo.userid || US.NU));
  248. if (UTF) {
  249. U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "SearchGroupInfo", _searchvalue, _US, _UE], U.F.S.AsynSSCT, [UP > 1 ? [$("#UD_SYF_SCD")[0], 1] : [_UDTD, true], UP, _searchvalue, _UDTD, UTF]);
  250. }
  251. else {
  252. U.A.Request(US.CD, [US.DB, "UseStudio_Friends", "SearchFriendInfo", US.userInfo.userid || US.NU, _searchvalue, _US, _UE], U.F.S.AsynSSCT, [UP > 1 ? [$("#UD_SYF_SCD")[0], 1] : [_UDTD, true], UP, _searchvalue, _UDTD, UTF]);
  253. }
  254. // U.A.Request(US.Auth,"UseStudioManage." + (UTF ? "bygroupnameselsectgroup" : "SelectUserByKeyWord"), _UME, U.F.S.AsynSSCT, ([UP > 1 ? [$("#UD_SYF_SCD")[0], 1] : [_UDTD, true], UP, _searchvalue, _UDTD, UTF]));
  255. $(_UDTD).Parent().onscroll = U.M.SSCH({ "AF": U.M.apply(null, [[U.F.S.GDSSCT, [_UDTD[0], UTF]]]) }).SCH();
  256. }
  257. else { U.F.S.RMQY(1, UTF, _UDTD); } //热门查看
  258. }
  259. //搜索异步
  260. U.F.S.AsynSSCT = function (r) {
  261. var context = r.context,
  262. _UP = context[1],
  263. _searchvalue = context[2],
  264. _UDOD = context[3],
  265. _UTF = context[4]; r = r.value;
  266. (_UP == 1) && (_UDOD.innerHTML = "", (!r || !r.length) && (_UDOD.innerHTML = "", U.F.S.SSCTNull(_UDOD)));
  267. if (r && r.length) { U.F.S.PSSCT(r, _UDOD, _UTF) }
  268. else { _UDOD.PT[1]--; };
  269. }
  270. //大小变化使用
  271. U.F.S.SSCTSize = function (UDOD) {
  272. var _UDTD = $(UDOD).find(".UD_SYF_SCX"),
  273. _UDPD = _UDTD.parentg();
  274. _UDTD.css({ "width": Math.floor(_UDPD.width() / 155) * 155 + "px" });
  275. }
  276. //打印搜索内容
  277. U.F.S.PSSCT = function (UDE, UDOD, UTF) {
  278. var i, UDSD, _UDKD, _UDXD,
  279. _userid = US.userInfo.userid || "",
  280. _UDTD = $$("frag"), _
  281. _UCE = UTF ? ["GroupManageName", "GroupManageRemark", "UD_SYF_SCXODT", "点击加入"] : ["UserNickName", "UserIndividualitysignature", "UD_SYF_SCXODO", "点击追随"];
  282. for (i = 0; i < UDE.length; i++) {
  283. _UDSD = $$("div", { "className": "UD_SYF_SCXO", "onclick": UTF ? [[U.M.StopBubble], [U.F.J.OAddGroup, [UDE[i], [[U.D.DT.YYDK, ["Disk", { "userid": _userid, "directoryid": UDE[i].GroupManageID}]]]]]] : [[U.M.StopBubble], [U.D.DT.YYDK, (["Disk", { "userid": UDE[i].UserId, "directoryid": US.FG}])]] }, _UDTD);
  284. _UDKD = $$("div", { "className": "UD_SYF_SCXOT" }, _UDSD);
  285. _UDXD = $$("div", { "className": "UD_SYF_SCXOTL" }, _UDKD);
  286. $$("img", { "onerror": U.M.ImgError, "src": U.M.GetImgU(UDE[i]["UserThumbnailImageHead"]), "title": UDE[i][_UCE[0]], "onclick": UTF ? null : [[U.M.StopBubble], [U.U.I.ViewOtherUserInfo, [UDE[i].UserId]]] }, _UDXD);
  287. $$("div", { "className": "UD_SYF_SCXOTR UTDF", "innerHTML": UDE[i][_UCE[0]] }, _UDKD);
  288. _UDKD = $$("div", { "className": "UD_SYF_SCXOZ" }, _UDSD);
  289. $$("div", { "className": "UD_SYF_SCXOZS", "innerHTML": UDE[i][_UCE[1]] || "暂无简介" }, _UDKD);
  290. $$("div", { "className": "UD_SYF_SCXOZZ", "innerHTML": "全部云分享:<span>" + (UDE[i]["DCount"] < 0 ? 0 : (UDE[i]["DCount"] || 0)) + "</span>" }, _UDKD);
  291. $$("div", { "className": "UD_SYF_SCXOZS", "innerHTML": "目前追随者:" + UDE[i]["FCount"] }, _UDKD);
  292. $$("div", { "className": "UD_SYF_SCXOD " + _UCE[2], "innerHTML": _UCE[3], "onclick": UTF ? [[U.M.StopBubble], [U.F.J.OAddGroup, [UDE[i], [[U.D.DT.YYDK, ["Disk", { "userid": _userid, "directoryid": UDE[i].GroupManageID}]]]]]] : [[U.M.StopBubble], [U.F.M.AddFriend, [UDE[i]]]] }, _UDSD);
  293. }
  294. UDOD.appendChild(_UDTD);
  295. }
  296. //查询群点击
  297. U.F.S.CXQDJ = function (UGID) {
  298. if (!U.U.L.isLogin(3)) {
  299. var _UFE = _$(US.Friend[2]).Select({ "GroupManageID": UGID })[0];
  300. if (_UFE) {
  301. U.D.DT.YYDK("Disk", { "userid": US.userInfo.userid, "directoryid": UGID });
  302. }
  303. else {
  304. U.Alert("请申请加入群查看群信息!");
  305. }
  306. }
  307. }
  308. //空查询
  309. U.F.S.SSCTNull = function (UDOD) {
  310. $$("div", { "className": "UD_SYF_SCXT", "innerHTML": "暂无搜索消息, 请稍候搜索。" }, UDOD);
  311. }
  312. //#endregion