{"id":2623,"date":"2025-10-20T13:36:21","date_gmt":"2025-10-20T12:36:21","guid":{"rendered":"https:\/\/www.tvcomm.co.uk\/g7izu\/?page_id=2623"},"modified":"2025-12-26T11:40:29","modified_gmt":"2025-12-26T11:40:29","slug":"upcoming-rocket-launches","status":"publish","type":"page","link":"https:\/\/www.tvcomm.co.uk\/g7izu\/upcoming-rocket-launches\/","title":{"rendered":"Upcoming Rocket Launches"},"content":{"rendered":"\n<div id=\"launches\"><\/div>\n\n<script>\nasync function fetchLaunches() {\n  try {\n    const response = await fetch('https:\/\/ll.thespacedevs.com\/2.2.0\/launch\/upcoming\/?limit=50');\n    const data = await response.json();\n    const launches = data.results;\n    const container = document.getElementById('launches');\n    container.innerHTML = '';\n\n    const now = new Date();\n    const twoWeeks = 14 * 24 * 60 * 60 * 1000;\n\n    launches.forEach(launch => {\n      const launchDate = new Date(launch.net);\n\n      \/\/ Skip past launches or launches beyond 2 weeks\n      const diffMs = launchDate - now;\n      if (diffMs <= 0 || diffMs > twoWeeks) return;\n\n      const item = document.createElement('div');\n      item.style.background = '#1c1c1c';\n      item.style.borderLeft = '5px solid #ff6600';\n      item.style.padding = '10px';\n      item.style.marginBottom = '10px';\n      item.style.borderRadius = '5px';\n      item.style.color = '#fff';\n      item.style.transition = 'transform 0.2s, box-shadow 0.2s';\n      item.onmouseover = () => { item.style.boxShadow = '0 0 10px #ff6600'; item.style.transform='scale(1.02)'; };\n      item.onmouseout = () => { item.style.boxShadow = 'none'; item.style.transform='scale(1)'; };\n\n      \/\/ Countdown if < 12 hours\n      const twelveHours = 12 * 60 * 60 * 1000;\n      let countdownHtml = '';\n      if (diffMs <= twelveHours) {\n        countdownHtml = ` <span id=\"cd-${launch.id}\" style=\"color:#ff6f61; font-weight:bold;\"><\/span>`;\n      }\n\n      item.innerHTML = `\n        <p><strong style=\"color:#ffcc00;\">Date:<\/strong> ${launchDate.toLocaleDateString()}${countdownHtml}<\/p>\n        <p><strong style=\"color:#ff6f61;\">Time:<\/strong> ${launchDate.toLocaleTimeString([], {hour:'2-digit', minute:'2-digit', timeZoneName:'short'})}<\/p>\n        <p><strong style=\"color:#45a29e;\">Rocket:<\/strong> ${launch.rocket.configuration.name}<\/p>\n        <p><strong style=\"color:#ff79c6;\">Payload:<\/strong> ${launch.mission ? launch.mission.name : 'N\/A'}<\/p>\n        <p><strong style=\"color:#f1fa8c;\">Orbit:<\/strong> ${launch.mission ? launch.mission.orbit.name : 'N\/A'}<\/p>\n        <p><strong style=\"color:#8be9fd;\">Launch Complex:<\/strong> ${launch.pad.name}, ${launch.pad.location.name}<\/p>\n      `;\n      container.appendChild(item);\n\n      \/\/ Countdown timer\n      if (diffMs <= twelveHours) {\n        const countdownEl = document.getElementById(`cd-${launch.id}`);\n        const interval = setInterval(() => {\n          const now2 = new Date();\n          let diff = launchDate - now2;\n          if (diff <= 0) {\n            countdownEl.textContent = ' \ud83d\ude80 Launching!';\n            clearInterval(interval);\n          } else {\n            const h = Math.floor(diff \/ 3600000);\n            const m = Math.floor((diff % 3600000) \/ 60000);\n            const s = Math.floor((diff % 60000) \/ 1000);\n            countdownEl.textContent = ` \u23f1 ${h}h ${m}m ${s}s`;\n          }\n        }, 1000);\n      }\n    });\n\n    if (!container.hasChildNodes()) {\n      container.innerHTML = '<p style=\"color:#fff;\">No launches in the next 2 weeks.<\/p>';\n    }\n  } catch (err) {\n    console.error('Error fetching launch data:', err);\n    document.getElementById('launches').innerHTML = '<p style=\"color:red;\">Could not load launch data.<\/p>';\n  }\n}\n\nfetchLaunches();\n<\/script>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"ngg_post_thumbnail":0,"footnotes":""},"class_list":["post-2623","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.tvcomm.co.uk\/g7izu\/wp-json\/wp\/v2\/pages\/2623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tvcomm.co.uk\/g7izu\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.tvcomm.co.uk\/g7izu\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.tvcomm.co.uk\/g7izu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tvcomm.co.uk\/g7izu\/wp-json\/wp\/v2\/comments?post=2623"}],"version-history":[{"count":9,"href":"https:\/\/www.tvcomm.co.uk\/g7izu\/wp-json\/wp\/v2\/pages\/2623\/revisions"}],"predecessor-version":[{"id":3360,"href":"https:\/\/www.tvcomm.co.uk\/g7izu\/wp-json\/wp\/v2\/pages\/2623\/revisions\/3360"}],"wp:attachment":[{"href":"https:\/\/www.tvcomm.co.uk\/g7izu\/wp-json\/wp\/v2\/media?parent=2623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}