Public Access
maj auto 2
This commit is contained in:
1 parent
db2b137d6b
commit
98bd4d7fbf
5 files changed
+142
-73
No files matched your search
+79
-44
@@ -48,13 +48,72 @@ def get_theme_hdrs():
|
||||
.input-field:focus { outline: none; }
|
||||
.file-btn { background: #2a2a35; border: 1px solid #444; color: var(--accent-blue); width: 36px !important; height: 36px !important; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1.3em; text-decoration: none; flex-shrink: 0; }
|
||||
.btn-submit { background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple)); color: white; border: none; width: 36px !important; height: 36px !important; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1.1em; flex-shrink: 0; }
|
||||
.htmx-indicator { display: none; }
|
||||
.htmx-request .htmx-indicator { display: flex; }
|
||||
.tech-loader-container { display: flex; align-items: center; gap: 15px; color: var(--accent-blue); font-style: italic; background: var(--bg-panel); padding: 15px 20px; border-radius: 15px 15px 15px 0; border: 1px dashed var(--accent-blue); width: fit-content; margin-bottom: 20px; font-size: 0.9em; }
|
||||
|
||||
/* LOADER HTMX SURÉLEVÉ ET CENTRÉ (Flotte au-dessus du texte) */
|
||||
.htmx-indicator { display: none; opacity: 0; transition: opacity 0.3s ease-in; position: absolute; bottom: 140px; left: 50%; transform: translateX(-50%); z-index: 9999; }
|
||||
.htmx-request.htmx-indicator { display: flex !important; opacity: 1; }
|
||||
.htmx-request .htmx-indicator { display: flex !important; opacity: 1; }
|
||||
.tech-loader-container { display: flex; align-items: center; gap: 15px; color: var(--accent-blue); font-style: italic; background: #1e1e24; padding: 15px 25px; border-radius: 30px; border: 1px dashed var(--accent-blue); box-shadow: 0 5px 20px rgba(0,229,255,0.2); font-size: 0.9em; white-space: nowrap; }
|
||||
.tech-spinner { width: 20px; height: 20px; border: 3px solid rgba(0, 229, 255, 0.2); border-top-color: var(--accent-blue); border-radius: 50%; animation: spin 1s linear infinite; }
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
|
||||
@media (max-width: 768px) {
|
||||
body { flex-direction: column; }
|
||||
.sidebar { width: 100%; height: auto; max-height: 35vh; border-right: none; border-bottom: 1px solid #333; padding: 10px; }
|
||||
.sidebar-history { max-height: 120px; }
|
||||
.main-content { flex: 1; height: 65vh; }
|
||||
.chat-container { padding-bottom: 180px; padding-left: 10px; padding-right: 10px; }
|
||||
.user-bubble, .ai-bubble { max-width: 95%; }
|
||||
.input-area { padding: 10px; }
|
||||
}
|
||||
"""),
|
||||
Script(r"""
|
||||
// Sac à dos virtuel global pour additionner les fichiers sans les écraser
|
||||
let aethasFiles = new DataTransfer();
|
||||
|
||||
function syncFiles() {
|
||||
const fileInput = document.getElementById('file-upload');
|
||||
if(fileInput) fileInput.files = aethasFiles.files;
|
||||
renderFilePills();
|
||||
}
|
||||
|
||||
function renderFilePills() {
|
||||
let previewList = document.getElementById('file-preview-list');
|
||||
if(!previewList) return;
|
||||
previewList.innerHTML = '';
|
||||
for (let i = 0; i < aethasFiles.files.length; i++) {
|
||||
let file = aethasFiles.files[i];
|
||||
let pill = document.createElement('div');
|
||||
pill.className = 'file-pill';
|
||||
pill.innerHTML = `📎 ${file.name} <span style="cursor:pointer; color:#ff5555; margin-left:4px;" onclick="removeFile(${i})">✕</span>`;
|
||||
previewList.appendChild(pill);
|
||||
}
|
||||
}
|
||||
|
||||
function removeFile(index) {
|
||||
let dt = new DataTransfer();
|
||||
for (let i = 0; i < aethasFiles.files.length; i++) {
|
||||
if (i !== index) dt.items.add(aethasFiles.files[i]);
|
||||
}
|
||||
aethasFiles = dt;
|
||||
syncFiles();
|
||||
}
|
||||
|
||||
function handleFileSelection(input) {
|
||||
if (input.files) {
|
||||
for (let f of input.files) {
|
||||
let exists = false;
|
||||
for (let existing of aethasFiles.files) {
|
||||
if (existing.name === f.name) exists = true;
|
||||
}
|
||||
if (!exists && aethasFiles.files.length < 10) {
|
||||
aethasFiles.items.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
syncFiles();
|
||||
}
|
||||
|
||||
function renderMarkdown() {
|
||||
try {
|
||||
document.querySelectorAll('.markdown-raw').forEach(el => {
|
||||
@@ -124,47 +183,50 @@ def get_theme_hdrs():
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const ta = document.getElementById('prompt-input');
|
||||
const dropZone = document.querySelector('.input-container-box');
|
||||
const fileInput = document.getElementById('file-upload');
|
||||
|
||||
if (ta) {
|
||||
ta.addEventListener('input', () => autoResize(ta));
|
||||
ta.addEventListener('paste', (e) => {
|
||||
let items = (e.clipboardData || e.originalEvent.clipboardData).items;
|
||||
let dt = new DataTransfer();
|
||||
if (fileInput && fileInput.files) {
|
||||
for (let f of fileInput.files) dt.items.add(f);
|
||||
}
|
||||
let hasFiles = false;
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (items[i].kind === 'file') {
|
||||
let blob = items[i].getAsFile();
|
||||
if (blob) { dt.items.add(blob); hasFiles = true; }
|
||||
if (blob && aethasFiles.files.length < 10) {
|
||||
aethasFiles.items.add(blob);
|
||||
hasFiles = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasFiles) {
|
||||
e.preventDefault();
|
||||
fileInput.files = dt.files;
|
||||
handleFileSelection(fileInput);
|
||||
syncFiles();
|
||||
} else {
|
||||
setTimeout(() => autoResize(ta), 20);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (dropZone && fileInput) {
|
||||
if (dropZone) {
|
||||
['dragenter', 'dragover'].forEach(eName => dropZone.addEventListener(eName, e => { e.preventDefault(); dropZone.style.borderColor = 'var(--accent-blue)'; }));
|
||||
['dragleave', 'drop'].forEach(eName => dropZone.addEventListener(eName, e => { e.preventDefault(); dropZone.style.borderColor = '#444'; }));
|
||||
dropZone.addEventListener('drop', (e) => {
|
||||
e.preventDefault();
|
||||
let dt = new DataTransfer();
|
||||
if (fileInput.files) { for (let f of fileInput.files) dt.items.add(f); }
|
||||
for (let f of e.dataTransfer.files) {
|
||||
if (dt.files.length < 10) dt.items.add(f);
|
||||
if (aethasFiles.files.length < 10) aethasFiles.items.add(f);
|
||||
}
|
||||
fileInput.files = dt.files;
|
||||
handleFileSelection(fileInput);
|
||||
syncFiles();
|
||||
});
|
||||
}
|
||||
|
||||
// Vider le sac à dos virtel une fois la requête HTMX envoyée !
|
||||
document.body.addEventListener('htmx:afterRequest', function(evt) {
|
||||
if(evt.detail.target.id === 'chat-history') {
|
||||
aethasFiles = new DataTransfer();
|
||||
syncFiles();
|
||||
if(ta) ta.style.height = '36px';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function copyCodeBlock(btn) {
|
||||
@@ -198,33 +260,6 @@ def get_theme_hdrs():
|
||||
}
|
||||
}
|
||||
|
||||
function handleFileSelection(input) {
|
||||
let previewList = document.getElementById('file-preview-list');
|
||||
previewList.innerHTML = '';
|
||||
if (input.files) {
|
||||
if (input.files.length > 10) alert("Maximum 10 fichiers autorisés.");
|
||||
let count = Math.min(input.files.length, 10);
|
||||
for (let i = 0; i < count; i++) {
|
||||
let file = input.files[i];
|
||||
let pill = document.createElement('div');
|
||||
pill.className = 'file-pill';
|
||||
pill.innerHTML = `📎 ${file.name} <span style="cursor:pointer; color:#ff5555; margin-left:4px;" onclick="removeFile(${i})">✕</span>`;
|
||||
previewList.appendChild(pill);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removeFile(index) {
|
||||
let fileInput = document.getElementById('file-upload');
|
||||
let dt = new DataTransfer();
|
||||
let { files } = fileInput;
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
if (i !== index) dt.items.add(files[i]);
|
||||
}
|
||||
fileInput.files = dt.files;
|
||||
handleFileSelection(fileInput);
|
||||
}
|
||||
|
||||
function downloadResponsePDF(btn) {
|
||||
let content = btn.closest('.ai-bubble').querySelector('.markdown-rendered');
|
||||
let filename = getSmartFilename(btn, 'Aethas38_Reponse', 'pdf');
|
||||
|
||||
Reference in new issue
Block a user