index.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <!doctype html>
  2. <meta charset="utf-8">
  3. <title>Zammad Chat</title>
  4. <link rel="stylesheet" href="chat.css">
  5. <meta name="viewport" content="width=device-width">
  6. <script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35738/livereload.js?snipver=1"></' + 'script>')</script>
  7. <style>
  8. body {
  9. margin: 0;
  10. font-family: sans-serif;
  11. }
  12. .mockup {
  13. vertical-align: bottom;
  14. }
  15. .settings {
  16. position: fixed;
  17. left: 20px;
  18. top: 20px;
  19. background: white;
  20. font-size: 14px;
  21. padding: 10px;
  22. border-radius: 5px;
  23. box-shadow: 0 3px 10px rgba(0,0,0,.3);
  24. }
  25. .settings input {
  26. vertical-align: middle;
  27. }
  28. .settings input + input {
  29. margin-right: 3px;
  30. }
  31. table td:first-child {
  32. text-align: right;
  33. padding-right: 0;
  34. }
  35. td {
  36. padding: 5px;
  37. }
  38. h2 {
  39. font-size: 1em;
  40. margin: 0;
  41. }
  42. @media only screen and (max-width: 768px) {
  43. .settings {
  44. display: none;
  45. }
  46. }
  47. .Box {
  48. background: hsl(0,0%,91%);
  49. width: 26px;
  50. height: 24px;
  51. color: hsl(0,0%,47%);
  52. float: left;
  53. }
  54. .Box.Active {
  55. background: hsl(0,0%,36%);
  56. color: white;
  57. }
  58. </style>
  59. <img class="mockup" width="100%" src="website.png">
  60. <div class="settings">
  61. <table>
  62. <tr>
  63. <td>
  64. <td><h2>Settings</h2>
  65. <tr>
  66. <td>
  67. <input id="flat" type="checkbox" data-option="flat">
  68. <td>
  69. <label for="flat">Flat Design</label>
  70. <tr>
  71. <td>
  72. <input type="color" id="color" value="#AE99D6" data-option="color">
  73. <td>
  74. <label for="color">Color</label>
  75. <tr>
  76. <td>
  77. <input type="range" id="borderRadius" value="5" min="0" max="20" data-option="borderRadius">
  78. <input type="number" value="5" min="5" max="20" data-option="borderRadius">px
  79. <td>
  80. <label for="borderRadius">Border Radius</label>
  81. <tr>
  82. <td>
  83. <input type="range" id="fontSize" value="12" min="11" max="18" data-option="fontSize">
  84. <input type="number" value="12" min="11" max="18" data-option="fontSize">px
  85. <td>
  86. <label for="fontSize">Font Size</label>
  87. <tr>
  88. <td>
  89. <td><button class="open-zammad-chat">Open Chat</button>
  90. </table>
  91. </div>
  92. <script src="jquery-2.1.4.min.js"></script>
  93. <!--
  94. <script src="node_modules/sass.js/dist/sass.js"></script>
  95. -->
  96. <script src="chat.js"></script>
  97. <!--
  98. <script>
  99. var sass = new Sass();
  100. var scss = '';
  101. var $scss = $('<style id="scss"></style>').appendTo('body');
  102. $.get('style.scss', function(result){ scss = result });
  103. function setScssVariable(name, value){
  104. if(!scss){
  105. return 'scss file not yet loaded';
  106. }
  107. scss = scss.replace(new RegExp('(\\$'+ name +':\ ).*(;)'), '$1'+ value +'$2');
  108. }
  109. function updateStyle(){
  110. if(!scss){
  111. return 'scss file not yet loaded';
  112. }
  113. sass.compile(scss, function(result) {
  114. if(result.status != 0){
  115. // error
  116. console.error(result.formatted);
  117. } else {
  118. $scss.text(result.text);
  119. }
  120. });
  121. }
  122. -->
  123. <script>
  124. var chat = new ZammadChat({
  125. chatId: 1,
  126. host: 'ws://localhost:6042',
  127. debug: true
  128. });
  129. $('.settings :input').on({
  130. change: function(){
  131. switch($(this).attr('data-option')){
  132. case "flat":
  133. $('.zammad-chat').toggleClass('zammad-chat--flat', this.checked);
  134. break;
  135. case "color":
  136. setScssVariable('themeColor', this.value);
  137. updateStyle();
  138. break;
  139. case "borderRadius":
  140. setScssVariable('borderRadius', this.value + "px");
  141. updateStyle();
  142. break;
  143. }
  144. },
  145. input: function(){
  146. switch($(this).attr('data-option')){
  147. case "borderRadius":
  148. $('[data-option="borderRadius"]').val(this.value);
  149. setScssVariable('borderRadius', this.value + "px");
  150. updateStyle();
  151. break;
  152. case "fontSize":
  153. $('[data-option="fontSize"]').val(this.value);
  154. setScssVariable('fontSize', this.value + "px");
  155. updateStyle();
  156. break;
  157. }
  158. }
  159. });
  160. </script>