Skip to content

Instantly share code, notes, and snippets.

@puneet-sutar
Last active August 15, 2020 17:11
Show Gist options
  • Save puneet-sutar/c4152857855abfa31e828fb5ce8cd550 to your computer and use it in GitHub Desktop.
Save puneet-sutar/c4152857855abfa31e828fb5ce8cd550 to your computer and use it in GitHub Desktop.
replace YOUR_API_KEY with your actual api key and then open the html file in your browser
<!-- Replace YOUR_API_KEY with your api key -->
<html>
<head>
<script src="https://unpkg.com/@juniperlabs/juniper-labs-search/dist/index.var.js"></script>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/@juniperlabs/juniper-labs-search/dist/index.css" />
<style>
input { width: 300px; height: 30px}
label { width: 300px; font-weight: bold; text-align: right; padding-right: 10px }
.form-group {
display: flex;
padding: 10px;
}
</style>
<script type="text/javascript">
API_KEY = "REPLACE_WITH_YOUR_API_KEY"
if (API_KEY == "REPLACE_WITH_YOUR_API_KEY") {
alert("Replace API_KEY with your api key")
}
document.addEventListener("DOMContentLoaded", () => {
const onSelect = (detailsResponse) => {
const {
business_name,
locations: [{
address_line_1,
address_line_2,
city,
state,
zip
}] } = detailsResponse
document.getElementById("business_name").value = business_name
document.getElementById("address_line_1").value = address_line_1
document.getElementById("address_line_2").value = address_line_2
document.getElementById("city").value = city
document.getElementById("state").value = state
document.getElementById("zip").value = zip
}
new JuniperLabsSearch.BusinessPrefill.AutoCompleteComponent(API_KEY, "https://prefill.juniperlabs-services-dev.com/v0.1").initializeComponent(
document.getElementById("business_name"),
{
onSelect,
registry_state: "CO"
}
)
})
</script>
<title>Sample Usage of Juniper Laps</title>
</head>
<body>
<h1>Business Prefill</h1>
<form>
<div class="form-group">
<label>Registered business name</label>
<input type="text" id="business_name" />
</div>
<div class="form-group">
<label>Registered business address</label>
<input type="text" id="address_line_1" />
</div>
<div class="form-group">
<label>Business address line 2</label>
<input type="text" id="address_line_2" />
</div>
<div class="form-group">
<label>City</label>
<input type="text" id="city" />
</div>
<div class="form-group">
<label>State</label>
<input type="text" id="state" />
</div>
<div class="form-group">
<label>zip</label>
<input type="text" id="zip" />
</div>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment