-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
236 lines (167 loc) · 8.84 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<!DOCTYPE html>
<html dir="rtl" lang="ar">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/png" href="algeria.png" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row justify-content-md-center">
<div class="col-12">
<header class="blog-header py-3">
<div class="row flex-nowrap justify-content-between align-items-center">
<div class="col text-center">
<a class="blog-header-logo text-dark" target="_blank" href="map.html">توزع الولايات علي الخريطة</a>
</div>
</div>
</header>
<form class="row g-3 mt-5">
<div class="col-12">
<label for="sel_state" class="form-label"> ولاية </label>
<select id="sel_state" class="form-select">
<option selected> إختر ولاية... </option>
</select>
</div>
<div class="col-12">
<label for="sel_dairas" class="form-label"> دائرة </label>
<select id="sel_dairas" class="form-select">
<option selected> إختر دائرة ... </option>
</select>
</div>
<div class="col-12">
<label for="sel_baladiyas" class="form-label"> بلدية </label>
<select id="sel_baladiyas" class="form-select">
<option selected> إختر بلدية ... </option>
</select>
</div>
<div class="col-12 d-grid gap-2 text-center">
<button type="button" id="submit" class="btn btn-outline-success"> أرسل </button>
</div>
</form>
<button style="display:none;" type="button" onclick="getOption()" class="btn btn-primary mt-5"> أرسل </button>
<p>
<ul class="list-group">
<li class="output_state list-group-item list-group-item-secondary"></li>
<li class="list-group-item list-group-item-secondary"><a target="_blank" class="url_state" href=""> تصفح علي الخريطة </a></li>
<li class="output_dairas list-group-item list-group-item-warning"></li>
<li class="list-group-item list-group-item-warning"><a target="_blank" class="url_dairas" href=""> تصفح علي الخريطة </a></li>
<li class="output_baladiyas list-group-item list-group-item-success"></li>
<li class="list-group-item list-group-item-success"><a target="_blank" class="url_baladiyas" href=""> تصفح علي الخريطة </a></li>
</ul>
</p>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script type='text/javascript'>
$(document).ready(function(){
// AJAX request
$.ajax({
url:'https://raw.githubusercontent.com/zahsadz/Algerian-Administrative-Division-with-latitude-and-longitude/main/json/state.json',
method: 'GET',
data: {},
dataType: 'json',
success: function(response){
// Add options
$.each(response,function(index,data){
$('#sel_state').append('<option data-latitude="'+data['latitude']+'" data-longitude="'+data['longitude']+'" value="'+data['id']+'">'+data['arabic']+'</option>');
});
}
});
// dairas change
$('#sel_state').change(function(){
var state = $(this).val();
// AJAX request
$.ajax({
url:'https://raw.githubusercontent.com/zahsadz/Algerian-Administrative-Division-with-latitude-and-longitude/main/json/dairas.json',
method: 'GET',
data: {},
dataType: 'json',
success: function(response){
// Remove options
$('#sel_dairas').find('option').not(':first').remove();
$('#sel_dairas').fadeOut(500).fadeIn(500);
$('#sel_dairas').css("background-color", "#FFFF9C");
// Add options
$.each(response,function(index,data){
if(data['id_state'] == state)
$('#sel_dairas').append('<option data-latitude="'+data['latitude']+'" data-longitude="'+data['longitude']+'" value="'+data['id']+'">'+data['arabic']+'</option>');
});
}
});
});
// baladiyas change
$('#sel_dairas').change(function(){
var daira = $(this).val();
// AJAX request
$.ajax({
url:'https://raw.githubusercontent.com/zahsadz/Algerian-Administrative-Division-with-latitude-and-longitude/main/json/baladiyas.json',
method: 'GET',
data: {},
dataType: 'json',
success: function(response){
// Remove options
$('#sel_baladiyas').find('option').not(':first').remove();
$('#sel_baladiyas').fadeOut(500).fadeIn(500);
$('#sel_baladiyas').css("background-color", "#cbf9c8");
// Add options
$.each(response,function(index,data){
if(data['id_daira'] == daira)
// console.log(data['arabic']);
$('#sel_baladiyas').append('<option data-latitude="'+data['latitude']+'" data-longitude="'+data['longitude']+'" value="'+data['id']+'">'+data['arabic']+'</option>');
});
}
});
});
});
$(".list-group").hide();
function getOption() {
$(".list-group").show();
selectElement = document.querySelector('#sel_baladiyas');
outputid = selectElement.value;
outputtext = selectElement.options[selectElement.selectedIndex].text;
document.querySelector('.output_baladiyas').textContent = ''+ outputtext +'';
selectdairas = document.querySelector('#sel_dairas');
outputiddairas = selectdairas.value;
outputtextdairas = selectdairas.options[selectdairas.selectedIndex].text;
document.querySelector('.output_dairas').textContent = ''+ outputtextdairas +'';
selectstate = document.querySelector('#sel_state');
outputidstate = selectstate.value;
outputtextstate = selectstate.options[selectstate.selectedIndex].text;
document.querySelector('.output_state').textContent = ''+ outputtextstate +'';
}
$("#submit").on('click', function(){
$(".list-group").show();
$(":selected","form").each(function(i,o){
//console.log(i);
//console.log(o);
//$('.output_state').append($(o).attr('data-latitude'));
});
var state =$("#sel_state option:selected").text();
var latitude_state = $("#sel_state option:selected").data("latitude");
var longitude_state = $("#sel_state option:selected").data("longitude");
var url_state = "location.html?lat=" + latitude_state + "&lng=" + longitude_state + "";
var dairas =$("#sel_dairas option:selected").text();
var latitude_dairas = $("#sel_dairas option:selected").data("latitude");
var longitude_dairas = $("#sel_dairas option:selected").data("longitude");
var url_dairas = "location.html?lat=" + latitude_dairas + "&lng=" + longitude_dairas + "";
var baladiyas =$("#sel_baladiyas option:selected").text();
var latitude = $("#sel_baladiyas option:selected").data("latitude");
var longitude = $("#sel_baladiyas option:selected").data("longitude");
var url = "location.html?lat=" + latitude + "&lng=" + longitude + "";
console.log($("#sel_baladiyas option:selected").text());
console.log($("#sel_baladiyas option:selected").data("latitude"));
console.log($("#sel_baladiyas option:selected").attr('data-longitude'));
$('.output_state').html(state);
$('.url_state').attr('href',''+url_state);
$('.output_dairas').html(dairas);
$('.url_dairas').attr('href',''+url_dairas);
$('.output_baladiyas').html(baladiyas);
$('.url_baladiyas').attr('href',''+url);
});
</script>
</body>
</html>