function createReplayLabel() {
let li = document.createElement("li");
li.classList.add("hs-form-list-label");
let span = document.createElement("span");
span.textContent = "Watch back";
span.setAttribute("style", "font-weight:500;display:inline-block;margin-bottom:8px;");
li.appendChild(span);
return li;
}
function createListItem(index, value, text, startTime, location, broadcastId, broadcastTitle, replayUrl, adobewebinar, webinarUrl, date, dateDF, multiple, today) {
let li = document.createElement("li");
li.classList.add("hs-form-radio");
let label = document.createElement("label");
label.setAttribute("for", `label_${index}`);
label.setAttribute("style", "align-items: center;");
label.classList.add("hs-form-radio-display");
let input = document.createElement("input");
input.setAttribute("type", "checkbox");
if (!multiple) {
input.setAttribute("type", "radio");
}
if (!multiple || index === 0) {
input.setAttribute("checked", true);
}
input.setAttribute("id", `label_${index}`);
input.setAttribute("name", "marketinglist_number_webinar");
input.setAttribute("value", value);
input.setAttribute("data-time", startTime);
input.setAttribute("data-location", location);
input.setAttribute("data-broadcastid", broadcastId);
input.setAttribute("data-broadcasttitle", broadcastTitle);
input.setAttribute("data-replayurl", replayUrl);
input.setAttribute("data-adobewebinar", adobewebinar);
input.setAttribute("data-webinarurl", webinarUrl);
input.setAttribute("data-date", date);
input.setAttribute("data-datedf", dateDF);
input.classList.add("hs-input");
let span = document.createElement("span");
span.textContent = text;
if (Boolean(+today)) {
span.setAttribute("style", "display: flex;align-items: center;gap: 12px;height: 12px;overflow:visible");
const tag = document.createElement("span");
tag.className = "p-tag p-component p-tag-success mr-1";
tag.style.backgroundColor = "#20b065";
const tagValue = document.createElement("span");
tagValue.className = "p-tag-value";
tagValue.textContent = "today";
tag.appendChild(tagValue);
span.append(" ", tag);
}
label.appendChild(input);
label.appendChild(span);
li.appendChild(label);
return li;
}
hbspt.forms.create({
region: "eu1",
portalId: "143438306",
formId: "9ddb6d85-c9c6-4ff8-8dc8-697628e584b4",
onFormSubmitted: () => {
trackForm();
let topPos = $(".hs-form-wrapper").offset().top - 180;
$('html, body').scrollTop(topPos);
},
onBeforeFormSubmit: function($form) {
let chosenInputs = Array.from($('input[name="marketinglist_number_webinar"]:checked'));
$('input[name="marketinglist_number_webinar"]').remove();
let formattedData = chosenInputs.reduce((ac,cu) => {
const data = { ...cu.dataset };
const keys = Object.keys(data);
keys.forEach((key) => (ac[key] = (!ac[key]) ? [data[key]] : [...ac[key], data[key]]));
return ac;
}, {});
let selectedMarketingListNumbers = chosenInputs.map((item) => item.value).join(',');
$('input[name="marketing_list_number"]').val(selectedMarketingListNumbers);
$('input[name="start_time"]').val(formattedData?.time?.join(','));
$('input[name="marketinglist_location"]').val(formattedData?.location?.join(','));
$('input[name="adobe_webinar"]').val(formattedData?.adobewebinar?.[0]);
$('input[name="marketinglist_date"]').val(formattedData?.date?.join(','));
$('input[name="marketinglist_date_df"]').val(formattedData?.datedf?.join(','));
if ((formattedData?.broadcastid || []).every(value => (typeof +value === 'number' && Boolean(value)))) {
$('input[name="broadcast_id_list"]').val(formattedData?.broadcastid?.join(','));
$('input[name="broadcast_title"]').val(formattedData?.broadcasttitle?.join(','));
$('input[name="webinar_url"]').val(formattedData?.webinarurl?.join(','));
$('input[name="webinargeek_broadcast_replay_urls"]').val(formattedData?.replayurl?.join(','));
} else {
$('input[name="download_link"]').val('U4zuuNilT4w');
$('input[name="broadcast_id_list"]').val('x');
$('input[name="broadcast_title"]').val('An introduction to Autodesk Construction Cloud');
$('input[name="webinar_url"]').val('x');
$('input[name="webinargeek_broadcast_replay_urls"]').val('x');
}
},
onFormReady: function($form, ctx) {
$('input[name="bu"]').val('AEC');
$('input[name="page_url"]').val('https://www.cadac.com/nl-en/event-archive/an-introduction-to-autodesk-construction-cloud/');
$('input[name="pagename"]').val(`An introduction to Autodesk Construction Cloud`);
$('input[name="campaign_description"]').val(`An introduction to Autodesk Construction Cloud`);
$('input[name="campaign_code"]').val('CMP-02602-R3R2M');
$('input[name="ddlcountry"]').val('us');
$('input[name="weblead_type"]').val('Webinar registration');
let marketinglistElm = document.querySelector('.hs_marketinglist_number_webinar .inputs-list');
marketinglistElm.replaceChildren();
marketinglistElm.appendChild(createReplayLabel());
marketinglistElm.appendChild(createListItem(0, "ML156223","15 September 2021 11:00 (GMT+1)", "11:00 (GMT+1)", "", "", "", "", "False", "", "15 September 2021", "09/15/2021", 0, 0));
}
});