if (false) {
jQuery('#ew_subform_6362a5e5454a6 input').each((i, input) => {
switch (input.type) {
case 'email':
if (EW.getItem(input.name))
input.value = EW.getItem(input.name).toString().replace(' ', '+');
break;
case 'text':
case 'date':
case 'datetime-local':
case 'month':
case 'number':
case 'range':
case 'tel':
case 'time':
case 'url':
case 'week':
input.value =EW.getItem(input.name);
console.log('name', input.name, 'value', EW.getItem(input.name));
break;
}
});
}
if (false) {
jQuery('#ew_subform_6362a5e5454a6 input.email').remove();
if (EW.getItem('contactId'))
jQuery('#ew_subform_6362a5e5454a6').append('');
else if (EW.getItem('email'))
jQuery('#ew_subform_6362a5e5454a6').append('');
}
if(typeof submit_onchange === 'undefined'){ var submit_onchange = []; }
if (''.length) {
submit_onchange = ''.split(',');
}
if (submit_onchange.length > 0) {
jQuery("input.submit").hide();
}
submit_onchange.forEach(name => {
name = name.substr(3);
jQuery("#ew_subform_6362a5e5454a6 input[name='" + name + "']").parent().addClass('input-submit');
jQuery("#ew_subform_6362a5e5454a6 input[name='" + name + "']").change((e) => {
//jQuery(e.target).next().text('Processing...');
jQuery("#ew_subform_6362a5e5454a6").submit();
});
});
jQuery("#ew_subform_6362a5e5454a6").on("submit", function(event) {
event.preventDefault();
let success = '/confirm-subscription/';
let error = '/error/';
if (false)
window.open(success);
let data = {
userId: '768f2cd6fe89718c868b62733f2a377d'
};
let location_override = jQuery("#ew_subform_6362a5e5454a6").attr('location-override') || '';
let email = jQuery("#ew_subform_6362a5e5454a6 input.email").val();
let contactId = jQuery("#ew_subform_6362a5e5454a6 input.contactId").val();
if (!false) {
if (!EW.isEmail(email)) {
alert("Invalid email");
return false;
}
// blow out contact id since it was just overrided by email
EW.removeItem('contactId');
}
if (email) data.email = email;
if (contactId) data.contactId = contactId;
let url = decodeURIComponent(window.location.search.substring(1)),
urlParams = url.split('&'),
urlParam,
i;
for (i = 0; i < urlParams.length; i++) { urlParam = urlParams[i].split('='); data[urlParam[0]] = urlParam[1]; } jQuery('#ew_subform_6362a5e5454a6 *').filter(':input').each(function(){ if (this.type === 'radio' || this.type === 'checkbox') { if (jQuery(this).is(':checked')) { data[this.name] = jQuery(this).val(); } } else data[this.name] = jQuery(this).val(); }); var custom_parameters = ''.split('|'); custom_parameters.forEach(c => {
if (!c) return;
let v = EW.getItem(c);
if (v)
data[c] = EW.getItem(c);
});
data.utm_campaign = EW.getItem("utm_campaign") || '';
data.utm_content = EW.getItem("utm_content") || '';
data.utm_medium = EW.getItem("utm_medium") || '';
data.placementId = 'subscription-form';
data.utm_term = EW.getItem("utm_term") || '';
data.sourceId = EW.getItem("utm_source") || '' || window.location.hostname;
data.workflowId = '';
data.utm_placement = data.placementId;
data.utm_source = data.sourceId;
var protected = ''.split(',');
Object.keys(data).forEach(key => {
success = success.replace('{' + key + '}', encodeURIComponent(data[key]));
error = error.replace('{' + key + '}', encodeURIComponent(data[key]));
location_override = location_override.replace('{' + key + '}', encodeURIComponent(data[key]));
if (key && data[key] && !protected.some((p) => {return p.substring(3) === key;}))
EW.setItem(key, data[key]);
});
Object.keys(data).forEach((k) => {
if (!data[k])
delete data[k];
})
let existingSubmitText = jQuery("#ew_subform_6362a5e5454a6 input.submit").val();
jQuery("#ew_subform_6362a5e5454a6 input.submit")
.prop("disabled", true)
.val("Processing...");
jQuery.ajax({
type: "POST",
url: jQuery(this).attr("action"),
data: data
}).done(function(response) {
EW.setRoles(EW.Roles.Subscriber);
console.log('success :)', response);
jQuery("#ew_subform_6362a5e5454a6 input.submit").val(existingSubmitText);
if (!false)
window.location.href = location_override || success;
return;
}).fail(function(response) {
console.log("Subscription failure: ", response);
window.location.href = location_override || error;
});
});
if(typeof role === 'undefined'){ var role = ''; }
role = false;
if (role && EW.hasRole(role, '', false)) {
jQuery('._aHtml').css('display', '');
jQuery('._pHtml').css('display', 'none');
}