simplified appointment link javascript

This commit is contained in:
2026-02-09 21:43:29 -05:00
parent 8944e92ffc
commit a6751d3f41
3 changed files with 9 additions and 18 deletions

View File

@@ -1,31 +1,22 @@
function updateLink() {
console.log("updateLink called");
const linkElement = document.getElementById("appointment_link");
const regex = /((?:<br\/>|%3Cbr\/?%3E))([\s\S]*?)(&dates)/gi;
linkElement.href = linkElement.href.replace(regex, `$1${getSelectedDocs()}$3`);
}
function getSelectedDocs() {
const invoices = document.querySelectorAll('.invoice-checkbox');
const estimates = document.querySelectorAll('.estimate-checkbox');
const appointent_extras = document.querySelectorAll('.appointment');
let output = '';
for (const i of invoices) {
if (i.checked) {
console.log(i.value);
console.log(i.dataset.doc);
output += `%0A<a href="${window.location.origin}/invoices/${i.dataset.id}">Invoice:%20${i.dataset.doc}</a>%0A`;
}
}
for (const e of estimates) {
if (e.checked) {
console.log(e.value);
console.log(e.dataset.doc);
output += `%0A<a href="${window.location.origin}/estimates/${e.value}">Estimate:%20${e.dataset.doc}</a>%0A`;
for (const item of appointent_extras) {
if (item.checked) {
console.log(`Checked item: ${item.dataset.text} with URL: ${item.dataset.url}`);
output += `%0A`+ encodeURIComponent(`<a href="${window.location.origin}${item.dataset.url}">${item.dataset.text}</a>`) +`%0A`;
}
}
// You can return the array or use it as needed
return output;
}