You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.5 KiB

  1. var Chats = {
  2. refresh: function() {
  3. var items = document.querySelectorAll('ul#chats_widget_list li:not(.subheader)');
  4. var i = 0;
  5. while(i < items.length)
  6. {
  7. if(items[i].dataset.jid != null) {
  8. items[i].onclick = function(e) {
  9. Rooms.refresh();
  10. Chat_ajaxGet(this.dataset.jid);
  11. Chats.reset(items);
  12. Notification_ajaxClear('chat|' + this.dataset.jid);
  13. Notification.current('chat|' + this.dataset.jid);
  14. movim_add_class(this, 'active');
  15. }
  16. items[i].onmousedown = function(e) {
  17. if(e.which == 2) {
  18. Chats_ajaxClose(this.dataset.jid);
  19. MovimTpl.hidePanel();
  20. }
  21. }
  22. }
  23. movim_remove_class(items[i], 'active');
  24. i++;
  25. }
  26. //Chat_ajaxGet();
  27. /*if(window.innerWidth > 1024 && !MovimTpl.isPanel()) {
  28. Notification.notifs_key = 'chat|' + items[0].dataset.jid;
  29. Notification_ajaxCurrent(Notification.notifs_key);
  30. items[0].click();
  31. }*/
  32. },
  33. reset: function(list) {
  34. for(i = 0; i < list.length; i++) {
  35. movim_remove_class(list[i], 'active');
  36. }
  37. }
  38. }
  39. movim_add_onload(function(){
  40. Notification.current('chat');
  41. });
  42. MovimWebsocket.attach(function() {
  43. Chats.refresh();
  44. });