header_frame.inc.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Header of each frame of the Chat tool
  5. *
  6. * @author Olivier Brouckaert
  7. * Modified by Denes Nagy
  8. * @package chamilo.chat
  9. */
  10. /**
  11. * Code
  12. */
  13. if (!defined('FRAME')) {
  14. exit();
  15. }
  16. $bodyXtra = ' class="course_chat" dir="'.api_get_text_direction().'" ';
  17. if (FRAME == 'hidden') {
  18. $bodyXtra .= 'onload="javascript: updateChat(); updateConnected(); setTimeout(\'submitHiddenForm();\', 5000);"';
  19. // Change timeout to change refresh time of the chat window
  20. } elseif (FRAME == 'message') {
  21. $bodyXtra .= 'onload="javascript: eventMessage();"';
  22. }
  23. $mycourseid=api_get_cidreq();
  24. if (empty($mycourseid)) {
  25. // If it is not set $mycourse id we reload the chat_message window in order to hide the textarea to submit a message.
  26. echo '<script type="text/javascript" language="javascript">';
  27. echo "parent.chat_message.location.href='chat_whoisonline.php?".api_get_cidreq()."';";
  28. echo '</script>';
  29. }
  30. /*
  31. * Choose CSS style (platform's, user's, or course's)
  32. */
  33. $my_style = api_get_visual_theme();
  34. $chat_size_old = isset($chat_size_old) ? $chat_size_old : null;
  35. $chat_size_new = isset($chat_size_new) ? $chat_size_new : null;
  36. $connected_new = isset($connected_new) ? $connected_new : null;
  37. $connected_old = isset($connected_old) ? $connected_old : null;
  38. header('Content-Type: text/html; charset='.api_get_system_encoding());
  39. ?><!DOCTYPE html>
  40. <html>
  41. <head>
  42. <meta charset="<?php echo api_get_system_encoding(); ?>" />
  43. <title>Chat</title>
  44. <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CSS_PATH); ?>chat.css">
  45. <?php echo api_get_js('jquery.min.js'); ?>
  46. <?php echo api_get_js('jquery.tinyscrollbar.js'); ?>
  47. <script type="text/javascript">
  48. $(document).ready(function(){
  49. $('#user-online-scroll').tinyscrollbar();
  50. });
  51. function play_notification() {
  52. document.getElementById('audio').play();
  53. }
  54. function updateChat(){
  55. if ('<?php echo $chat_size_old; ?>' != '<?php echo $chat_size_new; ?>') {
  56. parent.chat_chat.location.href='chat_chat.php?size=<?php echo $chat_size_new.'&'.api_get_cidreq(); ?>#bottom';
  57. play_notification();
  58. }
  59. }
  60. function updateConnected(){
  61. if ('<?php echo $connected_old; ?>' != '<?php echo $connected_new; ?>'){
  62. parent.chat_whoisonline.location.href='chat_whoisonline.php?size=<?php echo $connected_new; ?>';
  63. }
  64. }
  65. function submitHiddenForm(){
  66. document.formHidden.submit();
  67. }
  68. function eventMessage(){
  69. <?php if (isset($chat_size) && $chat_size): ?>
  70. parent.chat_hidden.document.formHidden.chat_size_old.value='<?php echo $chat_size; ?>';
  71. parent.chat_chat.location.href='chat_chat.php?size=<?php echo $chat_size.'&'.api_get_cidreq(); ?>#bottom';
  72. <?php endif; ?>
  73. document.formMessage.message.focus();
  74. }
  75. function send_message(keyEvent) {
  76. for (prop in keyEvent) {
  77. if(prop == 'which') key = keyEvent.which; else key = keyEvent.keyCode;
  78. }
  79. if (key == 13) {
  80. document.formMessage.submit();
  81. }
  82. }
  83. </script>
  84. </head>
  85. <body <?php echo $bodyXtra; ?> >