Add config option to configure chat background

This commit is contained in:
天クマ 2026-07-17 16:06:29 -03:00
commit 36f8448bf9
5 changed files with 37 additions and 6 deletions

View file

@ -130,6 +130,7 @@
<h2>SETTINGS</h2> <h2>SETTINGS</h2>
</header> </header>
<div class="modal-body"> <div class="modal-body">
<h3>server</h3>
<div class="form-group"> <div class="form-group">
<label for="settings-waha-url">WAHA Server URL</label> <label for="settings-waha-url">WAHA Server URL</label>
<input type="text" id="settings-waha-url" placeholder="http://localhost:3100"> <input type="text" id="settings-waha-url" placeholder="http://localhost:3100">
@ -143,9 +144,18 @@
<input type="password" id="settings-api-key" placeholder="Enter API Key"> <input type="password" id="settings-api-key" placeholder="Enter API Key">
</div> </div>
<p class="settings-warning">Note: Requests are sent directly from your browser to the WAHA server. Make sure CORS is enabled on your WAHA instance.</p> <p class="settings-warning">Note: Requests are sent directly from your browser to the WAHA server. Make sure CORS is enabled on your WAHA instance.</p>
<h3>chats</h3>
<div class="form-group">
<label for="settings-background-image">Chat background image</label>
<input type="text" id="settings-background-image" placeholder="Enter image URL">
</div>
<div class="form-group">
<label for="settings-background-opacity">Chat background opacity</label>
<input type="number" min="0" max="1" step="0.1" id="settings-background-opacity" placeholder="Enter opacity value">
</div>
</div> </div>
<footer class="modal-footer"> <footer class="modal-footer">
<button class="btn primary-btn" id="save-settings">Save Config</button> <button class="btn primary-btn" id="save-settings">Save</button>
</footer> </footer>
</div> </div>
</section> </section>

View file

@ -13,6 +13,10 @@ document.addEventListener('DOMContentLoaded', async () => {
elements.inputApiKey.value = config.apiKey; elements.inputApiKey.value = config.apiKey;
elements.inputWahaUrl.value = config.wahaUrl; elements.inputWahaUrl.value = config.wahaUrl;
elements.inputSession.value = config.session; elements.inputSession.value = config.session;
elements.inputBackgroundImage.value = config.bgImg;
elements.inputBackgroundOpacity.value = config.bgOpacity;
elements.activeChatContainer.style.setProperty('--background-image', `URL("${config.bgImg}")`);
elements.activeChatContainer.style.setProperty('--background-opacity', `${config.bgOpacity}`);
await updateOnlineStatus(); await updateOnlineStatus();
setupEventListeners(); setupEventListeners();
try { try {
@ -369,7 +373,9 @@ function saveSettings() {
config.save( config.save(
elements.inputWahaUrl.value, elements.inputWahaUrl.value,
elements.inputSession.value, elements.inputSession.value,
elements.inputApiKey.value elements.inputApiKey.value,
elements.inputBackgroundImage.value,
elements.inputBackgroundOpacity.value
); );
location.reload(); location.reload();
loadChats(); loadChats();

View file

@ -4,14 +4,20 @@ export const config = {
wahaUrl: localStorage.getItem('waha_url') || 'http://inspiran.beetal-castor.ts.net:3100', wahaUrl: localStorage.getItem('waha_url') || 'http://inspiran.beetal-castor.ts.net:3100',
session: localStorage.getItem('waha_session') || 'session_01kxc62bk5fs8vh4v127k88a7j', session: localStorage.getItem('waha_session') || 'session_01kxc62bk5fs8vh4v127k88a7j',
apiKey: localStorage.getItem('waha_api_key') || '', apiKey: localStorage.getItem('waha_api_key') || '',
bgImg: localStorage.getItem('background_image') || '',
bgOpacity: localStorage.getItem('background_opacity') || '0.4',
save(url, session, apiKey) { save(url, session, apiKey, bgImg, bgOpacity) {
this.wahaUrl = url.trim().replace(/\/$/, ""); this.wahaUrl = url.trim().replace(/\/$/, "");
this.session = session.trim(); this.session = session.trim();
this.apiKey = apiKey.trim(); this.apiKey = apiKey.trim();
this.bgImg = bgImg.trim();
this.bgOpacity = bgOpacity.trim();
localStorage.setItem('waha_url', this.wahaUrl); localStorage.setItem('waha_url', this.wahaUrl);
localStorage.setItem('waha_session', this.session); localStorage.setItem('waha_session', this.session);
localStorage.setItem('waha_api_key', this.apiKey); localStorage.setItem('waha_api_key', this.apiKey);
localStorage.setItem('background_image', this.bgImg);
localStorage.setItem('background_opacity', this.bgOpacity);
} }
}; };

View file

@ -24,6 +24,8 @@ export const elements = {
inputWahaUrl: document.getElementById('settings-waha-url'), inputWahaUrl: document.getElementById('settings-waha-url'),
inputSession: document.getElementById('settings-session'), inputSession: document.getElementById('settings-session'),
inputApiKey: document.getElementById('settings-api-key'), inputApiKey: document.getElementById('settings-api-key'),
inputBackgroundImage: document.getElementById('settings-background-image'),
inputBackgroundOpacity: document.getElementById('settings-background-opacity'),
loggedUserName: document.getElementById('pandora-username'), loggedUserName: document.getElementById('pandora-username'),
chatBottomBar: document.getElementById('chat-bottom-bar'), chatBottomBar: document.getElementById('chat-bottom-bar'),
chatBottomBarBtn: document.getElementById('chat-bottom-bar-btn'), chatBottomBarBtn: document.getElementById('chat-bottom-bar-btn'),

View file

@ -19,6 +19,7 @@
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.1); --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
--glass-blur: blur(20px); --glass-blur: blur(20px);
--high-box-shadow: 2px 7px 5px rgba(0, 0, 0, 0.3), 0px -4px 10px rgba(0, 0, 0, 0.3);
} }
* { * {
@ -65,7 +66,7 @@ button:hover {
} }
input { input {
background: var(--bg-main); background: var(--bg-secondary);
color: var(--accent); color: var(--accent);
border: none; border: none;
padding: 1em; padding: 1em;
@ -485,7 +486,7 @@ input:focus {
background-size: cover; background-size: cover;
background-position: center; background-position: center;
background-repeat: no-repeat; background-repeat: no-repeat;
opacity: 0.4; opacity: var(--background-opacity);
pointer-events: none; pointer-events: none;
z-index: 0; z-index: 0;
} }
@ -564,9 +565,10 @@ input:focus {
.load-more-btn { .load-more-btn {
margin: auto; margin: auto;
background-color: var(--bg-secondary); background-color: rgba(255, 255, 255, 0.1);
padding: .4em; padding: .4em;
cursor: pointer; cursor: pointer;
box-shadow: var(--high-box-shadow);
} }
.load-more-btn:hover { .load-more-btn:hover {
@ -904,6 +906,11 @@ input:focus {
height: 100%; height: 100%;
} }
.modal-body h3 {
font-size: xx-large;
font-weight: 100;
}
.modal-header { .modal-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;