lint: Use 4 space indent

This commit is contained in:
Cohee 2023-12-02 21:56:16 +02:00
parent c63cd87cc0
commit 08fedf3a96
12 changed files with 74 additions and 78 deletions

View File

@ -54,6 +54,7 @@ module.exports = {
'require-yield': 'off', 'require-yield': 'off',
'quotes': ['error', 'single'], 'quotes': ['error', 'single'],
'semi': ['error', 'always'], 'semi': ['error', 'always'],
'indent': ['error', 4, { SwitchCase: 1, FunctionDeclaration: { parameters: 'first' } }],
// These rules should eventually be enabled. // These rules should eventually be enabled.
'no-async-promise-executor': 'off', 'no-async-promise-executor': 'off',

View File

@ -4129,7 +4129,7 @@ async function DupeChar() {
const confirm = await callPopup(` const confirm = await callPopup(`
<h3>Are you sure you want to duplicate this character?</h3> <h3>Are you sure you want to duplicate this character?</h3>
<span>If you just want to start a new chat with the same character, use "Start new chat" option in the bottom-left options menu.</span><br><br>`, <span>If you just want to start a new chat with the same character, use "Start new chat" option in the bottom-left options menu.</span><br><br>`,
'confirm', 'confirm',
); );
if (!confirm) { if (!confirm) {
@ -7552,22 +7552,22 @@ function addDebugFunctions() {
`Recalculates token counts of all messages in the current chat to refresh the counters. `Recalculates token counts of all messages in the current chat to refresh the counters.
Useful when you switch between models that have different tokenizers. Useful when you switch between models that have different tokenizers.
This is a visual change only. Your chat will be reloaded.`, async () => { 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 // System messages are not counted
if (message.is_system) { if (message.is_system) {
continue; continue;
}
if (!message.extra) {
message.extra = {};
}
message.extra.token_count = getTokenCount(message.mes, 0);
} }
if (!message.extra) { await saveChatConditional();
message.extra = {}; await reloadCurrentChat();
} });
message.extra.token_count = getTokenCount(message.mes, 0);
}
await saveChatConditional();
await reloadCurrentChat();
});
registerDebugFunction('generationTest', 'Send a generation request', 'Generates text using the currently selected API.', async () => { registerDebugFunction('generationTest', 'Send a generation request', 'Generates text using the currently selected API.', async () => {
const text = prompt('Input text:', 'Hello'); const text = prompt('Input text:', 'Hello');

View File

@ -472,19 +472,19 @@ class BulkEditOverlay {
this.isLongPress = true; this.isLongPress = true;
setTimeout(() => { setTimeout(() => {
if (this.isLongPress && !cancel) { if (this.isLongPress && !cancel) {
if (this.state === BulkEditOverlayState.browse) { if (this.state === BulkEditOverlayState.browse) {
this.selectState(); this.selectState();
} else if (this.state === BulkEditOverlayState.select) { } else if (this.state === BulkEditOverlayState.select) {
this.#contextMenuOpen = true; this.#contextMenuOpen = true;
CharacterContextMenu.show(...this.#getContextMenuPosition(event)); CharacterContextMenu.show(...this.#getContextMenuPosition(event));
}
} }
}
this.container.removeEventListener('mouseup', cancelHold); this.container.removeEventListener('mouseup', cancelHold);
this.container.removeEventListener('touchend', cancelHold); this.container.removeEventListener('touchend', cancelHold);
}, },
BulkEditOverlay.longPressDelay); BulkEditOverlay.longPressDelay);
}; };
handleLongPressEnd = (event) => { handleLongPressEnd = (event) => {

View File

@ -1379,6 +1379,11 @@ PromptManagerModule.prototype.renderPromptManager = function () {
footerDiv.querySelector('.menu_button:last-child').addEventListener('click', this.handleNewPrompt); footerDiv.querySelector('.menu_button:last-child').addEventListener('click', this.handleNewPrompt);
// Add prompt export dialogue and options // Add prompt export dialogue and options
const exportForCharacter =`
<div class="row">
<a class="export-promptmanager-prompts-character list-group-item" data-i18n="Export for character">Export for character</a>
<span class="tooltip fa-solid fa-info-circle" title="Export prompts for this character, including their order."></span>
</div>`;
const exportPopup = ` const exportPopup = `
<div id="prompt-manager-export-format-popup" class="list-group"> <div id="prompt-manager-export-format-popup" class="list-group">
<div class="prompt-manager-export-format-popup-flex"> <div class="prompt-manager-export-format-popup-flex">
@ -1386,14 +1391,7 @@ PromptManagerModule.prototype.renderPromptManager = function () {
<a class="export-promptmanager-prompts-full list-group-item" data-i18n="Export all">Export all</a> <a class="export-promptmanager-prompts-full list-group-item" data-i18n="Export all">Export all</a>
<span class="tooltip fa-solid fa-info-circle" title="Export all your prompts to a file"></span> <span class="tooltip fa-solid fa-info-circle" title="Export all your prompts to a file"></span>
</div> </div>
${'global' === this.configuration.promptOrder.strategy ${'global' === this.configuration.promptOrder.strategy ? '' : exportForCharacter }
? ''
: `<div class="row">
<a class="export-promptmanager-prompts-character list-group-item" data-i18n="Export for character">Export
for character</a>
<span class="tooltip fa-solid fa-info-circle"
title="Export prompts for this character, including their order."></span>
</div>` }
</div> </div>
</div> </div>
`; `;

View File

@ -345,10 +345,10 @@ function onANMenuItemClick() {
opacity: 0.0, opacity: 0.0,
duration: 250, duration: 250,
}, },
async function () { async function () {
await delay(50); await delay(50);
$('#floatingPrompt').removeClass('resizing'); $('#floatingPrompt').removeClass('resizing');
}); });
setTimeout(function () { setTimeout(function () {
$('#floatingPrompt').hide(); $('#floatingPrompt').hide();
}, 250); }, 250);

View File

@ -140,10 +140,10 @@ function onCfgMenuItemClick() {
opacity: 0.0, opacity: 0.0,
duration: 250, duration: 250,
}, },
async function () { async function () {
await delay(50); await delay(50);
$('#cfgConfig').removeClass('resizing'); $('#cfgConfig').removeClass('resizing');
}); });
setTimeout(function () { setTimeout(function () {
$('#cfgConfig').hide(); $('#cfgConfig').hide();
}, 250); }, 250);

View File

@ -157,10 +157,10 @@ class CoquiTtsProvider {
// Load coqui-api settings from json file // Load coqui-api settings from json file
await fetch('/scripts/extensions/tts/coqui_api_models_settings.json') await fetch('/scripts/extensions/tts/coqui_api_models_settings.json')
.then(response => response.json()) .then(response => response.json())
.then(json => { .then(json => {
coquiApiModels = json; coquiApiModels = json;
console.debug(DEBUG_PREFIX,'initialized coqui-api model list to', coquiApiModels); console.debug(DEBUG_PREFIX,'initialized coqui-api model list to', coquiApiModels);
/* /*
$('#coqui_api_language') $('#coqui_api_language')
.find('option') .find('option')
@ -173,14 +173,14 @@ class CoquiTtsProvider {
$("#coqui_api_language").append(new Option(languageLabels[language],language)); $("#coqui_api_language").append(new Option(languageLabels[language],language));
console.log(DEBUG_PREFIX,"added language",language); console.log(DEBUG_PREFIX,"added language",language);
}*/ }*/
}); });
// Load coqui-api FULL settings from json file // Load coqui-api FULL settings from json file
await fetch('/scripts/extensions/tts/coqui_api_models_settings_full.json') await fetch('/scripts/extensions/tts/coqui_api_models_settings_full.json')
.then(response => response.json()) .then(response => response.json())
.then(json => { .then(json => {
coquiApiModelsFull = json; coquiApiModelsFull = json;
console.debug(DEBUG_PREFIX,'initialized coqui-api full model list to', coquiApiModelsFull); console.debug(DEBUG_PREFIX,'initialized coqui-api full model list to', coquiApiModelsFull);
/* /*
$('#coqui_api_full_language') $('#coqui_api_full_language')
.find('option') .find('option')
@ -193,7 +193,7 @@ class CoquiTtsProvider {
$("#coqui_api_full_language").append(new Option(languageLabels[language],language)); $("#coqui_api_full_language").append(new Option(languageLabels[language],language));
console.log(DEBUG_PREFIX,"added language",language); console.log(DEBUG_PREFIX,"added language",language);
}*/ }*/
}); });
} }
// Perform a simple readiness check by trying to fetch voiceIds // Perform a simple readiness check by trying to fetch voiceIds

View File

@ -1,25 +1,25 @@
////////////////// LOCAL STORAGE HANDLING ///////////////////// ////////////////// LOCAL STORAGE HANDLING /////////////////////
export function SaveLocal(target, val) { export function SaveLocal(target, val) {
localStorage.setItem(target, val); localStorage.setItem(target, val);
console.debug('SaveLocal -- ' + target + ' : ' + val); console.debug('SaveLocal -- ' + target + ' : ' + val);
} }
export function LoadLocal(target) { export function LoadLocal(target) {
console.debug('LoadLocal -- ' + target); console.debug('LoadLocal -- ' + target);
return localStorage.getItem(target); return localStorage.getItem(target);
} }
export function LoadLocalBool(target) { export function LoadLocalBool(target) {
let result = localStorage.getItem(target) === 'true'; let result = localStorage.getItem(target) === 'true';
return result; return result;
} }
export function CheckLocal() { export function CheckLocal() {
console.log('----------local storage---------'); console.log('----------local storage---------');
var i; var i;
for (i = 0; i < localStorage.length; i++) { for (i = 0; i < localStorage.length; i++) {
console.log(localStorage.key(i) + ' : ' + localStorage.getItem(localStorage.key(i))); console.log(localStorage.key(i) + ' : ' + localStorage.getItem(localStorage.key(i)));
} }
console.log('------------------------------'); console.log('------------------------------');
} }
export function ClearLocal() { localStorage.clear(); console.log('Removed All Local Storage'); } export function ClearLocal() { localStorage.clear(); console.log('Removed All Local Storage'); }

View File

@ -2241,7 +2241,7 @@ function setAvgBG() {
try { try {
data = context.getImageData(0, 0, width, height); data = context.getImageData(0, 0, width, height);
} catch (e) { } catch (e) {
/* security error, img on diff domain */alert('x'); /* security error, img on diff domain */alert('x');
return defaultRGB; return defaultRGB;
} }

View File

@ -358,8 +358,7 @@ export function stringFormat(format) {
return format.replace(/{(\d+)}/g, function (match, number) { return format.replace(/{(\d+)}/g, function (match, number) {
return typeof args[number] != 'undefined' return typeof args[number] != 'undefined'
? args[number] ? args[number]
: match : match;
;
}); });
} }

View File

@ -2098,17 +2098,15 @@ export function checkEmbeddedWorld(chid) {
localStorage.setItem(checkKey, 1); localStorage.setItem(checkKey, 1);
if (power_user.world_import_dialog) { if (power_user.world_import_dialog) {
callPopup(`<h3>This character has an embedded World/Lorebook.</h3> const html = `<h3>This character has an embedded World/Lorebook.</h3>
<h3>Would you like to import it now?</h3> <h3>Would you like to import it now?</h3>
<div class="m-b-1">If you want to import it later, select "Import Card Lore" in the "More..." dropdown menu on the character panel.</div>`, <div class="m-b-1">If you want to import it later, select "Import Card Lore" in the "More..." dropdown menu on the character panel.</div>`;
'confirm', const checkResult = (result) => {
'', if (result) {
{ okButton: 'Yes', }) importEmbeddedWorldInfo(true);
.then((result) => { }
if (result) { };
importEmbeddedWorldInfo(true); callPopup(html, 'confirm', '', { okButton: 'Yes', }).then(checkResult);
}
});
} }
else { else {
toastr.info( toastr.info(

View File

@ -210,7 +210,7 @@ async function downloadJannyCharacter(uuid) {
* @returns {String | null } UUID of the character * @returns {String | null } UUID of the character
*/ */
function parseJannyUrl(url) { 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 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); const matches = url.match(uuidRegex);