qikp commited on
Commit
099080c
·
verified ·
1 Parent(s): 7bd88f2

Update script.js

Browse files
Files changed (1) hide show
  1. script.js +2 -2
script.js CHANGED
@@ -8,7 +8,7 @@ tokenizeButton.addEventListener("click", async () => {
8
  let tokenized = tokenizer.encode(text);
9
  document.querySelector("#totalLength").textContent = `Total length: ${tokenized.length}`;
10
  let output = document.querySelector("#output");
11
- output.innerHTML = "";
12
  let colors = ["#ff0000", "#ff8700", "#ffd300", "#deff0a", "#a1ff0a", "#0aff99", "#0aefff", "#147df5", "#580aff", "#be0aff"].sort(() => Math.random() - 0.5);
13
  tokenized.forEach((token, index) => {
14
  let content = document.createElement("span");
@@ -16,7 +16,7 @@ tokenizeButton.addEventListener("click", async () => {
16
  content.style.backgroundColor = colors[index % colors.length];
17
  content.style.fontFamily = "monospace";
18
  content.title = token.toString();
19
- output.appendChild(content);
20
  });
21
  tokenizeButton.disabled = false;
22
  });
 
8
  let tokenized = tokenizer.encode(text);
9
  document.querySelector("#totalLength").textContent = `Total length: ${tokenized.length}`;
10
  let output = document.querySelector("#output");
11
+ output.contentDocument.body.innerHTML = "";
12
  let colors = ["#ff0000", "#ff8700", "#ffd300", "#deff0a", "#a1ff0a", "#0aff99", "#0aefff", "#147df5", "#580aff", "#be0aff"].sort(() => Math.random() - 0.5);
13
  tokenized.forEach((token, index) => {
14
  let content = document.createElement("span");
 
16
  content.style.backgroundColor = colors[index % colors.length];
17
  content.style.fontFamily = "monospace";
18
  content.title = token.toString();
19
+ output.contentDocument.body.appendChild(content);
20
  });
21
  tokenizeButton.disabled = false;
22
  });