Add simplified UI switch

This commit is contained in:
Cohee
2023-08-29 18:04:10 +03:00
parent 7810c411df
commit 44f88c61ff
7 changed files with 171 additions and 100 deletions

View File

@ -51,6 +51,11 @@ const defaultStoryString = "{{#if system}}{{system}}\n{{/if}}{{#if description}}
const defaultExampleSeparator = '***';
const defaultChatStart = '***';
export const ui_mode = {
SIMPLE: 0,
POWER: 1,
}
const avatar_styles = {
ROUND: 0,
RECTANGULAR: 1,
@ -101,6 +106,7 @@ let power_user = {
multigen_next_chunks: 30,
markdown_escape_strings: '',
ui_mode: ui_mode.POWER,
fast_ui_mode: true,
avatar_style: avatar_styles.ROUND,
chat_display: chat_styles.DEFAULT,
@ -238,6 +244,12 @@ const storage_keys = {
let browser_has_focus = true;
const debug_functions = [];
export function switchSimpleMode() {
$('[data-newbie-hidden]').each(function () {
$(this).toggleClass('displayNone', power_user.ui_mode === ui_mode.SIMPLE);
});
}
function playMessageSound() {
if (!power_user.play_message_sound) {
return;
@ -824,6 +836,7 @@ function loadPowerUserSettings(settings, data) {
$("#user-mes-blur-tint-color-picker").attr('color', power_user.user_mes_blur_tint_color);
$("#bot-mes-blur-tint-color-picker").attr('color', power_user.bot_mes_blur_tint_color);
$("#shadow-color-picker").attr('color', power_user.shadow_color);
$("#ui_mode_select").val(power_user.ui_mode).find(`option[value="${power_user.ui_mode}"]`).attr('selected', true);
for (const theme of themes) {
const option = document.createElement('option');
@ -851,6 +864,7 @@ function loadPowerUserSettings(settings, data) {
switchSpoilerMode();
loadMovingUIState();
loadCharListState();
switchSimpleMode();
}
async function loadCharListState() {
@ -2150,6 +2164,13 @@ $(document).ready(() => {
showDebugMenu();
});
$("#ui_mode_select").on('change', function () {
const value = $(this).find(':selected').val();
power_user.ui_mode = Number(value);
saveSettingsDebounced();
switchSimpleMode();
});
$(document).on('click', '#debug_table [data-debug-function]', function () {
const functionId = $(this).data('debug-function');
const functionRecord = debug_functions.find(f => f.functionId === functionId);