Nizax

Untitled

Mar 17th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Hugougo</title>
  4. <style>
  5. a {text-decoration: none;}
  6. html, body { margin:0; }
  7. </style>
  8. </head>
  9. <body>
  10.  
  11. <script src="/socket.io/socket.io.js"></script>
  12. <script>
  13. document.body.style.backgroundColor = 'transparent';
  14. document.body.style.opacity = '1';
  15. let player = document.createElement('h1');
  16. player.style = 'position:relative;top:5%;width:100%;text-align:center;color:white;font-size:30px; font-family:Calibri;';
  17. player.innerHTML = 'Napisz !hugo aby zagrać';
  18. let buttons = document.createElement('div');
  19. buttons.style = 'position:relative;width:100%;margin:0;visibility:hidden;top:3%;';
  20.  
  21. const socket = io();
  22.  
  23. socket.on('button', (data) => {
  24. let b = document.createElement('div');
  25. b.innerHTML = data;
  26. b.style = 'position:relative;border: 2px solid #ffd700;text-align:center;border-radius: 50px;color:#ffd700;font-size:30px; font-family:Calibri;display: block; margin-left: auto; margin-right: auto;';
  27. b.style['margin-top'] = (window.innerHeight/30)+'px';
  28. b.style['margin-bottom'] = (window.innerHeight/30)+'px';
  29. buttons.prepend(b);
  30. b.style['height'] = (window.innerHeight/15)+'px';
  31. b.style['width'] = (window.innerWidth/12)+'px';
  32. b.style['line-height'] = ((b.style['height']+b.style['width'])/1.5)+'px';
  33. });
  34. socket.on('start', (data) => {
  35. if(data.flag == 1) {
  36. player.innerHTML = 'Teraz gra: ' + data.nickname;
  37. buttons.style['visibility'] = 'visible';
  38. } else {
  39. buttons.style['visibility'] = 'hidden';
  40. buttons.innerHTML = '';
  41. player.innerHTML = 'Napisz !hugo aby zagrać';
  42. }
  43. });
  44.  
  45. document.body.append(player);
  46. document.body.append(buttons);
  47.  
  48. this.hugoS = function (data) {
  49. if(data[0] == 1) {
  50. player.innerHTML = 'Teraz gra: ' + data[1];
  51. buttons.style['visibility'] = 'visible';
  52. } else {
  53. buttons.style['visibility'] = 'hidden';
  54. buttons.innerHTML = '';
  55. player.innerHTML = 'Napisz !hugo aby zagrać';
  56. }
  57. }
  58. this.hugoB = function (data) {
  59. let a = document.createElement('div');
  60. let b = document.createElement('div');
  61. b.innerHTML = data;
  62. a.style = 'display: block; margin-left: auto; margin-right: auto;height: 6%; background-color: rgb(244, 88, 10);border: 3px solid black;border-radius: 3px;margin-top:1%;margin-bottom:1%';
  63. if(window.innerWidth < 200)
  64. a.style['width'] = '20%';
  65. else if(window.innerWidth < 300)
  66. a.style['width'] = '15%';
  67. else if(window.innerWidth < 500)
  68. a.style['width'] = '10%';
  69. else if(window.innerWidth < 800)
  70. a.style['width'] = '7%';
  71. else
  72. a.style['width'] = '6%';
  73. b.style = 'display: block; margin-left: auto; margin-right: auto;top:50%; transform: translateY(-50%);position: relative; text-align: center; border-radius: 50px; background-color: rgb(40, 40, 40); font-size: 185%;line-height: -1%;font-family: Calibri;color:white;width:90%;height:90%;';
  74.  
  75. a.append(b);
  76. buttons.prepend(a);
  77. }
  78.  
  79. player.onmouseenter = function () {
  80. player.style['background-color'] = 'gray';
  81. };
  82. player.onmouseleave = function () {
  83. player.style['background-color'] = '';
  84. };
  85.  
  86. buttons.onmouseenter = function() {
  87. buttons.style['background-color'] = 'gray';
  88. }
  89. buttons.onmouseleave = function() {
  90. buttons.style['background-color'] = '';
  91. }
  92.  
  93. let bodyDance;
  94. let r = Math.random()*1000;
  95. let g = Math.random()*1000;
  96. let b = Math.random()*1000;
  97. document.body.onclick = function (e) {
  98. if(e.path.length < 5) {
  99. console.log('start bodyDance');
  100. let i=0;
  101. setInterval( function() {
  102. /*
  103. Math.abs(Math.sin(i*r/10))*60+15
  104. Math.abs(Math.sin(i*r/10))*165+180
  105. Math.abs(Math.sin(i*b/10))*60+15
  106. */
  107. document.body.setAttribute('style','background-color: rgb('+ Math.abs(Math.sin(i*r/10))*60+15 +','+Math.abs(Math.sin(i*g/10))*165+180+','+Math.abs(Math.sin(i*b/10))*60+15+')');
  108. i++;
  109. }, 100);
  110. } else {
  111. let index = e.path.length - 5;
  112. /*if(e.path[index].tagName == 'DIV')
  113. // guziki
  114. else if (e.path[index].tagName == 'H1')
  115. // player
  116. */
  117. }
  118. };
  119.  
  120. /*
  121. R: 15-90
  122. G: 180-255
  123. B: 15-90
  124. */
  125.  
  126. </script>
  127.  
  128. </body>
  129. </html>
Advertisement
Add Comment
Please, Sign In to add comment