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.

113 lines
2.7 KiB

  1. function scrollAllTalks() {
  2. var mes = document.querySelectorAll('.messages');
  3. for (var i=0; i<mes.length; i++){
  4. // We add 200px to prevent smiley loading
  5. mes.item(i).scrollTop = mes.item(i).scrollHeight + 200;
  6. }
  7. }
  8. function scrollTalk(params) {
  9. var messages = document.getElementById(params);
  10. messages.scrollTop = messages.scrollHeight;
  11. }
  12. //Loads the Notification sound.
  13. /*var chatSoundNotif = document.createElement('audio');
  14. chatSoundNotif.setAttribute('src', './system/Widget/widgets/Chat/sound/notif.ogg');
  15. chatSoundNotif.load();
  16. chatSoundNotif.volume = 1;*/
  17. movim_add_onload(function()
  18. {
  19. scrollAllTalks();
  20. });
  21. function colorTalk(params) {
  22. messages = document.getElementById(params);
  23. tabstyle = messages.parentNode.parentNode.querySelector('.tab').className = 'tab alert';
  24. }
  25. function showTalk(n) {
  26. panel = n.parentNode.querySelector('.panel');
  27. panel.style.display = 'block';
  28. n.style.display = 'none';
  29. n.className = 'tab';
  30. }
  31. function hideTalk(n) {
  32. panel = n.parentNode.parentNode.parentNode.querySelector('.panel');
  33. tab = n.parentNode.parentNode.parentNode.querySelector('.tab');
  34. panel.style.display = 'none';
  35. tab.style.display = 'block';
  36. }
  37. function showComposing(jid) {
  38. var box = document.getElementById('messages' + jid);
  39. var composing = document.getElementById('composing' + jid);
  40. hidePaused(jid);
  41. box.appendChild(composing);
  42. composing.style.display = 'block';
  43. }
  44. function showPaused(jid) {
  45. var box = document.getElementById('messages' + jid);
  46. var paused = document.getElementById('paused' + jid);
  47. hideComposing(jid);
  48. box.appendChild(paused);
  49. paused.style.display = 'block';
  50. }
  51. function notify() {
  52. if(document_focus == false) {
  53. movim_title_inc();
  54. //play the notif sound
  55. /*chatSoundNotif.pause();
  56. chatSoundNotif.currentTime= 0;
  57. chatSoundNotif.play();*/
  58. }
  59. }
  60. function hideComposing(jid) {
  61. var composing = document.getElementById('composing' + jid);
  62. composing.style.display = 'none';
  63. }
  64. function hidePaused(jid) {
  65. var paused = document.getElementById('paused' + jid);
  66. paused.style.display = 'none';
  67. }
  68. function sendMessage(n, jid)
  69. {
  70. var text = n.value;
  71. n.value = "";
  72. n.focus();
  73. // We escape the text to prevent XML errors
  74. return encodeURIComponent(text);
  75. }
  76. function sendEncryptedMessage(n, jid)
  77. {
  78. var text = JSON.parse(sjcl.encrypt(n.dataset.publickey,n.value)).iv;
  79. n.value = "";
  80. n.focus();
  81. // We escape the text to prevent XML errors
  82. return encodeURIComponent(text);
  83. }
  84. function disableSound(){
  85. chatSoundNotif.volume = 0;
  86. }