Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

udpdate render #83

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions pages/common/naf/display-item.htm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="NAF 2008 - consultation">
<title>NAF 2008 - consultation</title>
<link href="../commun.css" rel="stylesheet" type="text/css"/>
<link href="../commun.css" rel="stylesheet" type="text/css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha384-vtXRMe3mGCbOeY7l30aIg8H9p3GdeSe4IFlP6G8JMa7o7lXvnz3GFKzPxzJdPfGK" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.1.6/purify.min.js" integrity="sha384-+VfUPEb0PdtChMwmBcBmykRMDd+v6D/oFmB3rZM/puCMDYcIvF968OimRh4KQY9a" crossorigin="anonymous"></script>
<script>
Expand Down Expand Up @@ -152,23 +152,26 @@
}

async function getNote(uri, tag) {
const query = `
SELECT ?text WHERE {
<${encodeHTML(uri)}> <http://eurovoc.europa.eu/schema#noteLiteral> ?text
}
`;
try {
const data = await fetchData(query);
if (data.results.bindings.length > 0) {
const noteText = escapeHtml(data.results.bindings[0].text.value.replace(regex, replacement));
const tagElement = document.getElementById(tag);
tagElement.innerHTML += DOMPurify.sanitize(noteText.replace(/\\\$/g, "<br />"));
tagElement.classList.add(tag);
}
} catch (error) {
console.error('Error in getNote:', error);
}
const query = `
SELECT ?text WHERE {
<${encodeHTML(uri)}> <http://eurovoc.europa.eu/schema#noteLiteral> ?text
}
`;
try {
const data = await fetchData(query);
if (data.results.bindings.length > 0) {
let noteText = data.results.bindings[0].text.value;
// Remplacer toutes les occurrences de "http://bauhaus/" par "http://id.insee.fr/" dans le texte
noteText = noteText.replace(/http:\/\/bauhaus\//g, 'http://id.insee.fr/');
// Sanitize and update the HTML content
noteText = DOMPurify.sanitize(noteText, { ADD_ATTR: ['target'] });
document.getElementById(tag).innerHTML += noteText.replace(/\\\$/g, "<br />");
document.getElementById(tag).classList.add(tag);
}
} catch (error) {
console.error('Error in getNote:', error);
}
}

function getURLParameter(name) {
const result = new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search);
Expand Down Expand Up @@ -272,7 +275,7 @@
<body>
<div id="fil-ariane"></div>
<h1 id="label" class="item"></h1>
<br/>
<br>
<div id="notes">
<div id="note-generale"></div>
<div id="contenu-central"></div>
Expand Down