P01yH3dr0n commited on
Commit
9f89f77
2 Parent(s): d0aabb2 b2673d7

Merge branch 'main' of https://hf-mirror.com/spaces/P01yH3dr0n/impart-client

Browse files
tagcomplete/javascript/_utils.js CHANGED
@@ -39,7 +39,11 @@ function parseCSV(str) {
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}`);
@@ -56,7 +60,7 @@ async function readFile(filePath, json = false) {
56
 
57
  if (json) {
58
  let content = await response.json();
59
- localStorage.setItem(filePath, content);
60
  return content;
61
  }
62
  else {
 
39
  // Load file
40
  async function readFile(filePath, json = false) {
41
  if (filePath in localStorage)
42
+ if (json) {
43
+ return JSON.parse(localStorage.getItem(filePath));
44
+ } else {
45
+ return localStorage.getItem(filePath);
46
+ }
47
  while (true) {
48
  try {
49
  var response = await fetch(`file=${filePath}`);
 
60
 
61
  if (json) {
62
  let content = await response.json();
63
+ localStorage.setItem(filePath, JSON.stringify(content));
64
  return content;
65
  }
66
  else {
tagcomplete/javascript/ext_chants.js CHANGED
@@ -33,7 +33,7 @@ class ChantParser extends BaseTagParser {
33
  async function load() {
34
  if (TAC_CFG.chantFile && TAC_CFG.chantFile !== "None") {
35
  try {
36
- chants = await readFile(`${tagBasePath}/${TAC_CFG.chantFile}?`, true);
37
  } catch (e) {
38
  console.error("Error loading chants.json: " + e);
39
  }
 
33
  async function load() {
34
  if (TAC_CFG.chantFile && TAC_CFG.chantFile !== "None") {
35
  try {
36
+ chants = await readFile(`${tagBasePath}/${TAC_CFG.chantFile}`, true);
37
  } catch (e) {
38
  console.error("Error loading chants.json: " + e);
39
  }
tagcomplete/javascript/tagAutocomplete.js CHANGED
@@ -156,6 +156,25 @@ async function loadExtraTags(c) {
156
  }
157
  }
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  // Create the result list div and necessary styling
160
  function createResultsDiv(textArea) {
161
  let parentDiv = document.createElement("div");
@@ -1030,6 +1049,7 @@ async function run() {
1030
  // Get our tag base path from the temp file
1031
  // Rest of setup
1032
  await loadTags(TAC_CFG);
 
1033
  setup();
1034
  tacLoading = false;
1035
- }
 
156
  }
157
  }
158
 
159
+ async function loadTranslations(c) {
160
+ if (c.translation.translationFile && c.translation.translationFile !== "None") {
161
+ try {
162
+ let tArray = await loadCSV(`${tagBasePath}/${c.translation.translationFile}`);
163
+ tArray.forEach(t => {
164
+ if (c.translation.oldFormat && t[2]) // if 2 doesn't exist, it's probably a new format file and the setting is on by mistake
165
+ translations.set(t[0], t[2]);
166
+ else if (t[1])
167
+ translations.set(t[0], t[1]);
168
+ else
169
+ translations.set(t[0], "Not found");
170
+ });
171
+ } catch (e) {
172
+ console.error("Error loading translations file: " + e);
173
+ return;
174
+ }
175
+ }
176
+ }
177
+
178
  // Create the result list div and necessary styling
179
  function createResultsDiv(textArea) {
180
  let parentDiv = document.createElement("div");
 
1049
  // Get our tag base path from the temp file
1050
  // Rest of setup
1051
  await loadTags(TAC_CFG);
1052
+ await loadTranslations(TAC_CFG);
1053
  setup();
1054
  tacLoading = false;
1055
+ }
tagcomplete/tags/demo-chants.json CHANGED
@@ -28,11 +28,5 @@
28
  "terms": "Water, Magic, Fancy",
29
  "content": "(extremely detailed CG unity 8k wallpaper), (masterpiece), (best quality), (ultra-detailed), (best illustration),(best shadow), (an extremely delicate and beautiful), classic, dynamic angle, floating, fine detail, Depth of field, classic, (painting), (sketch), (bloom), (shine), glinting stars,\n\na girl, solo, bare shoulders, flat chest, diamond and glaring eyes, beautiful detailed cold face, very long blue and sliver hair, floating black feathers, wavy hair, extremely delicate and beautiful girls, beautiful detailed eyes, glowing eyes,\n\nriver, (forest),palace, (fairyland,feather,flowers, nature),(sunlight),Hazy fog, mist",
30
  "color": 5
31
- },
32
- {
33
- "name": "fangdongye cute",
34
- "terms": "fangdongye, loli style",
35
- "content": "[suimya, muririn], artist:ciloranko, [artist:sho_(sho_lwlw)], [[tianliang duohe fangdongye]], [eip (pepai)], [rukako], year 2023,",
36
- "color": 5
37
  }
38
  ]
 
28
  "terms": "Water, Magic, Fancy",
29
  "content": "(extremely detailed CG unity 8k wallpaper), (masterpiece), (best quality), (ultra-detailed), (best illustration),(best shadow), (an extremely delicate and beautiful), classic, dynamic angle, floating, fine detail, Depth of field, classic, (painting), (sketch), (bloom), (shine), glinting stars,\n\na girl, solo, bare shoulders, flat chest, diamond and glaring eyes, beautiful detailed cold face, very long blue and sliver hair, floating black feathers, wavy hair, extremely delicate and beautiful girls, beautiful detailed eyes, glowing eyes,\n\nriver, (forest),palace, (fairyland,feather,flowers, nature),(sunlight),Hazy fog, mist",
30
  "color": 5
 
 
 
 
 
 
31
  }
32
  ]