header_frame.inc.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. ?>
  35. <!DOCTYPE html>
  36. <html>
  37. <head>
  38. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>">
  39. <title>Chat</title>
  40. <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CSS_PATH).$my_style; ?>/default.css">
  41. <script type="text/javascript" language="javascript">
  42. function updateChat() {
  43. if ('<?php echo $chat_size_old; ?>' != '<?php echo $chat_size_new; ?>')
  44. {
  45. parent.chat_chat.location.href='chat_chat.php?size=<?php echo $chat_size_new.'&'.api_get_cidreq(); ?>#bottom';
  46. }
  47. }
  48. function updateConnected() {
  49. if ('<?php echo $connected_old; ?>' != '<?php echo $connected_new; ?>')
  50. {
  51. parent.chat_whoisonline.location.href='chat_whoisonline.php?size=<?php echo $connected_new; ?>';
  52. }
  53. }
  54. function submitHiddenForm() {
  55. document.formHidden.submit();
  56. }
  57. function eventMessage() {
  58. <?php if($chat_size): ?>
  59. parent.chat_hidden.document.formHidden.chat_size_old.value='<?php echo $chat_size; ?>';
  60. parent.chat_chat.location.href='chat_chat.php?size=<?php echo $chat_size.'&'.api_get_cidreq(); ?>#bottom';
  61. <?php endif; ?>
  62. document.formMessage.message.focus();
  63. }
  64. function send_message(evenement) {
  65. for (prop in evenement) {
  66. if(prop == 'which') touche = evenement.which; else touche = evenement.keyCode;
  67. }
  68. if (touche == 13) {
  69. document.formMessage.submit();
  70. }
  71. }
  72. </script>
  73. </head>
  74. <body <?php echo $bodyXtra; ?> >