tylermullen commited on
Commit
d9e145a
·
verified ·
1 Parent(s): 2acf86c

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +16 -0
index.js CHANGED
@@ -32,6 +32,7 @@ const recordButton = document.getElementById(
32
  'record-button',
33
  );
34
  const sendButton = document.getElementById('send-button');
 
35
  const recordButtonIcon = recordButton.querySelector('i');
36
  const loaderOverlay = document.getElementById('loader-overlay');
37
  const progressBarFill = document.getElementById('progress-bar-fill');
@@ -380,6 +381,21 @@ promptInputElement.addEventListener('keydown', (event) => {
380
  sendTextQuery();
381
  }
382
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
 
384
  // --- Initialization ---
385
  document.addEventListener('DOMContentLoaded', initMedia);
 
32
  'record-button',
33
  );
34
  const sendButton = document.getElementById('send-button');
35
+ const clearCacheButton = document.getElementById('clear-cache-button');
36
  const recordButtonIcon = recordButton.querySelector('i');
37
  const loaderOverlay = document.getElementById('loader-overlay');
38
  const progressBarFill = document.getElementById('progress-bar-fill');
 
381
  sendTextQuery();
382
  }
383
  });
384
+ clearCacheButton.addEventListener('click', async () => {
385
+ const userConfirmed = confirm(
386
+ 'Are you sure you want to clear the cached model? ' +
387
+ 'This will require re-downloading the model on the next visit.'
388
+ );
389
+ if (userConfirmed) {
390
+ try {
391
+ const opfs = await navigator.storage.getDirectory();
392
+ await opfs.removeEntry(cacheFileName);
393
+ console.log('Cache cleared successfully.');
394
+ } catch (error) {
395
+ console.error('Error clearing cache:', error);
396
+ }
397
+ }
398
+ });
399
 
400
  // --- Initialization ---
401
  document.addEventListener('DOMContentLoaded', initMedia);