Skip to content

Commit 2a4c0c4

Browse files
authored
Update script.js
1 parent 56c2d4d commit 2a4c0c4

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

script.js

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
1-
const chat = document.getElementById("chat");
1+
const chat = document.getElementById("chat");
22
const form = document.getElementById("input-form");
33
const input = document.getElementById("user-input");
44

55
let threadId = null;
66

7-
// Openingsbericht bij het laden van de pagina
7+
// ✅ Toegevoegd: bronnummer → URL mapping
8+
const sourceMap = {
9+
4: "https://voorbeeld.nl/bron4.pdf",
10+
6: "https://voorbeeld.nl/bron6.pdf",
11+
11: "https://voorbeeld.nl/bron11.pdf",
12+
14: "https://voorbeeld.nl/bron14.pdf",
13+
16: "https://voorbeeld.nl/bron16.pdf",
14+
17: "https://voorbeeld.nl/bron17.pdf"
15+
};
16+
17+
// ✅ Toegevoegd: functie om 【X†source】 te vervangen door klikbare links
18+
function formatSources(text) {
19+
return text.replace(/(\d+)source/g, (match, number) => {
20+
const url = sourceMap[number];
21+
return url
22+
? `<a href="${url}" target="_blank" class="bronlink">[bron ${number}]</a>`
23+
: `[bron ${number}]`;
24+
});
25+
}
26+
27+
// Welkomstbericht
828
window.onload = () => {
929
const welkomstHTML = `
1030
Welkom bij <strong>Indicatiehulp.ai</strong>!<br>
1131
Ik ben Indi, jouw digitale adviseur voor:<br>
1232
het stellen van de juiste indicatie en het opstellen van een conceptadvies voor de (Evean) zorgexpert.<br><br>
1333
14-
<strong>Het volgende is bijv. mogelijk:</strong><br>
34+
<strong>Het volgende is bijvoorbeeld mogelijk:</strong><br>
1535
- In kaart brengen cliëntsituatie<br>
1636
- Indicatiestelling extramuraal (zorg thuis)<br>
1737
- Indicatiestelling intramuraal (verpleeghuis)<br><br>
@@ -76,10 +96,11 @@ function renderMessage(cssClass, text) {
7696
msg.classList.add("message", cssClass);
7797
chat.appendChild(msg);
7898

79-
// Zet **vetgedrukte** en *cursieve* accenten om
99+
// ✅ Verwerk vet, cursief én bronverwijzingen
80100
let htmlText = text
81-
.replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>") // vet
82-
.replace(/(?<!\*)\*(?!\*)(.*?)\*(?!\*)/g, "<em>$1</em>"); // cursief
101+
.replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>")
102+
.replace(/(?<!\*)\*(?!\*)(.*?)\*(?!\*)/g, "<em>$1</em>");
103+
htmlText = formatSources(htmlText);
83104

84105
const lines = htmlText.split("\n").filter(line => line.trim() !== "");
85106

0 commit comments

Comments
 (0)