From 00951eb79114adf74ad1a3f1ce596e9e0fa932bf Mon Sep 17 00:00:00 2001 From: H Lohaus Date: Wed, 10 Apr 2024 08:14:50 +0200 Subject: Add OpenRouter and DeepInfraImage Provider (#1814) --- g4f/gui/client/static/js/chat.v1.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'g4f/gui/client/static/js/chat.v1.js') diff --git a/g4f/gui/client/static/js/chat.v1.js b/g4f/gui/client/static/js/chat.v1.js index 5036a93b..628d0682 100644 --- a/g4f/gui/client/static/js/chat.v1.js +++ b/g4f/gui/client/static/js/chat.v1.js @@ -42,7 +42,7 @@ appStorage = window.localStorage || { const markdown = window.markdownit(); const markdown_render = (content) => { return markdown.render(content - .replaceAll(/[\s\S]+/gm, "") + .replaceAll(/|/gm, "") .replaceAll(//gm, "") ) .replaceAll(" { container.classList.add("audio"); container.appendChild(sound); content_el.appendChild(container); + if (ended && !stopped) { + sound.play(); + } } if (lines.length < 1 || stopped) { el.classList.remove("active"); @@ -608,12 +608,11 @@ async function get_messages(conversation_id) { } async function add_conversation(conversation_id, content) { - if (content.length > 17) { - title = content.substring(0, 17) + '...' + if (content.length > 18) { + title = content.substring(0, 18) + '...' } else { - title = content + ' '.repeat(19 - content.length) + title = content + ' '.repeat(20 - content.length) } - if (appStorage.getItem(`conversation:${conversation_id}`) == null) { await save_conversation(conversation_id, { id: conversation_id, @@ -623,7 +622,6 @@ async function add_conversation(conversation_id, content) { items: [], }); } - history.pushState({}, null, `/chat/${conversation_id}`); } @@ -695,27 +693,31 @@ const load_conversations = async () => { await clear_conversations(); - for (conversation of conversations) { + conversations.sort((a, b) => (b.updated||0)-(a.updated||0)); + + let html = ""; + conversations.forEach((conversation) => { let updated = ""; if (conversation.updated) { const date = new Date(conversation.updated); updated = date.toLocaleString('en-GB', {dateStyle: 'short', timeStyle: 'short', monthStyle: 'short'}); updated = updated.replace("/" + date.getFullYear(), "") } - box_conversations.innerHTML += ` + html += `
${updated} ${conversation.title}
- +
`; - } + }); + box_conversations.innerHTML = html; }; document.getElementById("cancelButton").addEventListener("click", async () => { @@ -804,6 +806,7 @@ const register_settings_storage = async () => { appStorage.setItem(element.id, element.selectedIndex); break; case "text": + case "number": appStorage.setItem(element.id, element.value); break; default: @@ -828,6 +831,7 @@ const load_settings_storage = async () => { element.selectedIndex = parseInt(value); break; case "text": + case "number": case "textarea": element.value = value; break; -- cgit v1.2.3