Disable translate button by default (until loaded)

#1
by Xenova HF staff - opened
Files changed (1) hide show
  1. index.html +8 -4
index.html CHANGED
@@ -6,8 +6,10 @@
6
  <title>Translation in browser using nllb-200-distilled-600M</title>
7
  <link rel="stylesheet" href="style.css" />
8
  <script type="module">
9
- import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.3.0';
10
- const c = console;
 
 
11
 
12
  function progress_callback(x) {
13
  if (x.status === "done") {
@@ -15,6 +17,8 @@
15
  }
16
  if (x.status === "ready") {
17
  document.getElementById("status").textContent += `\nready πŸ”₯`;
 
 
18
  }
19
  }
20
 
@@ -281,7 +285,7 @@
281
  <option value="zho_Hans">zho_Hans</option>
282
  </select>
283
 
284
- <input type="submit" id="submit" value="Translate" />
285
 
286
  <br>
287
  <br>
@@ -289,4 +293,4 @@
289
  </div>
290
 
291
  </body>
292
- </html>
 
6
  <title>Translation in browser using nllb-200-distilled-600M</title>
7
  <link rel="stylesheet" href="style.css" />
8
  <script type="module">
9
+ import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.3.0';
10
+ env.allowLocalModels = false; // Skip check for models hosted locally
11
+
12
+ const c = console;
13
 
14
  function progress_callback(x) {
15
  if (x.status === "done") {
 
17
  }
18
  if (x.status === "ready") {
19
  document.getElementById("status").textContent += `\nready πŸ”₯`;
20
+ button.value = "Translate";
21
+ button.disabled = false;
22
  }
23
  }
24
 
 
285
  <option value="zho_Hans">zho_Hans</option>
286
  </select>
287
 
288
+ <input type="submit" id="submit" value="Loading..." disabled />
289
 
290
  <br>
291
  <br>
 
293
  </div>
294
 
295
  </body>
296
+ </html>