-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
349 lines (288 loc) · 15.1 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Nanum+Pen+Script&display=swap" rel="stylesheet">
<meta charset="UTF-8">
<meta name="viewport" ontent="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" />
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Nanum+Pen+Script&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.14.3/xlsx.full.min.js"></script>
<title>Mat-zip</title>
<style>
* { font-family: 'Nanum Pen Script', cursive; }
table {
margin: 0 auto;
text-align: center;
border-collapse: collapse;
border: 1px solid gainsboro;
}
tr {
background: whitesmoke;
}
th, td {
padding: 10px 30px;
}
th {
border-bottom: 1px solid whitesmoke;
}
tbody {
background: whitesmoke;
}
.centered { display: table; margin-left: auto; margin-right: auto; display: inline-block; }
<!-- font & center alignment -->
<style>
* { font-family: 'Nanum Pen Script', cursive; }
.centered { display: table; margin-left: auto; margin-right: auto; }
</style>
<!-- icon & title -->
<link rel="shortcut icon" type="image⁄x-icon" href="burger.png">
<title>Restaurants in order</title>
</head>
<body>
<nav class="navbar navbar-light bg-light">
<div class="container">
<span class="navbar-brand mb-0 h1 centered"><i class="bi bi-card-checklist"></i> Creating my own to-go restaurant list</span>
</div>
</nav>
<div class="centered">
<h2><p style="text-align: center; margin-top: 30px;">방문하고자 하는 지역을 클릭해주세요</p></h2>
<!-- map of Seoul separated by 구 -->
<div id="item">
<img id="img" src="seoul.png" alt="map of Seoul" usemap="#city"/>
<map name="city" id="city">
<area shape="poly" coords="39,145, 125,222, 93,253, 71,230, 38,246, 10,220" alt="강서구" onclick="clicked(this)" href="#">
<area shape="poly" coords="125,222, 195,268, 176,276, 165,303, 146,320, 126,280, 131,253" alt="영등포구" onclick="clicked(this)" href="#">
<area shape="poly" coords="71,230, 93,253, 125,222, 131,253, 126,280, 64,282" alt="양천구" onclick="clicked(this)" href="#">
<area shape="poly" coords="64,282, 126,280, 146,320, 117,320, 85,340, 55,340" alt="구로구" onclick="clicked(this)" href="#">
<area shape="poly" coords="117,320, 146,320, 167,381, 142,395" alt="금천구" onclick="clicked(this)" href="#">
<area shape="poly" coords="176,276, 195,268, 225,290, 236,302, 233,331, 212,329, 203,311, 146,320, 165,303" alt="동작구" onclick="clicked(this)" href="#">
<area shape="poly" coords="146,320, 203,311, 212,329, 233,331, 245,361, 200,395, 167,381, " alt="관악구" onclick="clicked(this)" href="#">
<area shape="poly" coords="225,290, 266,266, 281,313, 305,351, 341,341, 357,368, 323,402, 290,395, 285,357, 260,370, 245,361, 233,331, 236,302" alt="서초구" onclick="clicked(this)" href="#">
<area shape="poly" coords="266,266, 283,255, 324,272, 328,297, 360,310, 385,356, 357,368, 341,341, 305,351, 281,313" alt="강남구" onclick="clicked(this)" href="#">
<area shape="poly" coords="324,272, 352,270, 375,241, 386,271, 405,279, 405,297, 426,305, 385,356, 360,310, 328,297" alt="송파구" onclick="clicked(this)" href="#">
<area shape="poly" coords="375,241, 382,218, 442,191, 448,240, 418,251, 405,279, 386,271" alt="강동구" onclick="clicked(this)" href="#">
<area shape="poly" coords="337,198, 367,196, 370,216, 348,261, 317,258, 330,215" alt="광진구" onclick="clicked(this)" href="#">
<area shape="poly" coords="279,199, 305,198, 330,215, 317,258, 270,249, 266,230" alt="성동구" onclick="clicked(this)" href="#">
<area shape="poly" coords="334,137, 372,126, 386,144, 367,196, 337,198, 331,151" alt="중랑구" onclick="clicked(this)" href="#">
<area shape="poly" coords="285,177, 331,151, 337,198, 330,215, 305,198, 279,199, 279,189" alt="동대문구" onclick="clicked(this)" href="#">
<area shape="poly" coords="317,23, 341,10, 364,26, 361,84, 376,89, 381,111, 372,126, 334,137, 306,112" alt="노원구" onclick="clicked(this)" href="#">
<area shape="poly" coords="272,13, 317,23, 306,112, 266,73, 265,33" alt="도봉구" onclick="clicked(this)" href="#">
<area shape="poly" coords="229,105, 240,102, 268,124, 272,140, 300,137, 306,112, 334,137, 331,151, 285,177, 279,189, 265,187, 252,165, 235,161, 242,149" alt="성북구" onclick="clicked(this)" href="#">
<area shape="poly" coords="253,36, 265,33, 266,73, 306,112, 300,137, 272,140, 268,124, 240,102, 241,68" alt="강북구" onclick="clicked(this)" href="#">
<area shape="poly" coords="214,225, 266,230, 270,249, 240,278, 221,279, 195,254" alt="용산구" onclick="clicked(this)" href="#">
<area shape="poly" coords="219,202, 279,199, 266,230, 214,225, 210,212" alt="중구" onclick="clicked(this)" href="#">
<area shape="poly" coords="133,163, 155,185, 186,213, 210,212, 214,225, 195,254, 100,182" alt="마포구" onclick="clicked(this)" href="#">
<area shape="poly" coords="221,106, 229,105, 242,149, 235,161, 252,165, 265,187, 279,189, 279,199, 219,202, 208,192, 213,170, 205,149, 207,120" alt="종로구" onclick="clicked(this)" href="#">
<area shape="poly" coords="155,185, 205,149, 213,170, 208,192, 219,202, 210,212, 186,213" alt="서대문구" onclick="clicked(this)" href="#">
<area id="blue" shape="poly" coords="160,81, 199,66, 221,85, 221,106, 207,120, 205,149, 155,185, 133,163, 154,156" alt="은평구" onclick="clicked(this)" href="#">
</map>
</div>
<!-- ''를 선택하셨습니다. -->
<h1>
<p style="text-align: center; margin-top: 50px;">'<span class="textCity"></span>'를 선택하셨습니다.</p>
</h1>
</div>
<div class="d-flex">
<div class="container">
<div class="col-md-auto text-center mb-2 mt-2">
<hr>
<input type="file" id="excelFile" onchange="excelExport(event)"/>
<input type="text" id="mykeyword" placeholder="유형을 입력하세요.">
<br>
<hr>
<div id="displayExcelHtml"></div>
</div>
</div>
<div class="flex-grow-1 bg-light rounded-2 p-2 w-50">
<h3>My picks</h3>
<div class="d-flex align-items-center mb-2 mt-2">
<input onkeyup="enterkey();"type="text" class="form-control" id="task-input" placeholder="Which restaurant?">
<button type="button" id="add" class="btn btn-primary ms-1 text-nowrap"><i class="bi bi-plus"></i>
Add</button>
</div>
<div id="todo-list">
<div class="task bg-light p-1 rounded-2 ps-2 d-flex align-items-center">
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<!-- function clicked: change name of 구 & change image of map -->
<script>
function clicked(item) {
var name = $(item).attr('alt');
$("map#city area").each(function() {
if ($(this).attr('alt') === name) {
$(".textCity").text(name);
document.getElementById("img").src = "./img/" + name + ".png";
}
});
$("table > tbody > tr").hide();
var temp = $("table > tbody > tr > td:nth-child(5n+1):contains('" + name + "')");
$(temp).parent().show();
$("#mykeyword").on("keyup", function() {
var value = $(this).val().toLowerCase();
var find = $("table > tbody > tr > td:nth-child(5n+4):contains('" + value + "')");
$(find).parent().show();
$("table > tbody > tr > td:nth-child(5n+1):not(:contains('" + name + "'))").parent().hide();
});
}
let tasks = [];
function loadTasks() {
let lastTasks = localStorage.getItem("tasks");
if (!lastTasks) return;
tasks = JSON.parse(lastTasks);
tasks.forEach(addToList);
}
function saveTasks() {
localStorage.setItem("tasks", JSON.stringify(tasks));
}
function addToList(task) {
let div = document.createElement("div");
div.className = "task bg-light p-1 rounded-2 ps-2 d-flex align-items-center";
let span = document.createElement("span");
span.className = "me-auto";
span.textContent = task.text;
div.appendChild(span);
let buttonRemove = document.createElement("button");
buttonRemove.className = "btn btn-sm btn-danger";
buttonRemove.innerHTML = '<i class="bi bi-x"></i>';
div.appendChild(buttonRemove);
buttonRemove.addEventListener("click", () => {
div.remove();
tasks = tasks.filter(t => t !== task);
saveTasks();
});
let list = document.querySelector("#todo-list");
list.appendChild(div);
}
window.addEventListener("load", () => {
loadTasks();
});
let button = document.querySelector("#add");
button.addEventListener("click", () => {
// 1. Read the text in #task-input.
let input = document.querySelector("#task-input");
let text = input.value;
if (!text.length) return;
// 2. Create a new Task object.
let task = {
text: text,
};
// 3. Append the new Task object to tasks
tasks.push(task);
saveTasks();
// 4. Create a new task item and attach it to #todo-list.
addToList(task);
// 5. Clear #task-input.
input.value = "";
});
function enterkey(){
if(window.event.keyCode==13){
// 1. Read the text in #task-input.
let input = document.querySelector("#task-input");
let text = input.value;
if (!text.length) return;
// 2. Create a new Task object.
let task = {
text: text,
};
// 3. Append the new Task object to tasks
tasks.push(task);
saveTasks();
// 4. Create a new task item and attach it to #todo-list.
addToList(task);
// 5. Clear #task-input.
input.value = "";
}
};
$(document).ready(function() {
$("#mykeyword").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("table > tbody > tr").hide();
var temp = $("table > tbody > tr > td:nth-child(5n+4):contains('" + value + "')");
$(temp).parent().show();
});
});
$.ajax({
url: 'csv_data.csv',
dataType: 'text',
}).done(Table);
function excelExport(event){
excelExportCommon(event, handleExcelDataAll);
}
function excelExportCommon(event, callback){
var input = event.target;
var reader = new FileReader();
reader.onload = function() {
var fileData = reader.result;
var wb = XLSX.read(fileData, {type : 'binary'});
var sheetNameList = wb.SheetNames;
var firstSheetName = sheetNameList[0];
var firstSheet = wb.Sheets[firstSheetName];
callback(firstSheet);
};
reader.readAsBinaryString(input.files[0]);
}
function handleExcelDataAll(sheet){
handleExcelDataHtml(sheet);
}
function handleExcelDataHtml(sheet){
$("#displayExcelHtml").html(XLSX.utils.sheet_to_html(sheet));
}
function get_header_row(sheet) {
var headers = [];
var range = XLSX.utils.decode_range(sheet['!ref']);
var C, R = range.s.r;
for(C = range.s.c; C <= range.e.c; ++C) {
var cell = sheet[XLSX.utils.encode_cell({c:C, r:R})]
var hdr = "UNKNOWN " + C;
if(cell && cell.t) hdr = XLSX.utils.format_cell(cell);
headers.push(hdr);
}
return headers;
}
function Table(data) {
var allRows = data.split(/\r?\n|\r/);
var table = document.createElement("table");
for (var singleRow = 0; singleRow < allRows.length; singleRow++) {
if (singleRow === 0) {
var thead = document.createElement("thead");
var tr = document.createElement('tr');
table.appendChild(thead);
thead.appendChild(tr);
} else {
var tr = document.createElement('tr');
thead.appendChild(tr);
}
var rowCells = allRows[singleRow].split(',');
for (var rowCell = 0; rowCell < rowCells.length; rowCell++) {
if (singleRow === 0) {
var th = document.createElement("th");
th.innerHTML = rowCells[rowCell];
tr.appendChild(th);
} else {
var td = document.createElement("td");
td.innerHTML = rowCells[rowCell];
tr.appendChild(td);
}
}
if (singleRow === 0) {
var tbody = document.createElement("tbody");
table.appendChild(tbody);
}
}
document.body.appendChild(table);
}
</script>
</body>
</html>