From 08fedf3a96881fef43b6cfba5ca5542511ed3d0a Mon Sep 17 00:00:00 2001
From: Cohee <18619528+Cohee1207@users.noreply.github.com>
Date: Sat, 2 Dec 2023 21:56:16 +0200
Subject: [PATCH] lint: Use 4 space indent
---
.eslintrc.js | 1 +
public/script.js | 28 +++++++++++++-------------
public/scripts/BulkEditOverlay.js | 22 ++++++++++----------
public/scripts/PromptManager.js | 14 ++++++-------
public/scripts/authors-note.js | 8 ++++----
public/scripts/cfg-scale.js | 8 ++++----
public/scripts/extensions/tts/coqui.js | 20 +++++++++---------
public/scripts/f-localStorage.js | 24 +++++++++++-----------
public/scripts/power-user.js | 2 +-
public/scripts/utils.js | 3 +--
public/scripts/world-info.js | 20 +++++++++---------
src/content-manager.js | 2 +-
12 files changed, 74 insertions(+), 78 deletions(-)
diff --git a/.eslintrc.js b/.eslintrc.js
index 5b6ec8a17..9d4c01f47 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -54,6 +54,7 @@ module.exports = {
'require-yield': 'off',
'quotes': ['error', 'single'],
'semi': ['error', 'always'],
+ 'indent': ['error', 4, { SwitchCase: 1, FunctionDeclaration: { parameters: 'first' } }],
// These rules should eventually be enabled.
'no-async-promise-executor': 'off',
diff --git a/public/script.js b/public/script.js
index 7beebda78..5fdd18a7e 100644
--- a/public/script.js
+++ b/public/script.js
@@ -4129,7 +4129,7 @@ async function DupeChar() {
const confirm = await callPopup(`
Are you sure you want to duplicate this character?
If you just want to start a new chat with the same character, use "Start new chat" option in the bottom-left options menu.
`,
- 'confirm',
+ 'confirm',
);
if (!confirm) {
@@ -7552,22 +7552,22 @@ function addDebugFunctions() {
`Recalculates token counts of all messages in the current chat to refresh the counters.
Useful when you switch between models that have different tokenizers.
This is a visual change only. Your chat will be reloaded.`, async () => {
- for (const message of chat) {
+ for (const message of chat) {
// System messages are not counted
- if (message.is_system) {
- continue;
+ if (message.is_system) {
+ continue;
+ }
+
+ if (!message.extra) {
+ message.extra = {};
+ }
+
+ message.extra.token_count = getTokenCount(message.mes, 0);
}
- if (!message.extra) {
- message.extra = {};
- }
-
- message.extra.token_count = getTokenCount(message.mes, 0);
- }
-
- await saveChatConditional();
- await reloadCurrentChat();
- });
+ await saveChatConditional();
+ await reloadCurrentChat();
+ });
registerDebugFunction('generationTest', 'Send a generation request', 'Generates text using the currently selected API.', async () => {
const text = prompt('Input text:', 'Hello');
diff --git a/public/scripts/BulkEditOverlay.js b/public/scripts/BulkEditOverlay.js
index 808b630f8..e8f9ec577 100644
--- a/public/scripts/BulkEditOverlay.js
+++ b/public/scripts/BulkEditOverlay.js
@@ -472,19 +472,19 @@ class BulkEditOverlay {
this.isLongPress = true;
setTimeout(() => {
- if (this.isLongPress && !cancel) {
- if (this.state === BulkEditOverlayState.browse) {
- this.selectState();
- } else if (this.state === BulkEditOverlayState.select) {
- this.#contextMenuOpen = true;
- CharacterContextMenu.show(...this.#getContextMenuPosition(event));
- }
+ if (this.isLongPress && !cancel) {
+ if (this.state === BulkEditOverlayState.browse) {
+ this.selectState();
+ } else if (this.state === BulkEditOverlayState.select) {
+ this.#contextMenuOpen = true;
+ CharacterContextMenu.show(...this.#getContextMenuPosition(event));
}
+ }
- this.container.removeEventListener('mouseup', cancelHold);
- this.container.removeEventListener('touchend', cancelHold);
- },
- BulkEditOverlay.longPressDelay);
+ this.container.removeEventListener('mouseup', cancelHold);
+ this.container.removeEventListener('touchend', cancelHold);
+ },
+ BulkEditOverlay.longPressDelay);
};
handleLongPressEnd = (event) => {
diff --git a/public/scripts/PromptManager.js b/public/scripts/PromptManager.js
index 580bc538a..9d85a4f18 100644
--- a/public/scripts/PromptManager.js
+++ b/public/scripts/PromptManager.js
@@ -1379,6 +1379,11 @@ PromptManagerModule.prototype.renderPromptManager = function () {
footerDiv.querySelector('.menu_button:last-child').addEventListener('click', this.handleNewPrompt);
// Add prompt export dialogue and options
+ const exportForCharacter =`
+ `;
const exportPopup = `
`;
diff --git a/public/scripts/authors-note.js b/public/scripts/authors-note.js
index 8cf990590..1d9dae089 100644
--- a/public/scripts/authors-note.js
+++ b/public/scripts/authors-note.js
@@ -345,10 +345,10 @@ function onANMenuItemClick() {
opacity: 0.0,
duration: 250,
},
- async function () {
- await delay(50);
- $('#floatingPrompt').removeClass('resizing');
- });
+ async function () {
+ await delay(50);
+ $('#floatingPrompt').removeClass('resizing');
+ });
setTimeout(function () {
$('#floatingPrompt').hide();
}, 250);
diff --git a/public/scripts/cfg-scale.js b/public/scripts/cfg-scale.js
index 62aa32a0b..293318d64 100644
--- a/public/scripts/cfg-scale.js
+++ b/public/scripts/cfg-scale.js
@@ -140,10 +140,10 @@ function onCfgMenuItemClick() {
opacity: 0.0,
duration: 250,
},
- async function () {
- await delay(50);
- $('#cfgConfig').removeClass('resizing');
- });
+ async function () {
+ await delay(50);
+ $('#cfgConfig').removeClass('resizing');
+ });
setTimeout(function () {
$('#cfgConfig').hide();
}, 250);
diff --git a/public/scripts/extensions/tts/coqui.js b/public/scripts/extensions/tts/coqui.js
index 100417f28..09596ebf0 100644
--- a/public/scripts/extensions/tts/coqui.js
+++ b/public/scripts/extensions/tts/coqui.js
@@ -157,10 +157,10 @@ class CoquiTtsProvider {
// Load coqui-api settings from json file
await fetch('/scripts/extensions/tts/coqui_api_models_settings.json')
- .then(response => response.json())
- .then(json => {
- coquiApiModels = json;
- console.debug(DEBUG_PREFIX,'initialized coqui-api model list to', coquiApiModels);
+ .then(response => response.json())
+ .then(json => {
+ coquiApiModels = json;
+ console.debug(DEBUG_PREFIX,'initialized coqui-api model list to', coquiApiModels);
/*
$('#coqui_api_language')
.find('option')
@@ -173,14 +173,14 @@ class CoquiTtsProvider {
$("#coqui_api_language").append(new Option(languageLabels[language],language));
console.log(DEBUG_PREFIX,"added language",language);
}*/
- });
+ });
// Load coqui-api FULL settings from json file
await fetch('/scripts/extensions/tts/coqui_api_models_settings_full.json')
- .then(response => response.json())
- .then(json => {
- coquiApiModelsFull = json;
- console.debug(DEBUG_PREFIX,'initialized coqui-api full model list to', coquiApiModelsFull);
+ .then(response => response.json())
+ .then(json => {
+ coquiApiModelsFull = json;
+ console.debug(DEBUG_PREFIX,'initialized coqui-api full model list to', coquiApiModelsFull);
/*
$('#coqui_api_full_language')
.find('option')
@@ -193,7 +193,7 @@ class CoquiTtsProvider {
$("#coqui_api_full_language").append(new Option(languageLabels[language],language));
console.log(DEBUG_PREFIX,"added language",language);
}*/
- });
+ });
}
// Perform a simple readiness check by trying to fetch voiceIds
diff --git a/public/scripts/f-localStorage.js b/public/scripts/f-localStorage.js
index 977441f6c..adcb3af4e 100644
--- a/public/scripts/f-localStorage.js
+++ b/public/scripts/f-localStorage.js
@@ -1,25 +1,25 @@
////////////////// LOCAL STORAGE HANDLING /////////////////////
export function SaveLocal(target, val) {
- localStorage.setItem(target, val);
- console.debug('SaveLocal -- ' + target + ' : ' + val);
+ localStorage.setItem(target, val);
+ console.debug('SaveLocal -- ' + target + ' : ' + val);
}
export function LoadLocal(target) {
- console.debug('LoadLocal -- ' + target);
- return localStorage.getItem(target);
+ console.debug('LoadLocal -- ' + target);
+ return localStorage.getItem(target);
}
export function LoadLocalBool(target) {
- let result = localStorage.getItem(target) === 'true';
- return result;
+ let result = localStorage.getItem(target) === 'true';
+ return result;
}
export function CheckLocal() {
- console.log('----------local storage---------');
- var i;
- for (i = 0; i < localStorage.length; i++) {
- console.log(localStorage.key(i) + ' : ' + localStorage.getItem(localStorage.key(i)));
- }
- console.log('------------------------------');
+ console.log('----------local storage---------');
+ var i;
+ for (i = 0; i < localStorage.length; i++) {
+ console.log(localStorage.key(i) + ' : ' + localStorage.getItem(localStorage.key(i)));
+ }
+ console.log('------------------------------');
}
export function ClearLocal() { localStorage.clear(); console.log('Removed All Local Storage'); }
diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js
index ca2924473..a432cc510 100644
--- a/public/scripts/power-user.js
+++ b/public/scripts/power-user.js
@@ -2241,7 +2241,7 @@ function setAvgBG() {
try {
data = context.getImageData(0, 0, width, height);
} catch (e) {
- /* security error, img on diff domain */alert('x');
+ /* security error, img on diff domain */alert('x');
return defaultRGB;
}
diff --git a/public/scripts/utils.js b/public/scripts/utils.js
index 4c7a09917..bcb4612c7 100644
--- a/public/scripts/utils.js
+++ b/public/scripts/utils.js
@@ -358,8 +358,7 @@ export function stringFormat(format) {
return format.replace(/{(\d+)}/g, function (match, number) {
return typeof args[number] != 'undefined'
? args[number]
- : match
- ;
+ : match;
});
}
diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js
index 78a9a7e45..2511a4117 100644
--- a/public/scripts/world-info.js
+++ b/public/scripts/world-info.js
@@ -2098,17 +2098,15 @@ export function checkEmbeddedWorld(chid) {
localStorage.setItem(checkKey, 1);
if (power_user.world_import_dialog) {
- callPopup(`This character has an embedded World/Lorebook.
- Would you like to import it now?
- If you want to import it later, select "Import Card Lore" in the "More..." dropdown menu on the character panel.
`,
- 'confirm',
- '',
- { okButton: 'Yes', })
- .then((result) => {
- if (result) {
- importEmbeddedWorldInfo(true);
- }
- });
+ const html = `This character has an embedded World/Lorebook.
+ Would you like to import it now?
+ If you want to import it later, select "Import Card Lore" in the "More..." dropdown menu on the character panel.
`;
+ const checkResult = (result) => {
+ if (result) {
+ importEmbeddedWorldInfo(true);
+ }
+ };
+ callPopup(html, 'confirm', '', { okButton: 'Yes', }).then(checkResult);
}
else {
toastr.info(
diff --git a/src/content-manager.js b/src/content-manager.js
index cea6353ae..d596f604d 100644
--- a/src/content-manager.js
+++ b/src/content-manager.js
@@ -210,7 +210,7 @@ async function downloadJannyCharacter(uuid) {
* @returns {String | null } UUID of the character
*/
function parseJannyUrl(url) {
- // Extract UUID from URL
+ // Extract UUID from URL
const uuidRegex = /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/;
const matches = url.match(uuidRegex);