-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
38 lines (38 loc) · 1.74 KB
/
index.html
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
<html>
<head>
<title>Open Addresses UK's address entry playground</title>
<script src="bower_components/underscore/underscore-min.js"></script>
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/async/lib/async.js"></script>
<script src="index.js"></script>
</head>
<body>
<h1>This is Open Addresses UK's address entry playground</h1>
<input type="text" id="searchBox" style="width: 600px;" onkeyup="searchTextBox()">
<div id="results"></div>
<script>
var latestSetTimeout = null,
latestSearch = null;
var searchTextBox = function () {
clearTimeout(latestSetTimeout);
if ($("#searchBox").val().trim() !== latestSearch) {
latestSearch = $("#searchBox").val().trim();
latestSetTimeout = setTimeout(function () {
searchCombinations(latestSearch, function (err, data) {
console.log(data);
$("#results").html("<ul>\n" + data.map(function (x) {
return " <li>"
+ (x.pao ? x.pao : "")
+ (x.sao ? x.sao : "")
+ (x.street ? x.street : "")
+ (x.locality ? x.locality : "")
+ (x.town ? x.town : "")
+ (x.postcode ? x.postcode : "");
}).join("\n") + "</ul>\n");
});
}, 1000);
}
};
</script>
</body>
</html>