display.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <style>
  6. *{margin:0;padding:0;box-sizing:border-box};
  7. html, body{
  8. height: 100vh;
  9. width: 100vw;
  10. background: black;
  11. }
  12. .grid{
  13. display: grid;
  14. grid-template-columns: 1fr 1fr;
  15. grid-template-rows: 1fr 1fr;
  16. height: 100vh;
  17. width: 100vw;
  18. grid-template-areas:
  19. "topLeft topRight"
  20. "bottom bottom";
  21. gap: 2px;
  22. }
  23. .grid > *{
  24. background: black;
  25. min-height: 0;
  26. min-width: 0;
  27. overflow: hidden;
  28. }
  29. .topLeft{
  30. display: flex;
  31. flex-direction: column;
  32. justify-content: space-around;
  33. align-items: center;
  34. grid-area: topLeft;
  35. color: white;
  36. }
  37. .topRight{
  38. display: flex;
  39. align-items: center;
  40. justify-content: center;
  41. grid-area: topRight;
  42. }
  43. .bottom{
  44. grid-area: bottom;
  45. }
  46. #date{
  47. font-size: 2.2em;
  48. }
  49. #time{
  50. font-size: 1.8em;
  51. text-align: center;
  52. }
  53. .weather{
  54. display: flex;
  55. justify-content: space-around;
  56. width: 100%;
  57. }
  58. .weatherBlock{
  59. display: flex;
  60. justify-content: space-around;
  61. align-items: center;
  62. position: relative;
  63. padding-top: 35px;
  64. width: 50%;
  65. }
  66. .weatherBlock h2{
  67. position: absolute;
  68. top: 0;
  69. left: 0;
  70. width: 100%;
  71. text-align: center;
  72. }
  73. .topRight img{
  74. height: 95%;
  75. }
  76. .bottom iframe{
  77. width: 100%;
  78. height: 100%;
  79. }
  80. </style>
  81. </head>
  82. <body>
  83. <div class="grid">
  84. <div class="topLeft">
  85. <div class="dateTime">
  86. <p id="date"></p>
  87. <p id="time"></p>
  88. </div>
  89. <div class="weather">
  90. <div id="currentWeather" class="weatherBlock">
  91. <h2>Current Weather</h2>
  92. <div class="condition">
  93. <img>
  94. <p class="conditionText"></p>
  95. </div>
  96. <div class="weatherInfo">
  97. <p id="temp"></p>
  98. <p id="feels"></p>
  99. <p id="wind"></p>
  100. <p id="humidity"</p>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. <div class="topRight">
  106. <img id="radar" src="https://radar.weather.gov/ridge/standard/KLTX_0.gif" alt="radar">
  107. </div>
  108. <div class="bottom">
  109. <iframe src="https://www.youtube-nocookie.com/embed/4nMfRpesYfw?si=O9Up2lQKNo8v9gi2" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
  110. </div>
  111. </div>
  112. </body>
  113. <script>
  114. const setDateTime = ()=>{
  115. const dateTime = new Date();
  116. document.getElementById("date").textContent = dateTime.toLocaleDateString("en-US", {
  117. weekday: "long",
  118. year: "numeric",
  119. month: "long",
  120. day: "numeric"
  121. });
  122. document.getElementById("time").textContent = dateTime.toLocaleTimeString("en-US", {
  123. hour: "numeric",
  124. minute: "2-digit",
  125. hour12: true
  126. });
  127. }
  128. const getWeather = ()=>{
  129. fetch("https://api.weatherapi.com/v1/current.json?key=519f51763fa8477b864184849251502&q=29576&aqi=no", {
  130. method: "get"
  131. })
  132. .then(r=>r.json())
  133. .then((response)=>{
  134. const tempDisplay = `Temperature: ${response.current.temp_f}\u00B0F`;
  135. document.getElementById("temp").textContent = tempDisplay;
  136. const feelsLike = `Feels Like: ${response.current.feelslike_f}\u00B0F`;
  137. document.getElementById("feels").textContent = feelsLike;
  138. const currentWeatherImage = document.querySelector("#currentWeather img");
  139. currentWeatherImage.src = `https:${response.current.condition.icon}`;
  140. currentWeatherImage.alt = response.current.condition.text;
  141. const currentWeatherText = document.querySelector("#currentWeather .conditionText");
  142. currentWeatherText.textContent = response.current.condition.text;
  143. const currentWind = `Wind: ${response.current.wind_mph}mph ${response.current.wind_dir}`;
  144. document.getElementById("wind").textContent = currentWind;
  145. const humidity = `Humidity: ${response.current.humidity}%`;
  146. document.getElementById("humidity").textContent = humidity;
  147. })
  148. .catch((err)=>{
  149. console.log(err);
  150. });
  151. }
  152. const getRadarImage = () =>{
  153. const img = document.getElementById("radar");
  154. const base = img.src.split("?")[0];
  155. img.src = base + "?t=" + Date.now();
  156. }
  157. getWeather();
  158. setInterval(getWeather, 60000);
  159. setDateTime();
  160. setInterval(setDateTime, 10000);
  161. setInterval(getRadarImage, 10 * 1000);
  162. </script>
  163. </html>