-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
159 lines (138 loc) · 5.47 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
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BjLocationData Demo </title>
<style>
/* General styles for the widget container */
#locationDataBJ-widget {
font-family: Arial, sans-serif;
max-width: 600px;
margin: auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
/* Styles for search container */
.search-container {
margin-bottom: 20px;
}
.search-container input[type="text"] {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
.search-results-container {
border-top: 1px solid #ccc;
padding-top: 10px;
}
/* Styles for select elements in the form */
select {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
background-color: white;
}
/* Style for individual containers */
.department-container,
.town-container,
.district-container,
.neighborhood-container {
margin-bottom: 10px;
}
/* Optional style , just for this page */
footer {
text-align: center;
margin-top: 50px;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: #f1f1f1;
color: #333;
padding: 10px;
}
footer a {
color: #333;
}
.text-center {
text-align: center;
}
/* Highlight the JSON outputted in the state element */
#state {
font-family: 'Courier New', monospace;
white-space: 'break-space';
/* Preserves the JSON formatting */
background-color: #f5f5f5;
/* Light grey background for contrast */
padding: 10px;
border-radius: 4px;
border: 1px solid #ddd;
overflow-x: auto;
/* Allows horizontal scrolling if needed */
color: #333;
/* Default text color */
}
</style>
</head>
<body>
<h1 class="text-center">BjLocationData, javascript library</h1>
<p class="text-center">Simple javascript library to get location data of Benin Republic</p>
<p class="text-center">Please see the source code this page to see more other option, like searching for location, etc.</p>
<div id="bj-location-data-holder" class="bj-location-data-holder">Here</div>
<div id="state" class="text-center"></div>
<footer>
<p>Developed with ❤️ by <a href="https://dah-kenangnon.com" target="_blank">Dah Kenangnon</a></p>
</footer>
<script src="./dist/bundle.js"></script>
<!-- Now initialize the script and start using it-->
<script>
let locationData = {
department: null,
town: null,
district: null,
neighborhood: null,
};
const stateDiv = document.getElementById('state');
stateDiv.innerHTML = JSON.stringify(locationData);
BjLocationData.init({
// useSearch: true,
holderQuerySelector: '#bj-location-data-holder',
// departmentSelectLabel: 'Départment',
// townSelectLabel: 'Sélectionner une commune',
// districtSelectLabel: 'Sélectionner un arrondissement',
// neighborhoodSelectLabel: 'Sélectionner un quartier',
useHierarchy: true,
searchPlaceholder: 'Rechercher une localité',
searchNoResultsText: 'Aucun résultat trouvé',
useDefaultSelect: true,
level: ['town', 'neighborhood', 'district', 'department',],
onChanges: (value) => {
console.log("onChanges ", value)
},
onNeighborhoodChange: (value) => {
locationData.neighborhood = value;
stateDiv.innerHTML = JSON.stringify(locationData);
},
onDistrictChange: (value) => {
locationData.district = value;
stateDiv.innerHTML = JSON.stringify(locationData);
},
onTownChange: (value) => {
locationData.town = value;
stateDiv.innerHTML = JSON.stringify(locationData);
},
onDepartmentChange: (value) => {
locationData.department = value;
stateDiv.innerHTML = JSON.stringify(locationData);
},
});
</script>
</body>
</html>