Update index.html
Browse files- index.html +12 -1
index.html
CHANGED
|
@@ -29,7 +29,17 @@
|
|
| 29 |
<script type="module">
|
| 30 |
import { oauthLoginUrl, oauthHandleRedirectIfPresent } from "@huggingface/hub";
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
if (oauthResult) {
|
| 35 |
document.querySelector("pre").textContent = JSON.stringify(oauthResult, null, 2);
|
|
@@ -38,6 +48,7 @@
|
|
| 38 |
document.getElementById("signout").onClick = async function() {
|
| 39 |
localStorage.removeItem("oauth");
|
| 40 |
window.location.href = window.location.href.replace(/\?.*$/, '');
|
|
|
|
| 41 |
}
|
| 42 |
} else {
|
| 43 |
document.getElementById("signin").style.removeProperty("display");
|
|
|
|
| 29 |
<script type="module">
|
| 30 |
import { oauthLoginUrl, oauthHandleRedirectIfPresent } from "@huggingface/hub";
|
| 31 |
|
| 32 |
+
let oauthResult = localStorage.getItem("oauth");
|
| 33 |
+
|
| 34 |
+
if (oauthResult) {
|
| 35 |
+
try {
|
| 36 |
+
oauthResult = JSON.parse(oauthResult);
|
| 37 |
+
} catch {
|
| 38 |
+
oauthResult = null;
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
oauthResult ||= await oauthHandleRedirectIfPresent();
|
| 43 |
|
| 44 |
if (oauthResult) {
|
| 45 |
document.querySelector("pre").textContent = JSON.stringify(oauthResult, null, 2);
|
|
|
|
| 48 |
document.getElementById("signout").onClick = async function() {
|
| 49 |
localStorage.removeItem("oauth");
|
| 50 |
window.location.href = window.location.href.replace(/\?.*$/, '');
|
| 51 |
+
window.location.reload();
|
| 52 |
}
|
| 53 |
} else {
|
| 54 |
document.getElementById("signin").style.removeProperty("display");
|