orgTimeIndex.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. var blinkTime;
  2. var titleTipTime;
  3. function sendTimeMsgCount(){
  4. try{
  5. var toUserStr = $("#currentUserId").val();
  6. var param = {'type':"timeMsg"};
  7. if(toUserStr){
  8. sendAsyncAjax(param,"loadOrgIndex.do?t="+new Date().getTime(),"json",loadTimeMsgCountProcess,loadTimeMsgCountError);
  9. }
  10. }catch(e){}
  11. }
  12. function loadTimeMsgCountProcess(data){
  13. var imCount = 0;
  14. var msgCount = 0;
  15. var emailCount = 0;
  16. var onlineCount = 0;
  17. try{
  18. if(data!=null){
  19. imCount = data.imCount;
  20. msgCount = data.msgCount;
  21. emailCount = data.emailCount;
  22. onlineCount = data.onlineCount;
  23. }
  24. if(imCount>0){
  25. if(!blinkTime){
  26. blink();
  27. }
  28. // if(!titleTipTime){
  29. myThreadProcess();
  30. // }
  31. }else{
  32. window.top.document.title=$("#topTitle").val();
  33. clearTimeout(titleTipTime);
  34. clearTimeout(blinkTime);
  35. im_imgCount.style.visibility = "visible";
  36. }
  37. loadTimeOnlineProcess(onlineCount);
  38. $("#imCount").html(imCount);
  39. $("#msgCount").html(msgCount);
  40. $("#emailCount").html(emailCount);
  41. }catch(e){
  42. $("#imCount").html(0);
  43. $("#msgCount").html(0);
  44. $("#emailCount").html(0);
  45. }
  46. }
  47. function myThreadProcess(){
  48. try{
  49. var topTitle = $("#topTitle").val();
  50. var str = "[      ]"+topTitle;
  51. var msg = "[您有新的会话]"+topTitle;
  52. if(window.top.document.title==str){
  53. window.top.document.title=msg;
  54. }else{
  55. window.top.document.title=str;
  56. }
  57. titleTipTime = setTimeout("myThreadProcess()",500);
  58. }catch(e){
  59. }
  60. }
  61. function blink() {
  62. im_imgCount.style.visibility = (im_imgCount.style.visibility == "hidden") ? "visible" : "hidden";
  63. blinkTime = setTimeout("blink()", 500);
  64. }
  65. function loadTimeMsgCountError(request,msg){
  66. var text = request.responseText;
  67. if(text!=undefined&&text.indexOf("SYSTEM_TIMEOUT_ERROR")!=-1){
  68. $("body").html("<div style='margin:50px auto;text-align:center'>"+text+"</div>");
  69. }
  70. }
  71. function loadTimeOnlineProcess(data){
  72. try{
  73. var onlineObj = $("#online",window.top.document);
  74. $(onlineObj).parent().show();
  75. var oldCount = $(onlineObj).html();
  76. oldCount = parseInt(oldCount,10);
  77. if(oldCount != data){
  78. $(onlineObj).html(data);
  79. olineObj = onlineTree();
  80. if(orgObj){
  81. orgTree();
  82. }
  83. if(groupObj){
  84. groupTree();
  85. }
  86. }
  87. }catch(e){}
  88. }