Guest User

Untitled

a guest
Feb 22nd, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5. <style>
  6. button {
  7. width: 60px;
  8. cursor: pointer;
  9. }
  10.  
  11. .a-btn:after {
  12. content: "Play";
  13. }
  14.  
  15. .a-btn-restart:after {
  16. content: "Restart";
  17. }
  18.  
  19. .a-btn.a-btn-on {
  20. background-color: lightblue;
  21. }
  22.  
  23. .a-btn.a-btn-on::after {
  24. content: "Pause";
  25. }
  26. </style>
  27. </head>
  28.  
  29. <body>
  30.  
  31. <progress id="a-progress" min="0" max="100" value="0"></progress>
  32. <button id="a-rwd">rwd</button>
  33. <button id="a-play" class="a-btn"></button>
  34. <button id="a-ffw">ffw</button>
  35. <input id="a-slider" type="range" min="1" max="10" value="1">
  36. <script>
  37. var variable = function (element, attr) {
  38.  
  39. return function () {
  40. if (arguments.length > 0)
  41. element.value = arguments[0];
  42.  
  43. else return element.value;
  44. }
  45.  
  46. }
  47. var i = new variable(document.getElementById("a-progress"));
  48. var s = document.getElementById("a-slider").value * 100;
  49. var id;
  50. var max = document.getElementById("a-progress").max;
  51. var pause = true;
  52.  
  53. function intervalFunc() {
  54. i(i() + 1);
  55. if (i() >= max || i() <= 0) {
  56. pause = true;
  57. document.getElementById("a-play").className = "a-btn-restart";
  58. clearInterval(id);
  59.  
  60. }
  61. if (pause === true) {
  62. clearInterval(id);
  63. }
  64. }
  65.  
  66. document.getElementById("a-play").addEventListener('click', function () {
  67. if (this.className === "a-btn-restart") {
  68. this.className = "a-btn";
  69. i(0);
  70. }
  71. this.classList.toggle("a-btn-on");
  72. pause = !pause;
  73. if (pause) return;
  74. id = setInterval(intervalFunc, s);
  75.  
  76. });
  77.  
  78. document.getElementById("a-ffw").addEventListener('click', function () {
  79. if (i() < max - 5)
  80. i(i() + 5);
  81. });
  82.  
  83. document.getElementById("a-rwd").addEventListener('click', function () {
  84. if (i() > 5)
  85. i(i() - 5);
  86. });
  87. document.getElementById("a-slider").addEventListener('change', function(){
  88. clearInterval(id);
  89. s = this.value * 100;
  90. id = setInterval(intervalFunc, s);
  91. });
  92. </script>
  93.  
  94. </body>
  95.  
  96. </html>
Add Comment
Please, Sign In to add comment