Guest User

Untitled

a guest
Feb 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <title>SVG</title>
  6. <style>
  7. body { margin: 0; }
  8. #content { left: 300px; overflow: hidden; position: absolute; right: 30px; top: 30px; }
  9. svg { position: absolute; right: 0; top: 0; }
  10. rect { height: 20px; stroke-width: 1px; stroke: #fff; }
  11. .suc { fill: #93c47d; }
  12. .suf { fill: #d9d9d9; }
  13. .wrn { fill: #f6b26b; }
  14. .stf { fill: #ff0000; }
  15. </style>
  16. </head>
  17. <body>
  18. <div id="page"><div id="content"><svg></svg></div></div>
  19.  
  20. <!-- <g transform="scale(-1,1)></g> -->
  21.  
  22. <script>
  23. (function () {
  24. var [ height, size, half, max ] = [ 30, 20, 10, 0 ];
  25. var d = document.querySelector("#content");
  26. var s = document.querySelector("svg");
  27. for (var i = 0; i < 150; i += 1) {
  28. var h = `<g class="item" transform="translate(0,${i*height})">`;
  29. for (var j = 0, k = 0; j < 72; j += 1) {
  30. var w, c;
  31. if (j== 39) {
  32. w = size;
  33. c = "suf";
  34. } else if (j===50 || j===51 || j===55) {
  35. w = size;
  36. c = "wrn";
  37. } else if (j===52 || j===53 || j===56) {
  38. w = half;
  39. c = "stf";
  40. } else {
  41. c = "suc";
  42. w = size;
  43. }
  44. h += `<rect class="${c}" x="${k}" y="1" height="${size}" width="${w}"/></rect>`;
  45. k += w;
  46. }
  47. max = Math.max(max, k);
  48. h += "</g>";
  49. s.insertAdjacentHTML("beforeend", h);
  50. }
  51. s.setAttribute("width", max);
  52. s.setAttribute("height", i*height);
  53. d.style.height = `${i*height}px`;
  54. setInterval(function () {
  55. var R = document.querySelectorAll("rect");
  56. for (var i=0; i<R.length; i+=1) {
  57. var r = R[i], x = r.getAttribute("x");
  58. x -= 1;
  59. if (x < -20) {
  60. r.parentNode.removeChild(r);
  61. } else {
  62. r.setAttribute("x", r.getAttribute("x") - 1);
  63. }
  64. }
  65. s.setAttribute("width", 1 + parseInt(s.getAttribute("width"), 10));
  66. }, 1000);
  67. }());
  68. </script>
  69. </body>
  70. </html>
Add Comment
Please, Sign In to add comment