-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split JS functions, change the JSON content type to x-www-form-urlenc…
…oded Split JS functions, change the JSON content type to x-www-form-urlenc…
- Loading branch information
Showing
8 changed files
with
256 additions
and
243 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
wp-content/plugins/chris-buys-blocks/build/lead-form/index.js.map
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
wp-content/plugins/chris-buys-blocks/build/lead-form/view.asset.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array(), 'version' => 'b0c5e04d7738918af100'); | ||
<?php return array('dependencies' => array(), 'version' => 'fa24eef6983052c7667c'); |
247 changes: 131 additions & 116 deletions
247
wp-content/plugins/chris-buys-blocks/build/lead-form/view.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
wp-content/plugins/chris-buys-blocks/build/lead-form/view.js.map
Large diffs are not rendered by default.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
wp-content/plugins/chris-buys-blocks/src/lead-form/modules/form_helpers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
export function populateUtms(form, formData) { | ||
let utms = { | ||
'utm_source': 'utm', | ||
'utm_term': 'utm', | ||
'utm_campaign': 'utm', | ||
'utm_medium': 'utm', | ||
'utm_content': 'utm', | ||
'device': 'utm', | ||
'gclid': 'utm', | ||
'fbclid': 'utm', | ||
'msclkid': 'utm', | ||
'page_url': ()=>{ | ||
return document.location.href | ||
}, | ||
'lead_source': ()=>{ | ||
return localStorage.getItem('Initial_Lead_Source') || '' | ||
}, | ||
'timestamp': ()=>{ | ||
return (new Date()).getTime() | ||
}, | ||
'client_id': ()=>{ | ||
return '??' | ||
}, | ||
'session_id': ()=>{ | ||
return '??' | ||
}, | ||
'form_name': form.name, | ||
} | ||
let getParams = new URLSearchParams(window.location.search) | ||
|
||
Object.keys(utms).forEach(function (utmName) { | ||
if(utms[utmName] === 'get'){ | ||
if(getParams.get(utmName)) { | ||
formData.set(utmName, getParams.get(utmName)) | ||
} | ||
} else if(utms[utmName] === 'utm'){ | ||
let utmFromQuery= getParams.get(utmName); | ||
let utmFromSession = sessionStorage.getItem(formConfig.storagePrefix + utmName); | ||
|
||
if(utmFromQuery) { | ||
formData.set(utmName, utmFromQuery) | ||
} else if(utmFromSession){ | ||
formData.set(utmName, utmFromSession) | ||
} | ||
} else if(typeof utms[utmName] === 'function'){ | ||
formData.set(utmName, utms[utmName]()) | ||
} else { | ||
formData.set(utmName, utms[utmName]) | ||
} | ||
}) | ||
|
||
return formData; | ||
} | ||
export function getRedirectParams(formData, queries) { | ||
let query = {} | ||
|
||
queries.forEach(function (fieldData) { | ||
let inputName = fieldData.field | ||
let propName = fieldData.key | ||
|
||
if(inputName === 'country'){ | ||
query[propName] = 'United States' | ||
} else if(formData.get(inputName)) { | ||
query[propName] = formData.get(inputName) | ||
} | ||
}) | ||
|
||
return new URLSearchParams(query).toString() | ||
} |
Oops, something went wrong.