whitphx HF staff commited on
Commit
904843c
1 Parent(s): 9f854a8

Update comment

Browse files
Files changed (1) hide show
  1. index.html +4 -3
index.html CHANGED
@@ -37,7 +37,7 @@
37
  </div>
38
 
39
  <script>
40
- // Sync query and hash from this embedded app to the parent page URL
41
  function sync() {
42
  const queryString = document.getElementById("query").value;
43
  const hash = document.getElementById("hash").value;
@@ -49,13 +49,14 @@
49
  }, "https://huggingface.co");
50
  }
51
 
52
- // Read the initial query and hash
53
  const initialQuery = window.location.search;
54
  const initialHash = window.location.hash;
55
  document.getElementById("initial-query").value = initialQuery ?? "";
56
  document.getElementById("initial-hash").value = initialHash ?? "";
57
 
58
- // Read the updated hash reactively
 
59
  window.addEventListener("hashchange", (event) => {
60
  console.log("hash change event", event);
61
  const currentHash = window.location.hash;
 
37
  </div>
38
 
39
  <script>
40
+ // Sync query and hash from this embedded app to the parent page URL.
41
  function sync() {
42
  const queryString = document.getElementById("query").value;
43
  const hash = document.getElementById("hash").value;
 
49
  }, "https://huggingface.co");
50
  }
51
 
52
+ // Read the initial query and hash.
53
  const initialQuery = window.location.search;
54
  const initialHash = window.location.hash;
55
  document.getElementById("initial-query").value = initialQuery ?? "";
56
  document.getElementById("initial-hash").value = initialHash ?? "";
57
 
58
+ // Read the updated hash reactively.
59
+ // Note: there is no way to capture the query string update like this because updating query string causes page-reload (ref: https://stackoverflow.com/a/4291024).
60
  window.addEventListener("hashchange", (event) => {
61
  console.log("hash change event", event);
62
  const currentHash = window.location.hash;