Add type casts
This commit is contained in:
parent
75832c1ad6
commit
de1ca9af74
|
@ -451,7 +451,7 @@ let safetychat = [
|
||||||
let chatSaveTimeout;
|
let chatSaveTimeout;
|
||||||
let importFlashTimeout;
|
let importFlashTimeout;
|
||||||
export let isChatSaving = false;
|
export let isChatSaving = false;
|
||||||
let chat_create_date = 0;
|
let chat_create_date = '';
|
||||||
let firstRun = false;
|
let firstRun = false;
|
||||||
let settingsReady = false;
|
let settingsReady = false;
|
||||||
let currentVersion = '0.0.0';
|
let currentVersion = '0.0.0';
|
||||||
|
@ -5260,7 +5260,7 @@ export function activateSendButtons() {
|
||||||
is_send_press = false;
|
is_send_press = false;
|
||||||
$('#send_but').removeClass('displayNone');
|
$('#send_but').removeClass('displayNone');
|
||||||
$('#mes_continue').removeClass('displayNone');
|
$('#mes_continue').removeClass('displayNone');
|
||||||
$('#send_textarea').attr('disabled', false);
|
$('#send_textarea').attr('disabled', String(false));
|
||||||
$('.mes_buttons:last').show();
|
$('.mes_buttons:last').show();
|
||||||
hideStopButton();
|
hideStopButton();
|
||||||
}
|
}
|
||||||
|
@ -6477,7 +6477,7 @@ export async function displayPastChats() {
|
||||||
$('#select_chat_div').append(template);
|
$('#select_chat_div').append(template);
|
||||||
|
|
||||||
if (currentChat === fileName.toString().replace('.jsonl', '')) {
|
if (currentChat === fileName.toString().replace('.jsonl', '')) {
|
||||||
$('#select_chat_div').find('.select_chat_block:last').attr('highlight', true);
|
$('#select_chat_div').find('.select_chat_block:last').attr('highlight', String(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7170,7 +7170,7 @@ function openCharacterWorldPopup() {
|
||||||
if (previousValue && !name) {
|
if (previousValue && !name) {
|
||||||
try {
|
try {
|
||||||
// Dirty hack to remove embedded lorebook from character JSON data.
|
// Dirty hack to remove embedded lorebook from character JSON data.
|
||||||
const data = JSON.parse($('#character_json_data').val());
|
const data = JSON.parse(String($('#character_json_data').val()));
|
||||||
|
|
||||||
if (data?.data?.character_book) {
|
if (data?.data?.character_book) {
|
||||||
data.data.character_book = undefined;
|
data.data.character_book = undefined;
|
||||||
|
@ -7327,7 +7327,7 @@ function addAlternateGreeting(template, greeting, index, getArray) {
|
||||||
async function createOrEditCharacter(e) {
|
async function createOrEditCharacter(e) {
|
||||||
$('#rm_info_avatar').html('');
|
$('#rm_info_avatar').html('');
|
||||||
const formData = new FormData($('#form_create').get(0));
|
const formData = new FormData($('#form_create').get(0));
|
||||||
formData.set('fav', fav_ch_checked);
|
formData.set('fav', String(fav_ch_checked));
|
||||||
|
|
||||||
const rawFile = formData.get('avatar');
|
const rawFile = formData.get('avatar');
|
||||||
if (rawFile instanceof File) {
|
if (rawFile instanceof File) {
|
||||||
|
@ -7336,7 +7336,7 @@ async function createOrEditCharacter(e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#form_create').attr('actiontype') == 'createcharacter') {
|
if ($('#form_create').attr('actiontype') == 'createcharacter') {
|
||||||
if ($('#character_name_pole').val().length > 0) {
|
if (String($('#character_name_pole').val()).length > 0) {
|
||||||
if (is_group_generating || is_send_press) {
|
if (is_group_generating || is_send_press) {
|
||||||
toastr.error('Cannot create characters while generating. Stop the request and try again.', 'Creation aborted');
|
toastr.error('Cannot create characters while generating. Stop the request and try again.', 'Creation aborted');
|
||||||
throw new Error('Cannot import character while generating');
|
throw new Error('Cannot import character while generating');
|
||||||
|
@ -7361,7 +7361,7 @@ async function createOrEditCharacter(e) {
|
||||||
url: url,
|
url: url,
|
||||||
data: formData,
|
data: formData,
|
||||||
beforeSend: function () {
|
beforeSend: function () {
|
||||||
$('#create_button').attr('disabled', true);
|
$('#create_button').attr('disabled', String(true));
|
||||||
$('#create_button').attr('value', '⏳');
|
$('#create_button').attr('value', '⏳');
|
||||||
},
|
},
|
||||||
cache: false,
|
cache: false,
|
||||||
|
@ -7448,7 +7448,7 @@ async function createOrEditCharacter(e) {
|
||||||
url: url,
|
url: url,
|
||||||
data: formData,
|
data: formData,
|
||||||
beforeSend: function () {
|
beforeSend: function () {
|
||||||
$('#create_button').attr('disabled', true);
|
$('#create_button').attr('disabled', String(true));
|
||||||
$('#create_button').attr('value', 'Save');
|
$('#create_button').attr('value', 'Save');
|
||||||
},
|
},
|
||||||
cache: false,
|
cache: false,
|
||||||
|
@ -8569,8 +8569,7 @@ jQuery(async function () {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
chat_file_for_del = $(this).attr('file_name');
|
chat_file_for_del = $(this).attr('file_name');
|
||||||
console.debug('detected cross click for' + chat_file_for_del);
|
console.debug('detected cross click for' + chat_file_for_del);
|
||||||
popup_type = 'del_chat';
|
callPopup('<h3>Delete the Chat File?</h3>', 'del_chat');
|
||||||
callPopup('<h3>Delete the Chat File?</h3>');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#advanced_div').click(function () {
|
$('#advanced_div').click(function () {
|
||||||
|
@ -9434,10 +9433,10 @@ jQuery(async function () {
|
||||||
edit_textarea.height(edit_textarea[0].scrollHeight);
|
edit_textarea.height(edit_textarea[0].scrollHeight);
|
||||||
edit_textarea.focus();
|
edit_textarea.focus();
|
||||||
edit_textarea[0].setSelectionRange( //this sets the cursor at the end of the text
|
edit_textarea[0].setSelectionRange( //this sets the cursor at the end of the text
|
||||||
edit_textarea.val().length,
|
String(edit_textarea.val()).length,
|
||||||
edit_textarea.val().length,
|
String(edit_textarea.val()).length,
|
||||||
);
|
);
|
||||||
if (this_edit_mes_id == chat.length - 1) {
|
if (Number(this_edit_mes_id) === chat.length - 1) {
|
||||||
$('#chat').scrollTop(chatScrollPosition);
|
$('#chat').scrollTop(chatScrollPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9660,6 +9659,11 @@ jQuery(async function () {
|
||||||
|
|
||||||
$('#character_import_file').on('change', async function (e) {
|
$('#character_import_file').on('change', async function (e) {
|
||||||
$('#rm_info_avatar').html('');
|
$('#rm_info_avatar').html('');
|
||||||
|
|
||||||
|
if (!(e.target instanceof HTMLInputElement)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!e.target.files.length) {
|
if (!e.target.files.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -9793,7 +9797,7 @@ jQuery(async function () {
|
||||||
$(document).on('click', '.mes_create_branch', async function () {
|
$(document).on('click', '.mes_create_branch', async function () {
|
||||||
var selected_mes_id = $(this).closest('.mes').attr('mesid');
|
var selected_mes_id = $(this).closest('.mes').attr('mesid');
|
||||||
if (selected_mes_id !== undefined) {
|
if (selected_mes_id !== undefined) {
|
||||||
branchChat(selected_mes_id);
|
branchChat(Number(selected_mes_id));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -9899,7 +9903,7 @@ jQuery(async function () {
|
||||||
|
|
||||||
var targetParentHasOpenDrawer = clickTarget.parents('.openDrawer').length;
|
var targetParentHasOpenDrawer = clickTarget.parents('.openDrawer').length;
|
||||||
if (clickTarget.hasClass('drawer-icon') == false && !clickTarget.hasClass('openDrawer')) {
|
if (clickTarget.hasClass('drawer-icon') == false && !clickTarget.hasClass('openDrawer')) {
|
||||||
if (jQuery.find('.openDrawer').length !== 0) {
|
if ($('.openDrawer').length !== 0) {
|
||||||
if (targetParentHasOpenDrawer === 0) {
|
if (targetParentHasOpenDrawer === 0) {
|
||||||
//console.log($('.openDrawer').not('.pinnedOpen').length);
|
//console.log($('.openDrawer').not('.pinnedOpen').length);
|
||||||
$('.openDrawer').not('.pinnedOpen').addClass('resizing').slideToggle(200, 'swing', function () {
|
$('.openDrawer').not('.pinnedOpen').addClass('resizing').slideToggle(200, 'swing', function () {
|
||||||
|
@ -10144,10 +10148,10 @@ jQuery(async function () {
|
||||||
const masterSelector = '#' + $(this).data('for');
|
const masterSelector = '#' + $(this).data('for');
|
||||||
const masterElement = $(masterSelector);
|
const masterElement = $(masterSelector);
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Enter') {
|
||||||
let manualInput = parseFloat($(this).val());
|
let manualInput = Number($(this).val());
|
||||||
if (isManualInput) {
|
if (isManualInput) {
|
||||||
//disallow manual inputs outside acceptable range
|
//disallow manual inputs outside acceptable range
|
||||||
if (manualInput >= $(this).attr('min') && manualInput <= $(this).attr('max')) {
|
if (manualInput >= Number($(this).attr('min')) && manualInput <= Number($(this).attr('max'))) {
|
||||||
//if value is ok, assign to slider and update handle text and position
|
//if value is ok, assign to slider and update handle text and position
|
||||||
//newSlider.val(manualInput)
|
//newSlider.val(manualInput)
|
||||||
//handleSlideEvent.call(newSlider, null, { value: parseFloat(manualInput) }, 'manual');
|
//handleSlideEvent.call(newSlider, null, { value: parseFloat(manualInput) }, 'manual');
|
||||||
|
@ -10172,10 +10176,10 @@ jQuery(async function () {
|
||||||
.on('mouseup blur', function () {
|
.on('mouseup blur', function () {
|
||||||
const masterSelector = '#' + $(this).data('for');
|
const masterSelector = '#' + $(this).data('for');
|
||||||
const masterElement = $(masterSelector);
|
const masterElement = $(masterSelector);
|
||||||
let manualInput = parseFloat($(this).val());
|
let manualInput = Number($(this).val());
|
||||||
if (isManualInput) {
|
if (isManualInput) {
|
||||||
//if value is between correct range for the slider
|
//if value is between correct range for the slider
|
||||||
if (manualInput >= $(this).attr('min') && manualInput <= $(this).attr('max')) {
|
if (manualInput >= Number($(this).attr('min')) && manualInput <= Number($(this).attr('max'))) {
|
||||||
valueBeforeManualInput = manualInput;
|
valueBeforeManualInput = manualInput;
|
||||||
//set the slider value to input value
|
//set the slider value to input value
|
||||||
$(masterElement).val($(this).val()).trigger('input');
|
$(masterElement).val($(this).val()).trigger('input');
|
||||||
|
|
Loading…
Reference in New Issue