znuny.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <!doctype html>
  2. <html lang="de-de">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Zammad Chat</title>
  6. <link rel="stylesheet" href="znuny.css">
  7. <meta name="viewport" content="width=device-width,initial-scale=1.0">
  8. <style>
  9. body {
  10. margin: 0;
  11. font-family: sans-serif;
  12. }
  13. .mockup {
  14. vertical-align: bottom;
  15. }
  16. .settings {
  17. position: fixed;
  18. left: 20px;
  19. top: 20px;
  20. background: white;
  21. font-size: 14px;
  22. padding: 10px;
  23. border-radius: 5px;
  24. box-shadow: 0 3px 10px rgba(0,0,0,.3);
  25. width: 500px;
  26. }
  27. .settings input {
  28. vertical-align: middle;
  29. }
  30. .settings input + input {
  31. margin-right: 3px;
  32. }
  33. table td:first-child {
  34. text-align: right;
  35. padding-right: 0;
  36. }
  37. table td.log {
  38. text-align: left;
  39. padding-right: 0;
  40. word-break: break-all;
  41. }
  42. td {
  43. padding: 5px;
  44. }
  45. h2 {
  46. font-size: 1em;
  47. margin: 0;
  48. }
  49. @media only screen and (max-width: 768px) {
  50. .settings {
  51. display: none;
  52. }
  53. }
  54. .Box {
  55. background: hsl(0,0%,91%);
  56. width: 26px;
  57. height: 24px;
  58. color: hsl(0,0%,47%);
  59. float: left;
  60. }
  61. .Box.Active {
  62. background: hsl(0,0%,36%);
  63. color: white;
  64. }
  65. </style>
  66. </head>
  67. <body>
  68. <img class="mockup" width="100%" src="znuny.png">
  69. <img class="mockup" width="100%" src="znuny.png">
  70. <img class="mockup" width="100%" src="znuny.png">
  71. <img class="mockup" width="100%" src="znuny.png">
  72. <img class="mockup" width="100%" src="znuny.png">
  73. <img class="mockup" width="100%" src="znuny.png">
  74. <img class="mockup" width="100%" src="znuny.png">
  75. <img class="mockup" width="100%" src="znuny.png">
  76. <img class="mockup" width="100%" src="znuny.png">
  77. <img class="mockup" width="100%" src="znuny.png">
  78. <img class="mockup" width="100%" src="znuny.png">
  79. <img class="mockup" width="100%" src="znuny.png">
  80. <div class="settings">
  81. <table>
  82. <tr>
  83. <td><h2>Settings</h2>
  84. <td>
  85. <tr>
  86. <td>
  87. <input id="flat" type="checkbox" data-option="flat">
  88. <td>
  89. <label for="flat">Flat Design</label>
  90. <tr>
  91. <td>
  92. <input type="color" id="color" value="#AE99D6" data-option="color">
  93. <td>
  94. <label for="color">Color</label>
  95. <tr>
  96. <td>
  97. <input type="range" id="borderRadius" value="5" min="0" max="20" data-option="borderRadius">
  98. <input type="number" value="5" min="5" max="20" data-option="borderRadius">px
  99. <td>
  100. <label for="borderRadius">Border Radius</label>
  101. <tr>
  102. <td>
  103. <input type="range" id="fontSize" value="12" min="11" max="18" data-option="fontSize">
  104. <input type="number" value="12" min="11" max="18" data-option="fontSize">px
  105. <td>
  106. <label for="fontSize">Font Size</label>
  107. <tr>
  108. <td>
  109. <td><button class="open-zammad-chat">Open Chat</button>
  110. <tr>
  111. <td class="log"><h2>Log</h2>
  112. <td>
  113. <tr>
  114. <td colspan="2" class="log js-chatLogDisplay">
  115. </table>
  116. </div>
  117. <script src="jquery-3.6.0.min.js"></script>
  118. <script src="chat.js"></script>
  119. <script>
  120. function getSearchParameters() {
  121. var prmstr = window.location.search.substr(1);
  122. return prmstr != null && prmstr != '' ? transformToAssocArray(prmstr) : {};
  123. }
  124. function transformToAssocArray( prmstr ) {
  125. var params = {};
  126. var prmarr = prmstr.split('&');
  127. for ( var i = 0; i < prmarr.length; i++) {
  128. var tmparr = prmarr[i].split('=');
  129. params[tmparr[0]] = tmparr[1];
  130. }
  131. return params;
  132. }
  133. var hostname = window.location.hostname;
  134. var port = window.location.port;
  135. var protocol = window.location.protocol;
  136. var wsProtocol = protocol === 'https:' ? 'wss:' : 'ws:';
  137. var params = getSearchParameters();
  138. var host = wsProtocol + '//'+ (location.host || 'localhost').split(':')[0] +':6042'
  139. if (params['port']) {
  140. host = wsProtocol + '//' + hostname + ':' + params['port']
  141. }
  142. cssUrl = protocol + '//' + hostname + ':' + port + '/assets/chat/chat.css'
  143. var chat = new ZammadChat({
  144. chatId: 1,
  145. host: host,
  146. cssUrl: cssUrl,
  147. debug: true,
  148. background: '#494d52',
  149. flat: true,
  150. idleTimeout: 0.2,
  151. idleTimeoutIntervallCheck: 0.21,
  152. inactiveTimeout: 0.3,
  153. inactiveTimeoutIntervallCheck: 0.31,
  154. waitingListTimeout: 0.1,
  155. waitingListTimeoutIntervallCheck: 0.11,
  156. });
  157. $('.settings :input').on({
  158. change: function(){
  159. switch($(this).attr('data-option')){
  160. case "flat":
  161. $('.zammad-chat').toggleClass('zammad-chat--flat', this.checked);
  162. break;
  163. case "color":
  164. setScssVariable('themeColor', this.value);
  165. updateStyle();
  166. break;
  167. case "borderRadius":
  168. setScssVariable('borderRadius', this.value + "px");
  169. updateStyle();
  170. break;
  171. }
  172. },
  173. input: function(){
  174. switch($(this).attr('data-option')){
  175. case "borderRadius":
  176. $('[data-option="borderRadius"]').val(this.value);
  177. setScssVariable('borderRadius', this.value + "px");
  178. updateStyle();
  179. break;
  180. case "fontSize":
  181. $('[data-option="fontSize"]').val(this.value);
  182. setScssVariable('fontSize', this.value + "px");
  183. updateStyle();
  184. break;
  185. }
  186. }
  187. });
  188. </script>
  189. </body>
  190. </html>