diff --git a/public/index.html b/public/index.html index d272ca96a..c6117f665 100644 --- a/public/index.html +++ b/public/index.html @@ -4010,6 +4010,10 @@ Compact Input Area + + + Swipe # for All Messages + Characters Hotswap @@ -5938,9 +5942,10 @@ - - - + + + + diff --git a/public/script.js b/public/script.js index b5a703f33..35bfcbab0 100644 --- a/public/script.js +++ b/public/script.js @@ -83,6 +83,7 @@ import { resetMovableStyles, forceCharacterEditorTokenize, applyPowerUserSettings, + switchSwipeNumAllMessages, } from './scripts/power-user.js'; import { @@ -2369,6 +2370,13 @@ export function addOneMessage(mes, { type = 'normal', insertAfter = null, scroll addCopyToCodeBlocks(newMessage); + // Set the swipes counter for past messages, only visible if 'Show Swipes on All Message' is enabled + if (!params.isUser && newMessageId !== 0 && newMessageId !== chat.length - 1) { + const swipesNum = chat[newMessageId].swipes?.length; + const swipeId = chat[newMessageId].swipe_id + 1; + newMessage.find('.swipes-counter').text(`${swipeId}\u200B/\u200b${swipesNum}`); + } + if (showSwipes) { $('#chat .mes').last().addClass('last_mes'); $('#chat .mes').eq(-2).removeClass('last_mes'); @@ -7471,7 +7479,6 @@ export function showSwipeButtons() { //had to add this to make the swipe counter work //(copied from the onclick functions for swipe buttons.. //don't know why the array isn't set for non-swipe messsages in Generate or addOneMessage..) - if (chat[chat.length - 1]['swipe_id'] === undefined) { // if there is no swipe-message in the last spot of the chat array chat[chat.length - 1]['swipe_id'] = 0; // set it to id 0 chat[chat.length - 1]['swipes'] = []; // empty the array @@ -7481,32 +7488,36 @@ export function showSwipeButtons() { const currentMessage = $('#chat').children().filter(`[mesid="${chat.length - 1}"]`); const swipeId = chat[chat.length - 1].swipe_id; const swipeCounterText = (`${(swipeId + 1)}\u200B/\u200b${(chat[chat.length - 1].swipes.length)}`); + const swipeRight = currentMessage.find('.swipe_right'); + const swipeLeft = currentMessage.find('.swipe_left'); + const swipeCounter = currentMessage.find('.swipes-counter'); if (swipeId !== undefined && (chat[chat.length - 1].swipes.length > 1 || swipeId > 0)) { - currentMessage.children('.swipe_left').css('display', 'flex'); + swipeLeft.css('display', 'flex'); } //only show right when generate is off, or when next right swipe would not make a generate happen if (is_send_press === false || chat[chat.length - 1].swipes.length >= swipeId) { - currentMessage.children('.swipe_right').css('display', 'flex'); - currentMessage.children('.swipe_right').css('opacity', '0.3'); + swipeRight.css('display', 'flex').css('opacity', '0.3'); + swipeCounter.css('opacity', '0.3'); } - //console.log((chat[chat.length - 1])); if ((chat[chat.length - 1].swipes.length - swipeId) === 1) { - //console.log('highlighting R swipe'); - currentMessage.children('.swipe_right').css('opacity', '0.7'); + //chevron was moved out of hardcode in HTML to class toggle dependent on last_mes or not + //necessary for 'swipe_right' div in past messages to have no chevron if 'show swipes for all messages' is turned on + swipeRight.css('opacity', '0.7'); + swipeCounter.css('opacity', '0.7'); } - //console.log(swipesCounterHTML); - $('.swipes-counter').text(swipeCounterText); + //allows for writing individual swipe counters for past messages + const lastSwipeCounter = $('.last_mes .swipes-counter'); + lastSwipeCounter.text(swipeCounterText).show(); - //console.log(swipeId); - //console.log(chat[chat.length - 1].swipes.length); + switchSwipeNumAllMessages(); } export function hideSwipeButtons() { - //console.log('hideswipebuttons entered'); - $('#chat').find('.swipe_right').css('display', 'none'); - $('#chat').find('.swipe_left').css('display', 'none'); + $('#chat').find('.swipe_right').hide(); + $('#chat').find('.last_mes .swipes-counter').hide(); + $('#chat').find('.swipe_left').hide(); } /** @@ -8341,8 +8352,8 @@ const swipe_right = () => { } const currentMessage = $('#chat').children().filter(`[mesid="${chat.length - 1}"]`); - let this_div = currentMessage.children('.swipe_right'); - let this_mes_div = this_div.parent(); + let this_div = currentMessage.find('.swipe_right'); + let this_mes_div = this_div.parent().parent(); if (chat[chat.length - 1]['swipe_id'] > chat[chat.length - 1]['swipes'].length) { //if we swipe right while generating (the swipe ID is greater than what we are viewing now) chat[chat.length - 1]['swipe_id'] = chat[chat.length - 1]['swipes'].length; //show that message slot (will be '...' while generating) @@ -8352,7 +8363,7 @@ const swipe_right = () => { } // handles animated transitions when swipe right, specifically height transitions between messages if (run_generate || run_swipe_right) { - let this_mes_block = this_mes_div.children('.mes_block').children('.mes_text'); + let this_mes_block = this_mes_div.find('.mes_block .mes_text'); const this_mes_div_height = this_mes_div[0].scrollHeight; const this_mes_block_height = this_mes_block[0].scrollHeight; @@ -9409,9 +9420,9 @@ jQuery(async function () { ///// SWIPE BUTTON CLICKS /////// - $(document).on('click', '.swipe_right', swipe_right); - - $(document).on('click', '.swipe_left', swipe_left); + //limit swiping to only last message clicks + $(document).on('click', '.last_mes .swipe_right', swipe_right); + $(document).on('click', '.last_mes .swipe_left', swipe_left); const debouncedCharacterSearch = debounce((searchQuery) => { entitiesFilter.setFilterData(FILTER_TYPES.SEARCH, searchQuery); diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index 8b2a81a16..bd618bad0 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -290,6 +290,7 @@ let power_user = { restore_user_input: true, reduced_motion: false, compact_input_area: true, + show_swipe_num_all_messages: false, auto_connect: false, auto_load_chat: false, forbid_external_media: true, @@ -469,6 +470,11 @@ function switchCompactInputArea() { $('#compact_input_area').prop('checked', power_user.compact_input_area); } +export function switchSwipeNumAllMessages() { + $('#show_swipe_num_all_messages').prop('checked', power_user.show_swipe_num_all_messages); + $('.mes:not(.last_mes) .swipes-counter').css('opacity', '').toggle(power_user.show_swipe_num_all_messages); +} + var originalSliderValues = []; async function switchLabMode() { @@ -1283,6 +1289,13 @@ function applyTheme(name) { switchCompactInputArea(); }, }, + { + key: 'show_swipe_num_all_messages', + action: () => { + $('#show_swipe_num_all_messages').prop('checked', power_user.show_swipe_num_all_messages); + switchSwipeNumAllMessages(); + }, + }, ]; for (const { key, selector, type, action } of themeProperties) { @@ -1352,6 +1365,7 @@ function applyPowerUserSettings() { switchHideChatAvatars(); switchTokenCount(); switchMessageActions(); + switchSwipeNumAllMessages(); } function getExampleMessagesBehavior() { @@ -2296,6 +2310,7 @@ function getThemeObject(name) { zoomed_avatar_magnification: power_user.zoomed_avatar_magnification, reduced_motion: power_user.reduced_motion, compact_input_area: power_user.compact_input_area, + show_swipe_num_all_messages: power_user.show_swipe_num_all_messages, }; } @@ -3755,6 +3770,12 @@ $(document).ready(() => { saveSettingsDebounced(); }); + $('#show_swipe_num_all_messages').on('input', function () { + power_user.show_swipe_num_all_messages = !!$(this).prop('checked'); + switchSwipeNumAllMessages(); + saveSettingsDebounced(); + }); + $('#auto-connect-checkbox').on('input', function () { power_user.auto_connect = !!$(this).prop('checked'); saveSettingsDebounced(); diff --git a/public/style.css b/public/style.css index 7d55cf832..01a49ab9f 100644 --- a/public/style.css +++ b/public/style.css @@ -969,34 +969,53 @@ body .panelControlBar { /* SWIPE RELATED STYLES*/ +.mes { + --swipeCounterHeight: 15px; + --swipeCounterMargin: 5px; +} + .swipe_right, .swipe_left { - height: 40px; - width: 40px; + width: 25px; + height: 25px; opacity: 0.3; align-items: center; justify-content: center; z-index: 9999; grid-row-start: 2; - font-size: 30px; + font-size: 20px; cursor: pointer; align-self: center; - position: absolute; -bottom: 15px; -flex-flow: column; } +.swipe_left { + position: absolute; + bottom: calc(var(--swipeCounterHeight) + var(--swipeCounterMargin)); + flex-flow: column; +} + +.swipeRightBlock { + position: absolute; + right: 0; + bottom: 0; +} .swipes-counter { color: var(--SmartThemeBodyColor); font-size: 12px; - padding: 0; + padding: 0 5px; font-family: var(--mainFontFamily); font-weight: 400; align-self: center; min-width: 40px; display: flex; justify-content: center; + margin-bottom: var(--swipeCounterMargin); + height: var(--swipeCounterHeight); +} + +.mes:not(.last_mes) .swipes-counter { + opacity: 0.3; } .swipe_left { @@ -1006,7 +1025,7 @@ flex-flow: column; .swipe_right { right: 5px; - align-self:end; + align-self: center; } .ui-settings { @@ -2640,7 +2659,7 @@ select option:not(:checked) { #instruct_enabled_label .menu_button:not(.toggleEnabled), #sysprompt_enabled_label .menu_button:not(.toggleEnabled) { - color: Red; + color: Red; } .displayBlock {