initial commit, functional, needs proofing

034a5a48c25b934398149503e0a69f63e2655669

RossAscends <124905043+RossAscends@users.noreply.github.com>

3 files changed, +75 -8Ignore whitespace
public/index.html+5 -1
@@ -4011,6 +4011,10 @@
40114011 <input id="compact_input_area" type="checkbox" />
40124012 <small data-i18n="Compact Input Area (Mobile)">Compact Input Area</small><i class="fa-solid fa-mobile-screen-button"></i>
40134013 </label>
4014+ <label for="show_swipe_num_all_messages" class="checkbox_label" title="Display swipe numbers for all messages, not just the last." data-i18n="[title]Display swipe numbers for all messages, not just the last.">
4015+ <input id="show_swipe_num_all_messages" type="checkbox" />
4016+ <small data-i18n="Swipe # for All Messages">Swipe # for All Messages</small><i class="fa-solid fa-mobile-screen-button"></i>
4017+ </label>
40144018 <label for="hotswapEnabled" class="checkbox_label" title="In the Character Management panel, show quick selection buttons for favorited characters." data-i18n="[title]In the Character Management panel, show quick selection buttons for favorited characters">
40154019 <input id="hotswapEnabled" type="checkbox" />
40164020 <small data-i18n="Characters Hotswap">Characters Hotswap</small>
@@ -5939,7 +5943,7 @@
59395943 </div>
59405944 <div class="mes_bias"></div>
59415945 </div>
59425946 <div class="swipe_right fa-solid fa-chevron-right" style="display: none;">
59435947 <div class="swipes-counter"></div>
59445948 </div>
59455949 </div>
public/script.js+25 -7
@@ -83,6 +83,7 @@ import {
8383 resetMovableStyles,
8484 forceCharacterEditorTokenize,
8585 applyPowerUserSettings,
86+ switchSwipeNumAllMessages,
8687} from './scripts/power-user.js';
8788
8889import {
@@ -2368,9 +2369,20 @@ export function addOneMessage(mes, { type = 'normal', insertAfter = null, scroll
23682369
23692370 addCopyToCodeBlocks(newMessage);
23702371
2372+ //const currentMessage = $('#chat').children().filter(`[mesid="${chat.length - 1}"]`);
2373+
2374+ // Set the swipes counter for past messages, only visible if 'Show Sipes on All Message' is enabled
2375+ if (!params.isUser && newMessageId !== 0) {
2376+ const swipesNum = chat[newMessageId].swipes?.length;
2377+ const swipeId = chat[newMessageId].swipe_id + 1;
2378+ newMessage.find('.swipes-counter').text(`${swipeId}\u200B/\u200b${swipesNum}`);
2379+ }
2380+
2381+
23712382 if (showSwipes) {
23722383 $('#chat .mes').last().addClass('last_mes');
23732384 $('#chat .mes').eq(-2).removeClass('last_mes');
2385+ .find('.swipe_right').removeClass('fa-chevron-right'); //otherwise it stays looking like it did when it was last_mes
23742386 hideSwipeButtons();
23752387 showSwipeButtons();
23762388 }
@@ -7489,19 +7501,25 @@ export function showSwipeButtons() {
74897501 //console.log((chat[chat.length - 1]));
74907502 if ((chat[chat.length - 1].swipes.length - swipeId) === 1) {
74917503 //console.log('highlighting R swipe');
7492- currentMessage.children('.swipe_right').css('opacity', '0.7');
7504+
7505+ //chevron was moved out of hardcode in HTML to class toggle dependent on last_mes or not
7506+ //necessary for 'swipe_right' div in past messages to have no chevron if 'show swipes for all messages' is turned on
7507+ currentMessage.children('.swipe_right').addClass('fa-chevron-right').css('opacity', '0.7');
74937508 }
74947509 //console.log(swipesCounterHTML);
74957510
7496- $('.swipes-counter').text(swipeCounterText);
7511+ //allows for writing individual swipe counters for past messages
7512+ $('.last_mes .swipes-counter').text(swipeCounterText);
74977513
74987514 //console.log(swipeId);
74997515 //console.log(chat[chat.length - 1].swipes.length);
7516+
7517+ switchSwipeNumAllMessages();
75007518}
75017519
75027520export function hideSwipeButtons() {
75037521 //console.log('hideswipebuttons entered');
75047522 $('#chat').find('.last_mes .swipe_right').css('display', 'none');
75057523 $('#chat').find('.swipe_left').css('display', 'none');
75067524}
75077525
@@ -9395,9 +9413,9 @@ jQuery(async function () {
93959413
93969414 ///// SWIPE BUTTON CLICKS ///////
93979415
9398- $(document).on('click', '.swipe_right', swipe_right);
9416+ //limit swiping to only last message clicks
9399-
9417+ $(document).on('click', '.last_mes .swipe_right', swipe_right);
94009418 $(document).on('click', '.last_mes .swipe_left', swipe_left);
94019419
94029420 const debouncedCharacterSearch = debounce((searchQuery) => {
94039421 entitiesFilter.setFilterData(FILTER_TYPES.SEARCH, searchQuery);
public/scripts/power-user.js+45 -0
@@ -290,6 +290,7 @@ let power_user = {
290290 restore_user_input: true,
291291 reduced_motion: false,
292292 compact_input_area: true,
293+ show_swipe_num_all_messages: false,
293294 auto_connect: false,
294295 auto_load_chat: false,
295296 forbid_external_media: true,
@@ -469,6 +470,35 @@ function switchCompactInputArea() {
469470 $('#compact_input_area').prop('checked', power_user.compact_input_area);
470471}
471472
473+export function switchSwipeNumAllMessages() {
474+ console.error('switching branch button initialted, function start!');
475+ $('#show_swipe_num_all_messages').prop('checked', power_user.show_swipe_num_all_messages);
476+
477+ if (power_user.show_swipe_num_all_messages) {
478+
479+ $('.mes').each(function () {
480+ //if the div also has the .lst_mes class, skip the loop for that item
481+ if ($(this).hasClass('last_mes')) {
482+ return;
483+ }
484+ //add the cloned button to every .mes .swipe_right EXCLUDING .mes.last_mes
485+ $(this).find('.swipe_right').css('display', 'flex');
486+ });
487+
488+ } else if (!power_user.show_swipe_num_all_messages) {
489+ $('.mes:not(.last_mes)').each(function () {
490+ if ($(this).hasClass('last_mes')) {
491+ return;
492+ }
493+ //add the cloned button back to its original spot
494+ $(this).find('.swipe_right').css('display', 'none');
495+ });
496+
497+ }
498+
499+
500+}
501+
472502var originalSliderValues = [];
473503
474504async function switchLabMode() {
@@ -1283,6 +1313,13 @@ function applyTheme(name) {
12831313 switchCompactInputArea();
12841314 },
12851315 },
1316+ {
1317+ key: 'show_swipe_num_all_messages',
1318+ action: () => {
1319+ $('#show_swipe_num_all_messages').prop('checked', power_user.show_swipe_num_all_messages);
1320+ switchSwipeNumAllMessages();
1321+ },
1322+ },
12861323 ];
12871324
12881325 for (const { key, selector, type, action } of themeProperties) {
@@ -1352,6 +1389,7 @@ function applyPowerUserSettings() {
13521389 switchHideChatAvatars();
13531390 switchTokenCount();
13541391 switchMessageActions();
1392+ switchSwipeNumAllMessages();
13551393}
13561394
13571395function getExampleMessagesBehavior() {
@@ -2296,6 +2334,7 @@ function getThemeObject(name) {
22962334 zoomed_avatar_magnification: power_user.zoomed_avatar_magnification,
22972335 reduced_motion: power_user.reduced_motion,
22982336 compact_input_area: power_user.compact_input_area,
2337+ show_swipe_num_all_messages: power_user.show_swipe_num_all_messages,
22992338 };
23002339}
23012340
@@ -3755,6 +3794,12 @@ $(document).ready(() => {
37553794 saveSettingsDebounced();
37563795 });
37573796
3797+ $('#show_swipe_num_all_messages').on('input', function () {
3798+ power_user.show_swipe_num_all_messages = !!$(this).prop('checked');
3799+ switchSwipeNumAllMessages();
3800+ saveSettingsDebounced();
3801+ });
3802+
37583803 $('#auto-connect-checkbox').on('input', function () {
37593804 power_user.auto_connect = !!$(this).prop('checked');
37603805 saveSettingsDebounced();