|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <title>Waiting for GitHub Pages Deployment</title> |
| 6 | + <style> |
| 7 | + @import url('nord.css'); |
| 8 | + body { |
| 9 | + height: 100vh; |
| 10 | + margin: 0; |
| 11 | + display: flex; |
| 12 | + flex-direction: column; |
| 13 | + align-items: center; |
| 14 | + justify-content: center; |
| 15 | + gap: 10px; |
| 16 | + } |
| 17 | + #spinner { |
| 18 | + display: none; |
| 19 | + border: 4px solid var(--nord1); |
| 20 | + border-top: 4px solid var(--nord3); |
| 21 | + border-radius: 50%; |
| 22 | + width: 25px; |
| 23 | + height: 25px; |
| 24 | + animation: spin 2s linear infinite; |
| 25 | + } |
| 26 | + p { |
| 27 | + font-size: 12px; |
| 28 | + } |
| 29 | + @keyframes spin { |
| 30 | + 0% { transform: rotate(0deg); } |
| 31 | + 100% { transform: rotate(360deg); } |
| 32 | + } |
| 33 | + </style> |
| 34 | + <script> |
| 35 | + function getHashFromQueryString() { |
| 36 | + const params = new URLSearchParams(window.location.search); |
| 37 | + return params.get("hash"); |
| 38 | + } |
| 39 | + |
| 40 | + async function checkFileExists(url) { |
| 41 | + try { |
| 42 | + const response = await fetch(url, { method: "HEAD" }); |
| 43 | + return response.ok; |
| 44 | + } catch (error) { |
| 45 | + return false; |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + async function waitForFileToExist(url, interval = 2000) { |
| 50 | + while (true) { |
| 51 | + if (await checkFileExists(url)) { |
| 52 | + return true; |
| 53 | + } |
| 54 | + await new Promise((resolve) => setTimeout(resolve, interval)); |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + async function loadContent() { |
| 59 | + const spinner = document.getElementById("spinner"); |
| 60 | + const hash = getHashFromQueryString(); |
| 61 | + const fileUrl = `${hash}.html`; |
| 62 | + |
| 63 | + spinner.style.display = "block"; |
| 64 | + |
| 65 | + await waitForFileToExist(fileUrl); |
| 66 | + |
| 67 | + window.location.href = fileUrl; |
| 68 | + } |
| 69 | + |
| 70 | + document.addEventListener("DOMContentLoaded", loadContent); |
| 71 | + |
| 72 | + </script> |
| 73 | + </head> |
| 74 | + <body> |
| 75 | + <div id="spinner"></div> |
| 76 | + <p>Waiting for GitHub Pages Deployment</p> |
| 77 | + </body> |
| 78 | +</html> |
0 commit comments