P01yH3dr0n commited on
Commit
c437b94
1 Parent(s): bec6ead

Update tagcomplete/javascript/_utils.js

Browse files
Files changed (1) hide show
  1. tagcomplete/javascript/_utils.js +9 -6
tagcomplete/javascript/_utils.js CHANGED
@@ -37,10 +37,9 @@ function parseCSV(str) {
37
  }
38
 
39
  // Load file
40
- async function readFile(filePath, json = false, cache = false) {
41
- if (!cache)
42
- filePath += `?${new Date().getTime()}`;
43
-
44
  while (true) {
45
  try {
46
  var response = await fetch(`file=${filePath}`);
@@ -55,10 +54,14 @@ async function readFile(filePath, json = false, cache = false) {
55
  return null;
56
  }
57
 
58
- if (json)
 
59
  return await response.json();
60
- else
 
 
61
  return await response.text();
 
62
  }
63
 
64
  // Load CSV
 
37
  }
38
 
39
  // Load file
40
+ async function readFile(filePath, json = false) {
41
+ if (filePath in localStorage)
42
+ return localStorage.getItem(filePath);
 
43
  while (true) {
44
  try {
45
  var response = await fetch(`file=${filePath}`);
 
54
  return null;
55
  }
56
 
57
+ if (json) {
58
+ localStorage.setItem(filePath, response.json());
59
  return await response.json();
60
+ }
61
+ else {
62
+ localStorage.setItem(filePath, response.text());
63
  return await response.text();
64
+ }
65
  }
66
 
67
  // Load CSV