diff --git a/public/index.html b/public/index.html index 13f59da05..e6f70355a 100644 --- a/public/index.html +++ b/public/index.html @@ -4011,6 +4011,10 @@ Compact Input Area + + + Swipe # for All Messages + Characters Hotswap @@ -5939,7 +5943,7 @@ - + diff --git a/public/script.js b/public/script.js index 6d93bc03b..cf3061708 100644 --- a/public/script.js +++ b/public/script.js @@ -83,6 +83,7 @@ import { resetMovableStyles, forceCharacterEditorTokenize, applyPowerUserSettings, + switchSwipeNumAllMessages, } from './scripts/power-user.js'; import { @@ -2368,9 +2369,20 @@ export function addOneMessage(mes, { type = 'normal', insertAfter = null, scroll addCopyToCodeBlocks(newMessage); + //const currentMessage = $('#chat').children().filter(`[mesid="${chat.length - 1}"]`); + + // Set the swipes counter for past messages, only visible if 'Show Sipes on All Message' is enabled + if (!params.isUser && newMessageId !== 0) { + 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'); + $('#chat .mes').eq(-2).removeClass('last_mes') + .find('.swipe_right').removeClass('fa-chevron-right'); //otherwise it stays looking like it did when it was last_mes hideSwipeButtons(); showSwipeButtons(); } @@ -7489,19 +7501,25 @@ export function showSwipeButtons() { //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 + currentMessage.children('.swipe_right').addClass('fa-chevron-right').css('opacity', '0.7'); } //console.log(swipesCounterHTML); - $('.swipes-counter').text(swipeCounterText); + //allows for writing individual swipe counters for past messages + $('.last_mes .swipes-counter').text(swipeCounterText); //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('.last_mes .swipe_right').css('display', 'none'); $('#chat').find('.swipe_left').css('display', 'none'); } @@ -9395,9 +9413,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..bfb82a6a5 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,35 @@ function switchCompactInputArea() { $('#compact_input_area').prop('checked', power_user.compact_input_area); } +export function switchSwipeNumAllMessages() { + console.error('switching branch button initialted, function start!'); + $('#show_swipe_num_all_messages').prop('checked', power_user.show_swipe_num_all_messages); + + if (power_user.show_swipe_num_all_messages) { + + $('.mes').each(function () { + //if the div also has the .lst_mes class, skip the loop for that item + if ($(this).hasClass('last_mes')) { + return; + } + //add the cloned button to every .mes .swipe_right EXCLUDING .mes.last_mes + $(this).find('.swipe_right').css('display', 'flex'); + }); + + } else if (!power_user.show_swipe_num_all_messages) { + $('.mes:not(.last_mes)').each(function () { + if ($(this).hasClass('last_mes')) { + return; + } + //add the cloned button back to its original spot + $(this).find('.swipe_right').css('display', 'none'); + }); + + } + + +} + var originalSliderValues = []; async function switchLabMode() { @@ -1283,6 +1313,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 +1389,7 @@ function applyPowerUserSettings() { switchHideChatAvatars(); switchTokenCount(); switchMessageActions(); + switchSwipeNumAllMessages(); } function getExampleMessagesBehavior() { @@ -2296,6 +2334,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 +3794,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();