mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Require single quotes
This commit is contained in:
@@ -18,36 +18,36 @@ import {
|
||||
eventSource,
|
||||
menu_type,
|
||||
substituteParams,
|
||||
} from "../script.js";
|
||||
} from '../script.js';
|
||||
|
||||
import {
|
||||
power_user,
|
||||
send_on_enter_options,
|
||||
} from "./power-user.js";
|
||||
} from './power-user.js';
|
||||
|
||||
import { LoadLocal, SaveLocal, LoadLocalBool } from "./f-localStorage.js";
|
||||
import { selected_group, is_group_generating, getGroupAvatar, groups, openGroupById } from "./group-chats.js";
|
||||
import { LoadLocal, SaveLocal, LoadLocalBool } from './f-localStorage.js';
|
||||
import { selected_group, is_group_generating, getGroupAvatar, groups, openGroupById } from './group-chats.js';
|
||||
import {
|
||||
SECRET_KEYS,
|
||||
secret_state,
|
||||
} from "./secrets.js";
|
||||
import { debounce, delay, getStringHash, isValidUrl } from "./utils.js";
|
||||
import { chat_completion_sources, oai_settings } from "./openai.js";
|
||||
import { getTokenCount } from "./tokenizers.js";
|
||||
import { isMancer } from "./textgen-settings.js";
|
||||
} from './secrets.js';
|
||||
import { debounce, delay, getStringHash, isValidUrl } from './utils.js';
|
||||
import { chat_completion_sources, oai_settings } from './openai.js';
|
||||
import { getTokenCount } from './tokenizers.js';
|
||||
import { isMancer } from './textgen-settings.js';
|
||||
|
||||
|
||||
var RPanelPin = document.getElementById("rm_button_panel_pin");
|
||||
var LPanelPin = document.getElementById("lm_button_panel_pin");
|
||||
var WIPanelPin = document.getElementById("WI_panel_pin");
|
||||
var RPanelPin = document.getElementById('rm_button_panel_pin');
|
||||
var LPanelPin = document.getElementById('lm_button_panel_pin');
|
||||
var WIPanelPin = document.getElementById('WI_panel_pin');
|
||||
|
||||
var RightNavPanel = document.getElementById("right-nav-panel");
|
||||
var LeftNavPanel = document.getElementById("left-nav-panel");
|
||||
var WorldInfo = document.getElementById("WorldInfo");
|
||||
var RightNavPanel = document.getElementById('right-nav-panel');
|
||||
var LeftNavPanel = document.getElementById('left-nav-panel');
|
||||
var WorldInfo = document.getElementById('WorldInfo');
|
||||
|
||||
var SelectedCharacterTab = document.getElementById("rm_button_selected_ch");
|
||||
var AutoConnectCheckbox = document.getElementById("auto-connect-checkbox");
|
||||
var AutoLoadChatCheckbox = document.getElementById("auto-load-chat-checkbox");
|
||||
var SelectedCharacterTab = document.getElementById('rm_button_selected_ch');
|
||||
var AutoConnectCheckbox = document.getElementById('auto-connect-checkbox');
|
||||
var AutoLoadChatCheckbox = document.getElementById('auto-load-chat-checkbox');
|
||||
|
||||
var connection_made = false;
|
||||
var retry_delay = 500;
|
||||
@@ -57,7 +57,7 @@ const countTokensDebounced = debounce(RA_CountCharTokens, 1000);
|
||||
|
||||
const observer = new MutationObserver(function (mutations) {
|
||||
mutations.forEach(function (mutation) {
|
||||
if (mutation.target.classList.contains("online_status_text")) {
|
||||
if (mutation.target.classList.contains('online_status_text')) {
|
||||
RA_checkOnlineStatus();
|
||||
} else if (mutation.target.parentNode === SelectedCharacterTab) {
|
||||
setTimeout(RA_CountCharTokens, 200);
|
||||
@@ -90,7 +90,7 @@ export function humanizeGenTime(total_gen_time) {
|
||||
let hours = time_spent % 24;
|
||||
time_spent = Math.floor(time_spent / 24);
|
||||
let days = time_spent;
|
||||
time_spent = "";
|
||||
time_spent = '';
|
||||
if (days > 0) { time_spent += `${days} Days, `; }
|
||||
if (hours > 0) { time_spent += `${hours} Hours, `; }
|
||||
if (minutes > 0) { time_spent += `${minutes} Minutes, `; }
|
||||
@@ -129,7 +129,7 @@ export function getDeviceInfo() {
|
||||
deviceInfo = result;
|
||||
},
|
||||
error: function () {
|
||||
console.log("Couldn't load device info. Defaulting to desktop");
|
||||
console.log('Couldn\'t load device info. Defaulting to desktop');
|
||||
deviceInfo = { device: { type: 'desktop' } };
|
||||
},
|
||||
});
|
||||
@@ -161,13 +161,13 @@ export function humanizedDateTime() {
|
||||
let humanYear = baseDate.getFullYear();
|
||||
let humanMonth = baseDate.getMonth() + 1;
|
||||
let humanDate = baseDate.getDate();
|
||||
let humanHour = (baseDate.getHours() < 10 ? "0" : "") + baseDate.getHours();
|
||||
let humanHour = (baseDate.getHours() < 10 ? '0' : '') + baseDate.getHours();
|
||||
let humanMinute =
|
||||
(baseDate.getMinutes() < 10 ? "0" : "") + baseDate.getMinutes();
|
||||
(baseDate.getMinutes() < 10 ? '0' : '') + baseDate.getMinutes();
|
||||
let humanSecond =
|
||||
(baseDate.getSeconds() < 10 ? "0" : "") + baseDate.getSeconds();
|
||||
(baseDate.getSeconds() < 10 ? '0' : '') + baseDate.getSeconds();
|
||||
let HumanizedDateTime =
|
||||
humanYear + "-" + humanMonth + "-" + humanDate + "@" + humanHour + "h" + humanMinute + "m" + humanSecond + "s";
|
||||
humanYear + '-' + humanMonth + '-' + humanDate + '@' + humanHour + 'h' + humanMinute + 'm' + humanSecond + 's';
|
||||
return HumanizedDateTime;
|
||||
}
|
||||
|
||||
@@ -196,13 +196,13 @@ export function getMessageTimeStamp() {
|
||||
|
||||
|
||||
// triggers:
|
||||
$("#rm_button_create").on("click", function () { //when "+New Character" is clicked
|
||||
$(SelectedCharacterTab).children("h2").html(''); // empty nav's 3rd panel tab
|
||||
$('#rm_button_create').on('click', function () { //when "+New Character" is clicked
|
||||
$(SelectedCharacterTab).children('h2').html(''); // empty nav's 3rd panel tab
|
||||
});
|
||||
//when any input is made to the create/edit character form textareas
|
||||
$("#rm_ch_create_block").on("input", function () { countTokensDebounced(); });
|
||||
$('#rm_ch_create_block').on('input', function () { countTokensDebounced(); });
|
||||
//when any input is made to the advanced editing popup textareas
|
||||
$("#character_popup").on("input", function () { countTokensDebounced(); });
|
||||
$('#character_popup').on('input', function () { countTokensDebounced(); });
|
||||
//function:
|
||||
export function RA_CountCharTokens() {
|
||||
let total_tokens = 0;
|
||||
@@ -347,7 +347,7 @@ export async function favsToHotswap() {
|
||||
|
||||
await Promise.allSettled(promises);
|
||||
//helpful instruction message if no characters are favorited
|
||||
if (count === 0) { container.html(`<small><span><i class="fa-solid fa-star"></i> Favorite characters to add them to HotSwaps</span></small>`) }
|
||||
if (count === 0) { container.html('<small><span><i class="fa-solid fa-star"></i> Favorite characters to add them to HotSwaps</span></small>') }
|
||||
//otherwise replace with fav'd characters
|
||||
if (count > 0) {
|
||||
container.replaceWith(newContainer);
|
||||
@@ -356,26 +356,26 @@ export async function favsToHotswap() {
|
||||
|
||||
//changes input bar and send button display depending on connection status
|
||||
function RA_checkOnlineStatus() {
|
||||
if (online_status == "no_connection") {
|
||||
$("#send_textarea").attr("placeholder", "Not connected to API!"); //Input bar placeholder tells users they are not connected
|
||||
$("#send_form").addClass('no-connection'); //entire input form area is red when not connected
|
||||
$("#send_but").addClass("displayNone"); //send button is hidden when not connected;
|
||||
$("#mes_continue").addClass("displayNone"); //continue button is hidden when not connected;
|
||||
$("#API-status-top").removeClass("fa-plug");
|
||||
$("#API-status-top").addClass("fa-plug-circle-exclamation redOverlayGlow");
|
||||
if (online_status == 'no_connection') {
|
||||
$('#send_textarea').attr('placeholder', 'Not connected to API!'); //Input bar placeholder tells users they are not connected
|
||||
$('#send_form').addClass('no-connection'); //entire input form area is red when not connected
|
||||
$('#send_but').addClass('displayNone'); //send button is hidden when not connected;
|
||||
$('#mes_continue').addClass('displayNone'); //continue button is hidden when not connected;
|
||||
$('#API-status-top').removeClass('fa-plug');
|
||||
$('#API-status-top').addClass('fa-plug-circle-exclamation redOverlayGlow');
|
||||
connection_made = false;
|
||||
} else {
|
||||
if (online_status !== undefined && online_status !== "no_connection") {
|
||||
$("#send_textarea").attr("placeholder", `Type a message, or /? for help`); //on connect, placeholder tells user to type message
|
||||
$('#send_form').removeClass("no-connection");
|
||||
$("#API-status-top").removeClass("fa-plug-circle-exclamation redOverlayGlow");
|
||||
$("#API-status-top").addClass("fa-plug");
|
||||
if (online_status !== undefined && online_status !== 'no_connection') {
|
||||
$('#send_textarea').attr('placeholder', 'Type a message, or /? for help'); //on connect, placeholder tells user to type message
|
||||
$('#send_form').removeClass('no-connection');
|
||||
$('#API-status-top').removeClass('fa-plug-circle-exclamation redOverlayGlow');
|
||||
$('#API-status-top').addClass('fa-plug');
|
||||
connection_made = true;
|
||||
retry_delay = 100;
|
||||
|
||||
if (!is_send_press && !(selected_group && is_group_generating)) {
|
||||
$("#send_but").removeClass("displayNone"); //on connect, send button shows
|
||||
$("#mes_continue").removeClass("displayNone"); //continue button is shown when connected
|
||||
$('#send_but').removeClass('displayNone'); //on connect, send button shows
|
||||
$('#mes_continue').removeClass('displayNone'); //continue button is shown when connected
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -388,24 +388,24 @@ function RA_autoconnect(PrevApi) {
|
||||
setTimeout(RA_autoconnect, 100);
|
||||
return;
|
||||
}
|
||||
if (online_status === "no_connection" && LoadLocalBool('AutoConnectEnabled')) {
|
||||
if (online_status === 'no_connection' && LoadLocalBool('AutoConnectEnabled')) {
|
||||
switch (main_api) {
|
||||
case 'kobold':
|
||||
if (api_server && isValidUrl(api_server)) {
|
||||
$("#api_button").trigger('click');
|
||||
$('#api_button').trigger('click');
|
||||
}
|
||||
break;
|
||||
case 'novel':
|
||||
if (secret_state[SECRET_KEYS.NOVEL]) {
|
||||
$("#api_button_novel").trigger('click');
|
||||
$('#api_button_novel').trigger('click');
|
||||
}
|
||||
break;
|
||||
case 'textgenerationwebui':
|
||||
if (isMancer() && secret_state[SECRET_KEYS.MANCER]) {
|
||||
$("#api_button_textgenerationwebui").trigger('click');
|
||||
$('#api_button_textgenerationwebui').trigger('click');
|
||||
}
|
||||
else if (api_server_textgenerationwebui && isValidUrl(api_server_textgenerationwebui)) {
|
||||
$("#api_button_textgenerationwebui").trigger('click');
|
||||
$('#api_button_textgenerationwebui').trigger('click');
|
||||
}
|
||||
break;
|
||||
case 'openai':
|
||||
@@ -417,7 +417,7 @@ function RA_autoconnect(PrevApi) {
|
||||
|| (secret_state[SECRET_KEYS.AI21] && oai_settings.chat_completion_source == chat_completion_sources.AI21)
|
||||
|| (secret_state[SECRET_KEYS.PALM] && oai_settings.chat_completion_source == chat_completion_sources.PALM)
|
||||
) {
|
||||
$("#api_button_openai").trigger('click');
|
||||
$('#api_button_openai').trigger('click');
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -434,21 +434,21 @@ function OpenNavPanels() {
|
||||
const deviceInfo = getDeviceInfo();
|
||||
if (deviceInfo && deviceInfo.device.type === 'desktop') {
|
||||
//auto-open R nav if locked and previously open
|
||||
if (LoadLocalBool("NavLockOn") == true && LoadLocalBool("NavOpened") == true) {
|
||||
if (LoadLocalBool('NavLockOn') == true && LoadLocalBool('NavOpened') == true) {
|
||||
//console.log("RA -- clicking right nav to open");
|
||||
$("#rightNavDrawerIcon").click();
|
||||
$('#rightNavDrawerIcon').click();
|
||||
}
|
||||
|
||||
//auto-open L nav if locked and previously open
|
||||
if (LoadLocalBool("LNavLockOn") == true && LoadLocalBool("LNavOpened") == true) {
|
||||
console.debug("RA -- clicking left nav to open");
|
||||
$("#leftNavDrawerIcon").click();
|
||||
if (LoadLocalBool('LNavLockOn') == true && LoadLocalBool('LNavOpened') == true) {
|
||||
console.debug('RA -- clicking left nav to open');
|
||||
$('#leftNavDrawerIcon').click();
|
||||
}
|
||||
|
||||
//auto-open WI if locked and previously open
|
||||
if (LoadLocalBool("WINavLockOn") == true && LoadLocalBool("WINavOpened") == true) {
|
||||
console.debug("RA -- clicking WI to open");
|
||||
$("#WIDrawerIcon").click();
|
||||
if (LoadLocalBool('WINavLockOn') == true && LoadLocalBool('WINavOpened') == true) {
|
||||
console.debug('RA -- clicking WI to open');
|
||||
$('#WIDrawerIcon').click();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -459,15 +459,15 @@ function restoreUserInput() {
|
||||
return;
|
||||
}
|
||||
|
||||
const userInput = LoadLocal("userInput");
|
||||
const userInput = LoadLocal('userInput');
|
||||
if (userInput) {
|
||||
$("#send_textarea").val(userInput).trigger('input');
|
||||
$('#send_textarea').val(userInput).trigger('input');
|
||||
}
|
||||
}
|
||||
|
||||
function saveUserInput() {
|
||||
const userInput = String($("#send_textarea").val());
|
||||
SaveLocal("userInput", userInput);
|
||||
const userInput = String($('#send_textarea').val());
|
||||
SaveLocal('userInput', userInput);
|
||||
}
|
||||
|
||||
// Make the DIV element draggable:
|
||||
@@ -526,7 +526,7 @@ export function dragElement(elmnt) {
|
||||
winWidth = window.innerWidth;
|
||||
winHeight = window.innerHeight;
|
||||
|
||||
topbar = document.getElementById("top-bar")
|
||||
topbar = document.getElementById('top-bar')
|
||||
const topbarstyle = getComputedStyle(topbar)
|
||||
topBarFirstX = parseInt(topbarstyle.marginInline)
|
||||
topBarLastY = parseInt(topbarstyle.height);
|
||||
@@ -566,19 +566,19 @@ export function dragElement(elmnt) {
|
||||
//prevent resizing offscreen
|
||||
if (top + elmnt.height() >= winHeight) {
|
||||
console.debug('resizing height to prevent offscreen')
|
||||
elmnt.css('height', winHeight - top - 1 + "px");
|
||||
elmnt.css('height', winHeight - top - 1 + 'px');
|
||||
}
|
||||
|
||||
if (left + elmnt.width() >= winWidth) {
|
||||
console.debug('resizing width to prevent offscreen')
|
||||
elmnt.css('width', winWidth - left - 1 + "px");
|
||||
elmnt.css('width', winWidth - left - 1 + 'px');
|
||||
}
|
||||
|
||||
//prevent resizing from top left into the top bar
|
||||
if (top < topBarLastY && maxX >= topBarFirstX && left <= topBarFirstX
|
||||
) {
|
||||
console.debug('prevent topbar underlap resize')
|
||||
elmnt.css('width', width - 1 + "px");
|
||||
elmnt.css('width', width - 1 + 'px');
|
||||
}
|
||||
|
||||
//set css to prevent weird resize behavior (does not save)
|
||||
@@ -607,13 +607,13 @@ export function dragElement(elmnt) {
|
||||
if (top <= 0) {
|
||||
elmnt.css('top', '0px');
|
||||
} else if (maxY >= winHeight) {
|
||||
elmnt.css('top', winHeight - maxY + top - 1 + "px");
|
||||
elmnt.css('top', winHeight - maxY + top - 1 + 'px');
|
||||
}
|
||||
|
||||
if (left <= 0) {
|
||||
elmnt.css('left', '0px');
|
||||
} else if (maxX >= winWidth) {
|
||||
elmnt.css('left', winWidth - maxX + left - 1 + "px");
|
||||
elmnt.css('left', winWidth - maxX + left - 1 + 'px');
|
||||
}
|
||||
|
||||
//prevent underlap with topbar div
|
||||
@@ -668,15 +668,15 @@ export function dragElement(elmnt) {
|
||||
elmnt.attr('data-dragged', 'true');
|
||||
|
||||
//first set css to computed values to avoid CSS NaN results from 'auto', etc
|
||||
elmnt.css('left', (elmnt.offset().left) + "px");
|
||||
elmnt.css("top", (elmnt.offset().top) + "px");
|
||||
elmnt.css('left', (elmnt.offset().left) + 'px');
|
||||
elmnt.css('top', (elmnt.offset().top) + 'px');
|
||||
|
||||
//then update element position styles to account for drag changes
|
||||
elmnt.css('margin', 'unset');
|
||||
elmnt.css('left', (elmnt.offset().left - pos1) + "px");
|
||||
elmnt.css("top", (elmnt.offset().top - pos2) + "px");
|
||||
elmnt.css("right", ((winWidth - maxX) + "px"));
|
||||
elmnt.css("bottom", ((winHeight - maxY) + "px"));
|
||||
elmnt.css('left', (elmnt.offset().left - pos1) + 'px');
|
||||
elmnt.css('top', (elmnt.offset().top - pos2) + 'px');
|
||||
elmnt.css('right', ((winWidth - maxX) + 'px'));
|
||||
elmnt.css('bottom', ((winHeight - maxY) + 'px'));
|
||||
|
||||
// Height/Width here are for visuals only, and are not saved to settings
|
||||
// required because some divs do hot have a set width/height..
|
||||
@@ -706,7 +706,7 @@ export function dragElement(elmnt) {
|
||||
isMouseDown = false;
|
||||
$(document).off('mouseup', closeDragElement);
|
||||
$(document).off('mousemove', elementDrag);
|
||||
$("body").css("overflow", "");
|
||||
$('body').css('overflow', '');
|
||||
// Clear the "data-dragged" attribute
|
||||
elmnt.attr('data-dragged', 'false');
|
||||
observer.disconnect()
|
||||
@@ -718,13 +718,13 @@ export function dragElement(elmnt) {
|
||||
export async function initMovingUI() {
|
||||
if (isMobile() === false && power_user.movingUI === true) {
|
||||
console.debug('START MOVING UI')
|
||||
dragElement($("#sheld"));
|
||||
dragElement($("#left-nav-panel"));
|
||||
dragElement($("#right-nav-panel"));
|
||||
dragElement($("#WorldInfo"));
|
||||
dragElement($('#sheld'));
|
||||
dragElement($('#left-nav-panel'));
|
||||
dragElement($('#right-nav-panel'));
|
||||
dragElement($('#WorldInfo'));
|
||||
await delay(1000)
|
||||
console.debug('loading AN draggable function')
|
||||
dragElement($("#floatingPrompt"))
|
||||
dragElement($('#floatingPrompt'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -737,8 +737,8 @@ export function initRossMods() {
|
||||
}, 100);
|
||||
|
||||
// read the state of AutoConnect and AutoLoadChat.
|
||||
$(AutoConnectCheckbox).prop("checked", LoadLocalBool("AutoConnectEnabled"));
|
||||
$(AutoLoadChatCheckbox).prop("checked", LoadLocalBool("AutoLoadChatEnabled"));
|
||||
$(AutoConnectCheckbox).prop('checked', LoadLocalBool('AutoConnectEnabled'));
|
||||
$(AutoLoadChatCheckbox).prop('checked', LoadLocalBool('AutoLoadChatEnabled'));
|
||||
|
||||
setTimeout(function () {
|
||||
if (LoadLocalBool('AutoLoadChatEnabled') == true) { RA_autoloadchat(); }
|
||||
@@ -746,17 +746,17 @@ export function initRossMods() {
|
||||
|
||||
|
||||
//Autoconnect on page load if enabled, or when api type is changed
|
||||
if (LoadLocalBool("AutoConnectEnabled") == true) { RA_autoconnect(); }
|
||||
$("#main_api").change(function () {
|
||||
if (LoadLocalBool('AutoConnectEnabled') == true) { RA_autoconnect(); }
|
||||
$('#main_api').change(function () {
|
||||
var PrevAPI = main_api;
|
||||
setTimeout(() => RA_autoconnect(PrevAPI), 100);
|
||||
});
|
||||
$("#api_button").click(function () { setTimeout(RA_checkOnlineStatus, 100); });
|
||||
$('#api_button').click(function () { setTimeout(RA_checkOnlineStatus, 100); });
|
||||
|
||||
//toggle pin class when lock toggle clicked
|
||||
$(RPanelPin).on("click", function () {
|
||||
SaveLocal("NavLockOn", $(RPanelPin).prop("checked"));
|
||||
if ($(RPanelPin).prop("checked") == true) {
|
||||
$(RPanelPin).on('click', function () {
|
||||
SaveLocal('NavLockOn', $(RPanelPin).prop('checked'));
|
||||
if ($(RPanelPin).prop('checked') == true) {
|
||||
//console.log('adding pin class to right nav');
|
||||
$(RightNavPanel).addClass('pinnedOpen');
|
||||
} else {
|
||||
@@ -764,15 +764,15 @@ export function initRossMods() {
|
||||
$(RightNavPanel).removeClass('pinnedOpen');
|
||||
|
||||
if ($(RightNavPanel).hasClass('openDrawer') && $('.openDrawer').length > 1) {
|
||||
$(RightNavPanel).slideToggle(200, "swing");
|
||||
$(RightNavPanel).slideToggle(200, 'swing');
|
||||
//$(rightNavDrawerIcon).toggleClass('openIcon closedIcon');
|
||||
$(RightNavPanel).toggleClass('openDrawer closedDrawer');
|
||||
}
|
||||
}
|
||||
});
|
||||
$(LPanelPin).on("click", function () {
|
||||
SaveLocal("LNavLockOn", $(LPanelPin).prop("checked"));
|
||||
if ($(LPanelPin).prop("checked") == true) {
|
||||
$(LPanelPin).on('click', function () {
|
||||
SaveLocal('LNavLockOn', $(LPanelPin).prop('checked'));
|
||||
if ($(LPanelPin).prop('checked') == true) {
|
||||
//console.log('adding pin class to Left nav');
|
||||
$(LeftNavPanel).addClass('pinnedOpen');
|
||||
} else {
|
||||
@@ -780,16 +780,16 @@ export function initRossMods() {
|
||||
$(LeftNavPanel).removeClass('pinnedOpen');
|
||||
|
||||
if ($(LeftNavPanel).hasClass('openDrawer') && $('.openDrawer').length > 1) {
|
||||
$(LeftNavPanel).slideToggle(200, "swing");
|
||||
$(LeftNavPanel).slideToggle(200, 'swing');
|
||||
//$(leftNavDrawerIcon).toggleClass('openIcon closedIcon');
|
||||
$(LeftNavPanel).toggleClass('openDrawer closedDrawer');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(WIPanelPin).on("click", function () {
|
||||
SaveLocal("WINavLockOn", $(WIPanelPin).prop("checked"));
|
||||
if ($(WIPanelPin).prop("checked") == true) {
|
||||
$(WIPanelPin).on('click', function () {
|
||||
SaveLocal('WINavLockOn', $(WIPanelPin).prop('checked'));
|
||||
if ($(WIPanelPin).prop('checked') == true) {
|
||||
console.debug('adding pin class to WI');
|
||||
$(WorldInfo).addClass('pinnedOpen');
|
||||
} else {
|
||||
@@ -798,7 +798,7 @@ export function initRossMods() {
|
||||
|
||||
if ($(WorldInfo).hasClass('openDrawer') && $('.openDrawer').length > 1) {
|
||||
console.debug('closing WI after lock removal');
|
||||
$(WorldInfo).slideToggle(200, "swing");
|
||||
$(WorldInfo).slideToggle(200, 'swing');
|
||||
//$(WorldInfoDrawerIcon).toggleClass('openIcon closedIcon');
|
||||
$(WorldInfo).toggleClass('openDrawer closedDrawer');
|
||||
}
|
||||
@@ -806,8 +806,8 @@ export function initRossMods() {
|
||||
});
|
||||
|
||||
// read the state of right Nav Lock and apply to rightnav classlist
|
||||
$(RPanelPin).prop('checked', LoadLocalBool("NavLockOn"));
|
||||
if (LoadLocalBool("NavLockOn") == true) {
|
||||
$(RPanelPin).prop('checked', LoadLocalBool('NavLockOn'));
|
||||
if (LoadLocalBool('NavLockOn') == true) {
|
||||
//console.log('setting pin class via local var');
|
||||
$(RightNavPanel).addClass('pinnedOpen');
|
||||
}
|
||||
@@ -816,8 +816,8 @@ export function initRossMods() {
|
||||
$(RightNavPanel).addClass('pinnedOpen');
|
||||
}
|
||||
// read the state of left Nav Lock and apply to leftnav classlist
|
||||
$(LPanelPin).prop('checked', LoadLocalBool("LNavLockOn"));
|
||||
if (LoadLocalBool("LNavLockOn") == true) {
|
||||
$(LPanelPin).prop('checked', LoadLocalBool('LNavLockOn'));
|
||||
if (LoadLocalBool('LNavLockOn') == true) {
|
||||
//console.log('setting pin class via local var');
|
||||
$(LeftNavPanel).addClass('pinnedOpen');
|
||||
}
|
||||
@@ -827,8 +827,8 @@ export function initRossMods() {
|
||||
}
|
||||
|
||||
// read the state of left Nav Lock and apply to leftnav classlist
|
||||
$(WIPanelPin).prop('checked', LoadLocalBool("WINavLockOn"));
|
||||
if (LoadLocalBool("WINavLockOn") == true) {
|
||||
$(WIPanelPin).prop('checked', LoadLocalBool('WINavLockOn'));
|
||||
if (LoadLocalBool('WINavLockOn') == true) {
|
||||
//console.log('setting pin class via local var');
|
||||
$(WorldInfo).addClass('pinnedOpen');
|
||||
}
|
||||
@@ -839,22 +839,22 @@ export function initRossMods() {
|
||||
}
|
||||
|
||||
//save state of Right nav being open or closed
|
||||
$("#rightNavDrawerIcon").on("click", function () {
|
||||
if (!$("#rightNavDrawerIcon").hasClass('openIcon')) {
|
||||
$('#rightNavDrawerIcon').on('click', function () {
|
||||
if (!$('#rightNavDrawerIcon').hasClass('openIcon')) {
|
||||
SaveLocal('NavOpened', 'true');
|
||||
} else { SaveLocal('NavOpened', 'false'); }
|
||||
});
|
||||
|
||||
//save state of Left nav being open or closed
|
||||
$("#leftNavDrawerIcon").on("click", function () {
|
||||
if (!$("#leftNavDrawerIcon").hasClass('openIcon')) {
|
||||
$('#leftNavDrawerIcon').on('click', function () {
|
||||
if (!$('#leftNavDrawerIcon').hasClass('openIcon')) {
|
||||
SaveLocal('LNavOpened', 'true');
|
||||
} else { SaveLocal('LNavOpened', 'false'); }
|
||||
});
|
||||
|
||||
//save state of Left nav being open or closed
|
||||
$("#WorldInfo").on("click", function () {
|
||||
if (!$("#WorldInfo").hasClass('openIcon')) {
|
||||
$('#WorldInfo').on('click', function () {
|
||||
if (!$('#WorldInfo').hasClass('openIcon')) {
|
||||
SaveLocal('WINavOpened', 'true');
|
||||
} else { SaveLocal('WINavOpened', 'false'); }
|
||||
});
|
||||
@@ -873,23 +873,23 @@ export function initRossMods() {
|
||||
}, 300);
|
||||
|
||||
//save AutoConnect and AutoLoadChat prefs
|
||||
$(AutoConnectCheckbox).on("change", function () { SaveLocal("AutoConnectEnabled", $(AutoConnectCheckbox).prop("checked")); });
|
||||
$(AutoLoadChatCheckbox).on("change", function () { SaveLocal("AutoLoadChatEnabled", $(AutoLoadChatCheckbox).prop("checked")); });
|
||||
$(AutoConnectCheckbox).on('change', function () { SaveLocal('AutoConnectEnabled', $(AutoConnectCheckbox).prop('checked')); });
|
||||
$(AutoLoadChatCheckbox).on('change', function () { SaveLocal('AutoLoadChatEnabled', $(AutoLoadChatCheckbox).prop('checked')); });
|
||||
|
||||
$(SelectedCharacterTab).click(function () { SaveLocal('SelectedNavTab', 'rm_button_selected_ch'); });
|
||||
$("#rm_button_characters").click(function () { SaveLocal('SelectedNavTab', 'rm_button_characters'); });
|
||||
$('#rm_button_characters').click(function () { SaveLocal('SelectedNavTab', 'rm_button_characters'); });
|
||||
|
||||
// when a char is selected from the list, save them as the auto-load character for next page load
|
||||
|
||||
// when a char is selected from the list, save their name as the auto-load character for next page load
|
||||
$(document).on("click", ".character_select", function () {
|
||||
$(document).on('click', '.character_select', function () {
|
||||
const characterId = $(this).find('.avatar').attr('title') || $(this).attr('title');
|
||||
setActiveCharacter(characterId);
|
||||
setActiveGroup(null);
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$(document).on("click", ".group_select", function () {
|
||||
$(document).on('click', '.group_select', function () {
|
||||
const groupId = $(this).data('id') || $(this).attr('grid');
|
||||
setActiveCharacter(null);
|
||||
setActiveGroup(groupId);
|
||||
@@ -915,7 +915,7 @@ export function initRossMods() {
|
||||
if (power_user.gestures === false) {
|
||||
return
|
||||
}
|
||||
if ($(".mes_edit_buttons, .drawer-content, #character_popup, #dialogue_popup, #WorldInfo, #right-nav-panel, #left-nav-panel, #select_chat_popup, #floatingPrompt").is(":visible")) {
|
||||
if ($('.mes_edit_buttons, .drawer-content, #character_popup, #dialogue_popup, #WorldInfo, #right-nav-panel, #left-nav-panel, #select_chat_popup, #floatingPrompt').is(':visible')) {
|
||||
return
|
||||
}
|
||||
var SwipeButR = $('.swipe_right:last');
|
||||
@@ -930,7 +930,7 @@ export function initRossMods() {
|
||||
if (power_user.gestures === false) {
|
||||
return
|
||||
}
|
||||
if ($(".mes_edit_buttons, .drawer-content, #character_popup, #dialogue_popup, #WorldInfo, #right-nav-panel, #left-nav-panel, #select_chat_popup, #floatingPrompt").is(":visible")) {
|
||||
if ($('.mes_edit_buttons, .drawer-content, #character_popup, #dialogue_popup, #WorldInfo, #right-nav-panel, #left-nav-panel, #select_chat_popup, #floatingPrompt').is(':visible')) {
|
||||
return
|
||||
}
|
||||
var SwipeButL = $('.swipe_left:last');
|
||||
@@ -967,19 +967,19 @@ export function initRossMods() {
|
||||
//Enter to send when send_textarea in focus
|
||||
if ($(':focus').attr('id') === 'send_textarea') {
|
||||
const sendOnEnter = shouldSendOnEnter();
|
||||
if (!event.shiftKey && !event.ctrlKey && !event.altKey && event.key == "Enter" && is_send_press == false && sendOnEnter) {
|
||||
if (!event.shiftKey && !event.ctrlKey && !event.altKey && event.key == 'Enter' && is_send_press == false && sendOnEnter) {
|
||||
event.preventDefault();
|
||||
Generate();
|
||||
}
|
||||
}
|
||||
if ($(':focus').attr('id') === 'dialogue_popup_input' && !isMobile()) {
|
||||
if (!event.shiftKey && !event.ctrlKey && event.key == "Enter") {
|
||||
if (!event.shiftKey && !event.ctrlKey && event.key == 'Enter') {
|
||||
event.preventDefault();
|
||||
$('#dialogue_popup_ok').trigger('click');
|
||||
}
|
||||
}
|
||||
//ctrl+shift+up to scroll to context line
|
||||
if (event.shiftKey && event.ctrlKey && event.key == "ArrowUp") {
|
||||
if (event.shiftKey && event.ctrlKey && event.key == 'ArrowUp') {
|
||||
event.preventDefault();
|
||||
let contextLine = $('.lastInContext');
|
||||
if (contextLine.length !== 0) {
|
||||
@@ -989,7 +989,7 @@ export function initRossMods() {
|
||||
} else { toastr.warning('Context line not found, send a message first!'); }
|
||||
}
|
||||
//ctrl+shift+down to scroll to bottom of chat
|
||||
if (event.shiftKey && event.ctrlKey && event.key == "ArrowDown") {
|
||||
if (event.shiftKey && event.ctrlKey && event.key == 'ArrowDown') {
|
||||
event.preventDefault();
|
||||
$('#chat').animate({
|
||||
scrollTop: $('#chat').prop('scrollHeight')
|
||||
@@ -997,25 +997,25 @@ export function initRossMods() {
|
||||
}
|
||||
|
||||
// Alt+Enter or AltGr+Enter to Continue
|
||||
if ((event.altKey || (event.altKey && event.ctrlKey)) && event.key == "Enter") {
|
||||
if ((event.altKey || (event.altKey && event.ctrlKey)) && event.key == 'Enter') {
|
||||
if (is_send_press == false) {
|
||||
console.debug("Continuing with Alt+Enter");
|
||||
console.debug('Continuing with Alt+Enter');
|
||||
$('#option_continue').trigger('click');
|
||||
}
|
||||
}
|
||||
|
||||
// Ctrl+Enter for Regeneration Last Response. If editing, accept the edits instead
|
||||
if (event.ctrlKey && event.key == "Enter") {
|
||||
const editMesDone = $(".mes_edit_done:visible");
|
||||
if (event.ctrlKey && event.key == 'Enter') {
|
||||
const editMesDone = $('.mes_edit_done:visible');
|
||||
if (editMesDone.length > 0) {
|
||||
console.debug("Accepting edits with Ctrl+Enter");
|
||||
console.debug('Accepting edits with Ctrl+Enter');
|
||||
editMesDone.trigger('click');
|
||||
} else if (is_send_press == false) {
|
||||
console.debug("Regenerating with Ctrl+Enter");
|
||||
console.debug('Regenerating with Ctrl+Enter');
|
||||
$('#option_regenerate').click();
|
||||
$('#options').hide();
|
||||
} else {
|
||||
console.debug("Ctrl+Enter ignored");
|
||||
console.debug('Ctrl+Enter ignored');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1025,25 +1025,25 @@ export function initRossMods() {
|
||||
return $('body').hasClass('nGY2_body_scrollbar');
|
||||
}
|
||||
|
||||
if (event.key == "ArrowLeft") { //swipes left
|
||||
if (event.key == 'ArrowLeft') { //swipes left
|
||||
if (
|
||||
!isNanogallery2LightboxActive() && // Check if lightbox is NOT active
|
||||
$(".swipe_left:last").css('display') === 'flex' &&
|
||||
$("#send_textarea").val() === '' &&
|
||||
$("#character_popup").css("display") === "none" &&
|
||||
$("#shadow_select_chat_popup").css("display") === "none" &&
|
||||
$('.swipe_left:last').css('display') === 'flex' &&
|
||||
$('#send_textarea').val() === '' &&
|
||||
$('#character_popup').css('display') === 'none' &&
|
||||
$('#shadow_select_chat_popup').css('display') === 'none' &&
|
||||
!isInputElementInFocus()
|
||||
) {
|
||||
$('.swipe_left:last').click();
|
||||
}
|
||||
}
|
||||
if (event.key == "ArrowRight") { //swipes right
|
||||
if (event.key == 'ArrowRight') { //swipes right
|
||||
if (
|
||||
!isNanogallery2LightboxActive() && // Check if lightbox is NOT active
|
||||
$(".swipe_right:last").css('display') === 'flex' &&
|
||||
$("#send_textarea").val() === '' &&
|
||||
$("#character_popup").css("display") === "none" &&
|
||||
$("#shadow_select_chat_popup").css("display") === "none" &&
|
||||
$('.swipe_right:last').css('display') === 'flex' &&
|
||||
$('#send_textarea').val() === '' &&
|
||||
$('#character_popup').css('display') === 'none' &&
|
||||
$('#shadow_select_chat_popup').css('display') === 'none' &&
|
||||
!isInputElementInFocus()
|
||||
) {
|
||||
$('.swipe_right:last').click();
|
||||
@@ -1051,13 +1051,13 @@ export function initRossMods() {
|
||||
}
|
||||
|
||||
|
||||
if (event.ctrlKey && event.key == "ArrowUp") { //edits last USER message if chatbar is empty and focused
|
||||
if (event.ctrlKey && event.key == 'ArrowUp') { //edits last USER message if chatbar is empty and focused
|
||||
if (
|
||||
$("#send_textarea").val() === '' &&
|
||||
$('#send_textarea').val() === '' &&
|
||||
chatbarInFocus === true &&
|
||||
($(".swipe_right:last").css('display') === 'flex' || $('.last_mes').attr('is_system') === 'true') &&
|
||||
$("#character_popup").css("display") === "none" &&
|
||||
$("#shadow_select_chat_popup").css("display") === "none"
|
||||
($('.swipe_right:last').css('display') === 'flex' || $('.last_mes').attr('is_system') === 'true') &&
|
||||
$('#character_popup').css('display') === 'none' &&
|
||||
$('#shadow_select_chat_popup').css('display') === 'none'
|
||||
) {
|
||||
const isUserMesList = document.querySelectorAll('div[is_user="true"]');
|
||||
const lastIsUserMes = isUserMesList[isUserMesList.length - 1];
|
||||
@@ -1068,14 +1068,14 @@ export function initRossMods() {
|
||||
}
|
||||
}
|
||||
|
||||
if (event.key == "ArrowUp") { //edits last message if chatbar is empty and focused
|
||||
if (event.key == 'ArrowUp') { //edits last message if chatbar is empty and focused
|
||||
//console.log('got uparrow input');
|
||||
if (
|
||||
$("#send_textarea").val() === '' &&
|
||||
$('#send_textarea').val() === '' &&
|
||||
chatbarInFocus === true &&
|
||||
$(".swipe_right:last").css('display') === 'flex' &&
|
||||
$("#character_popup").css("display") === "none" &&
|
||||
$("#shadow_select_chat_popup").css("display") === "none"
|
||||
$('.swipe_right:last').css('display') === 'flex' &&
|
||||
$('#character_popup').css('display') === 'none' &&
|
||||
$('#shadow_select_chat_popup').css('display') === 'none'
|
||||
) {
|
||||
const lastMes = document.querySelector('.last_mes');
|
||||
const editMes = lastMes.querySelector('.mes_block .mes_edit');
|
||||
@@ -1085,42 +1085,42 @@ export function initRossMods() {
|
||||
}
|
||||
}
|
||||
|
||||
if (event.key == "Escape") { //closes various panels
|
||||
if (event.key == 'Escape') { //closes various panels
|
||||
|
||||
//dont override Escape hotkey functions from script.js
|
||||
//"close edit box" and "cancel stream generation".
|
||||
if ($("#curEditTextarea").is(":visible") || $("#mes_stop").is(":visible")) {
|
||||
if ($('#curEditTextarea').is(':visible') || $('#mes_stop').is(':visible')) {
|
||||
console.debug('escape key, but deferring to script.js routines')
|
||||
return
|
||||
}
|
||||
|
||||
if ($("#dialogue_popup").is(":visible")) {
|
||||
if ($("#dialogue_popup_cancel").is(":visible")) {
|
||||
$("#dialogue_popup_cancel").trigger('click');
|
||||
if ($('#dialogue_popup').is(':visible')) {
|
||||
if ($('#dialogue_popup_cancel').is(':visible')) {
|
||||
$('#dialogue_popup_cancel').trigger('click');
|
||||
return
|
||||
} else {
|
||||
$("#dialogue_popup_ok").trigger('click')
|
||||
$('#dialogue_popup_ok').trigger('click')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if ($("#select_chat_popup").is(":visible")) {
|
||||
$("#select_chat_cross").trigger('click');
|
||||
if ($('#select_chat_popup').is(':visible')) {
|
||||
$('#select_chat_cross').trigger('click');
|
||||
return
|
||||
}
|
||||
|
||||
if ($("#character_popup").is(":visible")) {
|
||||
$("#character_cross").trigger('click');
|
||||
if ($('#character_popup').is(':visible')) {
|
||||
$('#character_cross').trigger('click');
|
||||
return
|
||||
}
|
||||
|
||||
if ($(".drawer-content")
|
||||
if ($('.drawer-content')
|
||||
.not('#WorldInfo')
|
||||
.not('#left-nav-panel')
|
||||
.not('#right-nav-panel')
|
||||
.not('#floatingPrompt')
|
||||
.is(":visible")) {
|
||||
let visibleDrawerContent = $(".drawer-content:visible")
|
||||
.is(':visible')) {
|
||||
let visibleDrawerContent = $('.drawer-content:visible')
|
||||
.not('#WorldInfo')
|
||||
.not('#left-nav-panel')
|
||||
.not('#right-nav-panel')
|
||||
@@ -1129,28 +1129,28 @@ export function initRossMods() {
|
||||
return
|
||||
}
|
||||
|
||||
if ($("#floatingPrompt").is(":visible")) {
|
||||
$("#ANClose").trigger('click');
|
||||
if ($('#floatingPrompt').is(':visible')) {
|
||||
$('#ANClose').trigger('click');
|
||||
return
|
||||
}
|
||||
|
||||
if ($("#WorldInfo").is(":visible")) {
|
||||
$("#WIDrawerIcon").trigger('click');
|
||||
if ($('#WorldInfo').is(':visible')) {
|
||||
$('#WIDrawerIcon').trigger('click');
|
||||
return
|
||||
}
|
||||
|
||||
if ($("#left-nav-panel").is(":visible") &&
|
||||
if ($('#left-nav-panel').is(':visible') &&
|
||||
$(LPanelPin).prop('checked') === false) {
|
||||
$("#leftNavDrawerIcon").trigger('click');
|
||||
$('#leftNavDrawerIcon').trigger('click');
|
||||
return
|
||||
}
|
||||
|
||||
if ($("#right-nav-panel").is(":visible") &&
|
||||
if ($('#right-nav-panel').is(':visible') &&
|
||||
$(RPanelPin).prop('checked') === false) {
|
||||
$("#rightNavDrawerIcon").trigger('click');
|
||||
$('#rightNavDrawerIcon').trigger('click');
|
||||
return
|
||||
}
|
||||
if ($(".draggable").is(":visible")) {
|
||||
if ($('.draggable').is(':visible')) {
|
||||
// Remove the first matched element
|
||||
$('.draggable:first').remove();
|
||||
return;
|
||||
@@ -1163,7 +1163,7 @@ export function initRossMods() {
|
||||
if (event.ctrlKey && /^[1-9]$/.test(event.key)) {
|
||||
// This will eventually be to trigger quick replies
|
||||
event.preventDefault();
|
||||
console.log("Ctrl +" + event.key + " pressed!");
|
||||
console.log('Ctrl +' + event.key + ' pressed!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user