Guest User

Untitled

a guest
Feb 25th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head lang="en">
  4. <meta charset="UTF-8" />
  5. <title>Liquid Fill Gauge Clock</title>
  6. <script src="//d3js.org/d3.v3.min.js"></script>
  7. <script src="//bl.ocks.org/brattonc/raw/5e5ce9beee483220e2f6/liquidFillGauge.js"></script>
  8. <style>
  9. .liquidFillGaugeText {
  10. font-family: Helvetica;
  11. font-weight: bold;
  12. }
  13. </style>
  14. </head>
  15. <body>
  16. <svg id="fillgauge" width="100%" height="500"></svg>
  17. <script language="JavaScript">
  18. var config = liquidFillGaugeDefaultSettings();
  19. config.minValue = 0;
  20. config.maxValue = 12;
  21. config.displayPercent = false;
  22. config.circleThickness = 0.15;
  23. config.circleColor = "#808015";
  24. config.textColor = "#555500";
  25. config.waveTextColor = "#FFFFAA";
  26. config.waveColor = "#AAAA39";
  27. config.textVertPosition = 0.8;
  28. config.waveAnimateTime = 1000;
  29. config.waveHeight = 0.05;
  30. config.waveAnimate = true;
  31. config.waveRise = true;
  32. config.waveHeightScaling = false;
  33. config.waveOffset = 0.25;
  34. config.textSize = 0.75;
  35. config.waveCount = 3;
  36.  
  37. function newValue() {
  38. var date = new Date();
  39. var time = (date.getHours() - 8) + date.getMinutes() / 60 + date.getSeconds() / 3600;
  40. if (time < 0) {
  41. time = time + 24;
  42. }
  43. if (time > 12) {
  44. time = time - 12;
  45. }
  46. return 12 - time;
  47. }
  48.  
  49. function isDay() {
  50. var date = new Date();
  51. var time = (date.getHours() - 8) + date.getMinutes() / 60 + date.getSeconds() / 3600;
  52. if (time < 0) {
  53. time = time + 24;
  54. }
  55. return time <= 12;
  56. }
  57.  
  58. var v = newValue();
  59. var gauge = loadLiquidFillGauge("fillgauge", v, config);
  60.  
  61. function chooseTheme() {
  62. if (isDay()) {
  63. config.circleColor = "#6495ED";
  64. config.textColor = "#FF7F00";
  65. config.waveTextColor = "#FFFFAA";
  66. config.waveColor = "#32CD32";
  67. } else {
  68. config.circleColor = "#191970";
  69. config.textColor = "#9932CC";
  70. config.waveTextColor = "#9370DB";
  71. config.waveColor = "#FFF8DC";
  72. }
  73. d3.select("svg").select("g").remove();
  74. gauge = loadLiquidFillGauge("fillgauge", newValue(), config);
  75. }
  76.  
  77. chooseTheme();
  78.  
  79. function update() {
  80. if (newValue() > v) {
  81. chooseTheme();
  82. }
  83. gauge.update(newValue());
  84. }
  85.  
  86. window.setInterval(update, 500);
  87. </script>
  88. </body>
  89. </html>
Add Comment
Please, Sign In to add comment