chat.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="apple-mobile-web-app-capable" content="yes" />
  6. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  7. <meta name="theme-color" content="#4b75ff">
  8. <link rel="stylesheet" href="../script/semantic/semantic.min.css">
  9. <script src="../script/jquery.min.js"></script>
  10. <script src="../script/ao_module.js"></script>
  11. <script src="../script/semantic/semantic.min.js"></script>
  12. <script src="message.js"></script>
  13. <link rel="icon" type="image/png" href="img/module_icon.png">
  14. <link rel="manifest" crossorigin="use-credentials" href="manifest.json">
  15. <title>Message</title>
  16. <style>
  17. body{
  18. background-color: rgb(250, 250, 250);
  19. }
  20. .chatdialog{
  21. width: 100%;
  22. display: flex;
  23. padding-top: 0.4em;
  24. }
  25. .self.chatdialog{
  26. justify-content: end;
  27. }
  28. .other.chatdialog{
  29. justify-content: start;
  30. }
  31. .chatbubble{
  32. max-width: 70%;
  33. }
  34. .self.chatdialog .chatbubble{
  35. background: rgb(98,135,254);
  36. background: linear-gradient(120deg, rgba(98,135,254,1) 37%, rgba(67,202,231,1) 100%);
  37. color: white;
  38. }
  39. .other.chatdialog .chatbubble{
  40. }
  41. .chatbubble{
  42. display: inline-block !important;
  43. padding: 7px !important;
  44. padding-left: 12px !important;
  45. padding-right: 12px !important;
  46. }
  47. .chatbubble p{
  48. margin-right: 2em;
  49. }
  50. .chatbubble .timestamp{
  51. float: right;
  52. }
  53. .chatbubble .timestampWrapper{
  54. height: 1em;
  55. }
  56. .sendbar{
  57. position: fixed;
  58. bottom: 0;
  59. left: 0;
  60. width: 100%;
  61. padding: 0.4em;
  62. }
  63. </style>
  64. </head>
  65. <body>
  66. <div class="ui segment" stlye="padding-top: 1em;">
  67. <div style="width: 100%; height: 0.3em;"></div>
  68. <img id="usericon" class="ui avatar mini image" style="margin-top: -0.7em; " src="img/noicon.png">
  69. <div style="display: inline-block; font-size: 1.5rem; margin-left: 0.2em;"><i id="onlineStatus"></i><span id="username">Username</span></div>
  70. </div>
  71. <div id="chatroom" class="ui text container">
  72. <!--
  73. <div class="self chatdialog">
  74. <div class="ui segment chatbubble">
  75. <p>Hello World! How are you today?</p>
  76. <div class="timestampWrapper">
  77. <small class="timestamp">4 Jan 14:25</small>
  78. </div>
  79. </div>
  80. </div>
  81. <div class="other chatdialog">
  82. <div class="ui segment chatbubble">
  83. <p>Good, thanks!</p>
  84. <div class="timestampWrapper">
  85. <small class="timestamp">4 Jan 14:25</small>
  86. </div>
  87. </div>
  88. </div>
  89. -->
  90. </div>
  91. <div class="sendbar">
  92. <div class="ui fluid action input">
  93. <input id="msgInput" type="text" placeholder="Aa">
  94. <button class="ui icon button" style="background-color: #608cfc; color: white;"><i class="chevron right icon"></i></button>
  95. </div>
  96. </div>
  97. <br><br>
  98. <script>
  99. var username = "";
  100. if (window.location.hash.length > 1){
  101. username = window.location.hash.substr(1);
  102. $("#username").text(username);
  103. //Get the user icon
  104. $.get("../system/users/list", function(data){
  105. console.log(data);
  106. data.forEach(function(user){
  107. let thisUsername = user[0];
  108. let usericon = user[2];
  109. if (thisUsername == username){
  110. $("#usericon").attr('src', usericon);
  111. }
  112. });
  113. });
  114. //Update the channel id, see message.js
  115. channelID = username;
  116. }
  117. function updateUserOnlineStatus(lastOnlineTimestamp){
  118. var currentTime = Math.floor(Date.now() / 1000);
  119. if (currentTime - lastOnlineTimestamp > 300){
  120. //Offline
  121. $("#onlineStatus").attr("class", "grey small circle icon");
  122. }else{
  123. //Online
  124. $("#onlineStatus").attr("class", "green small circle icon");
  125. }
  126. }
  127. //RPC callback events
  128. rpcCallback = function(data){
  129. console.log(data);
  130. updateUserOnlineStatus(data.oppositeLastOnlineTime);
  131. }
  132. //Manually start the first request on page load
  133. updateStatus();
  134. </script>
  135. </body>
  136. </html>