Update index.html
Browse files- index.html +21 -1
index.html
CHANGED
|
@@ -99,11 +99,31 @@
|
|
| 99 |
document.getElementById('hashText').innerText = data.sha256_hash;
|
| 100 |
document.getElementById('explorerBtn').href = data.verification_url;
|
| 101 |
|
|
|
|
| 102 |
document.getElementById('badgeContainer').innerHTML = `
|
| 103 |
-
<img src="${data.badge_url}" alt="ProofCore Badge" class="inline-block shadow-md">
|
| 104 |
`;
|
| 105 |
|
| 106 |
resultBox.classList.remove('hidden');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
} else {
|
| 108 |
alert("Error: " + (data.error || "Failed to seal content"));
|
| 109 |
}
|
|
|
|
| 99 |
document.getElementById('hashText').innerText = data.sha256_hash;
|
| 100 |
document.getElementById('explorerBtn').href = data.verification_url;
|
| 101 |
|
| 102 |
+
// Даем картинке ID, чтобы потом её обновить
|
| 103 |
document.getElementById('badgeContainer').innerHTML = `
|
| 104 |
+
<img id="statusBadge" src="${data.badge_url}" alt="ProofCore Badge" class="inline-block shadow-md transition-all duration-500">
|
| 105 |
`;
|
| 106 |
|
| 107 |
resultBox.classList.remove('hidden');
|
| 108 |
+
|
| 109 |
+
// 🔄 ЗАПУСКАЕМ ОПРОС СТАТУСА (POLLING)
|
| 110 |
+
const dealId = data.deal_id;
|
| 111 |
+
const badgeUrl = data.badge_url;
|
| 112 |
+
const pollInterval = setInterval(async () => {
|
| 113 |
+
try {
|
| 114 |
+
const statusRes = await fetch(`https://api.proofcore.org/api/v0.1/proof/${dealId}`);
|
| 115 |
+
const statusData = await statusRes.json();
|
| 116 |
+
|
| 117 |
+
if (statusData.status === "anchored_onchain" || statusData.status === "cancelled") {
|
| 118 |
+
// Если запечаталось — обновляем картинку (добавляем ?t=время, чтобы сбросить кэш браузера)
|
| 119 |
+
document.getElementById('statusBadge').src = badgeUrl + "?t=" + new Date().getTime();
|
| 120 |
+
clearInterval(pollInterval); // Останавливаем опрос
|
| 121 |
+
}
|
| 122 |
+
} catch (e) {
|
| 123 |
+
console.error("Polling error:", e);
|
| 124 |
+
}
|
| 125 |
+
}, 5000); // Проверяем каждые 5 секунд
|
| 126 |
+
|
| 127 |
} else {
|
| 128 |
alert("Error: " + (data.error || "Failed to seal content"));
|
| 129 |
}
|