[F.END] Changed zerocalcareTrigger to accept target div id as argument

This commit is contained in:
giuliof 2023-01-16 21:43:49 +01:00
parent c99ffd7b16
commit 94bd891942
1 changed files with 5 additions and 5 deletions

View File

@ -1,7 +1,7 @@
"use strict" "use strict"
function zerocalcareDisplay(xhr) { function zerocalcareDisplay(xhr, target_id) {
let zerocalcareOutput = document.getElementById('zerocalcareOutput'); let zerocalcareOutput = document.getElementById(target_id);
if (xhr.readyState == 4 && xhr.status == 200) { if (xhr.readyState == 4 && xhr.status == 200) {
@ -141,12 +141,12 @@ function zerocalcareDisplay(xhr) {
} }
} }
function zerocalcareTrigger(url) { function zerocalcareTrigger(url, target_id="zerocalcareOutput") {
if (typeof url !== "string") if (typeof url !== "string")
return return
let xhr = new XMLHttpRequest(); let xhr = new XMLHttpRequest();
xhr.onload = () => { zerocalcareDisplay(xhr) }; xhr.onload = () => { zerocalcareDisplay(xhr, target_id) };
xhr.open('GET', url, true); xhr.open('GET', url, true);
xhr.send(null); xhr.send(null);
} }