1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
<!doctype html>
<html lang="pt-BR">
<head>
<meta charset="utf-8" />
<title>checkout fixture</title>
</head>
<body>
<form id="checkout">
<label for="cep">CEP</label>
<input id="cep" name="cep" autocomplete="postal-code" />
<label for="rua">Endereço</label>
<input id="rua" name="rua" />
<label for="numero">Número</label>
<input id="numero" name="numero" />
<label for="bairro">Bairro</label>
<input id="bairro" name="bairro" />
<label for="cidade">Cidade</label>
<input id="cidade" name="cidade" />
<label for="uf">Estado</label>
<select id="uf" name="uf">
<option value="">Selecione</option>
<option value="RJ">Rio de Janeiro</option>
<option value="SP">São Paulo</option>
</select>
</form>
<script src="/cepis-autofill.js"></script>
<script>
window.__events = [];
window.__attach = function (options) {
window.__handle = window.CepisAutofill.attach(
Object.assign(
{
cep: "#cep",
logradouro: "#rua",
bairro: "#bairro",
localidade: "#cidade",
uf: "#uf",
numero: "#numero",
debounceMs: 50,
onResult: function (address) {
window.__events.push("result:" + address.cep);
},
onError: function (error) {
window.__events.push("error:" + error.code);
window.__error = {
code: error.code,
message: error.message,
faixa: error.faixa,
};
},
onStatus: function (state) {
window.__events.push("status:" + state);
},
},
options,
),
);
};
</script>
</body>
</html>
|