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',
'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',

View File

@ -4129,7 +4129,7 @@ async function DupeChar() {
const confirm = await callPopup(`
<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>`,
'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');

View File

@ -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) => {

View File

@ -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 =`
<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 = `
<div id="prompt-manager-export-format-popup" class="list-group">
<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>
<span class="tooltip fa-solid fa-info-circle" title="Export all your prompts to a file"></span>
</div>
${'global' === this.configuration.promptOrder.strategy
? ''
: `<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>` }
${'global' === this.configuration.promptOrder.strategy ? '' : exportForCharacter }
</div>
</div>
`;

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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'); }

View File

@ -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;
}

View File

@ -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;
});
}

View File

@ -2098,17 +2098,15 @@ export function checkEmbeddedWorld(chid) {
localStorage.setItem(checkKey, 1);
if (power_user.world_import_dialog) {
callPopup(`<h3>This character has an embedded World/Lorebook.</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>`,
'confirm',
'',
{ okButton: 'Yes', })
.then((result) => {
if (result) {
importEmbeddedWorldInfo(true);
}
});
const html = `<h3>This character has an embedded World/Lorebook.</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>`;
const checkResult = (result) => {
if (result) {
importEmbeddedWorldInfo(true);
}
};
callPopup(html, 'confirm', '', { okButton: 'Yes', }).then(checkResult);
}
else {
toastr.info(

View File

@ -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);