openvibers/openvibe.live Commits

Popout chat: clicking a name opens its menu again (the page never loaded chat-shared.js, so every user menu stayed on "Loading..." with OpenVibeChat is not defined) (#232)

OP OpenVibers committed 27 days ago · 5e36382489 · 2 files, +23 −0

Changes

ddiff --git a/public/popout-chat.html b/public/popout-chat.html
iindex ff2d93eb..56e4fc76 100644
---- a/public/popout-chat.html
++++ b/public/popout-chat.html
@@@ -259,6 +259,9 @@
<script src="/js/opencoins.js"></script>
<script src="/js/cosmetics-ui.js"></script>
<script src="/js/lang-detect.js"></script>
++ <!-- OpenVibeChat (user menus, linkify, TTS link text): chat.js needs it, as on the main page. Without it every
++ name clicked in the popout stayed on "Loading..." (OpenVibeChat is not defined). -->
++ <script src="/js/chat-shared.js"></script>
<script src="/js/chat.js"></script>
<script src="/js/chat-autocomplete.js"></script>
<script>
ddiff --git a/test/chat-pages-scripts.test.js b/test/chat-pages-scripts.test.js
nnew file mode 100644
iindex 00000000..60369b9a
---- /dev/null
++++ b/test/chat-pages-scripts.test.js
@@@ -0,0 +1,20 @@
++'use strict';
++// Every page that loads public/js/chat.js loads public/js/chat-shared.js before it: chat.js builds its user menus,
++// links and TTS text with OpenVibeChat. The popout chat page did not (2026-10-17): every name clicked there stayed on
++// "Loading..." with "OpenVibeChat is not defined".
++//
++// node test/chat-pages-scripts.test.js
++const assert = require('assert');
++const fs = require('fs');
++const path = require('path');
++
++const pub = path.join(__dirname, '..', 'public');
++const pages = fs.readdirSync(pub).filter((f) => f.endsWith('.html')).map((f) => [f, fs.readFileSync(path.join(pub, f), 'utf8')])
++ .filter(([, html]) => /<script[^>]+src="\/js\/chat\.js[?"]/.test(html));
++assert.ok(pages.some(([f]) => f === 'popout-chat.html') && pages.some(([f]) => f === 'index.html'), 'the main page and the popout load chat.js');
++for (const [file, html] of pages) {
++ const shared = html.search(/<script[^>]+src="\/js\/chat-shared\.js[?"]/);
++ const chat = html.search(/<script[^>]+src="\/js\/chat\.js[?"]/);
++ assert.ok(shared >= 0 && shared < chat, `${file} loads chat-shared.js before chat.js`);
++}
++console.log(`chat pages scripts: ${pages.length} pages load chat-shared.js before chat.js`);