Spaces:
Running
Running
Adds new restaurants and displays bonus options
Browse files- index.html +27 -1
- restaurants.json +9 -3
- script.js +24 -23
index.html
CHANGED
@@ -20,14 +20,36 @@
|
|
20 |
padding: 20px;
|
21 |
border-radius: 8px;
|
22 |
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
|
|
|
|
23 |
}
|
24 |
-
h1 {
|
25 |
color: #333;
|
|
|
26 |
}
|
27 |
.restaurant {
|
28 |
font-size: 1.2em;
|
29 |
margin: 10px 0;
|
30 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
</style>
|
32 |
</head>
|
33 |
<body>
|
@@ -35,6 +57,10 @@
|
|
35 |
<h1>Today's Restaurant Suggestions</h1>
|
36 |
<p id="currentDate"></p>
|
37 |
<div id="restaurants"></div>
|
|
|
|
|
|
|
|
|
38 |
</div>
|
39 |
<script src="script.js"></script>
|
40 |
</body>
|
|
|
20 |
padding: 20px;
|
21 |
border-radius: 8px;
|
22 |
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
23 |
+
max-width: 600px;
|
24 |
+
width: 100%;
|
25 |
}
|
26 |
+
h1, h3 {
|
27 |
color: #333;
|
28 |
+
margin-bottom: 20px;
|
29 |
}
|
30 |
.restaurant {
|
31 |
font-size: 1.2em;
|
32 |
margin: 10px 0;
|
33 |
}
|
34 |
+
.restaurant a {
|
35 |
+
color: #007bff;
|
36 |
+
text-decoration: none;
|
37 |
+
transition: color 0.3s;
|
38 |
+
}
|
39 |
+
.restaurant a:hover {
|
40 |
+
color: red;
|
41 |
+
}
|
42 |
+
.bonus-container {
|
43 |
+
margin-top: 30px;
|
44 |
+
padding: 20px;
|
45 |
+
background-color: #f0f8ff;
|
46 |
+
border-radius: 8px;
|
47 |
+
}
|
48 |
+
.bonus-container h3 {
|
49 |
+
margin-top: 0;
|
50 |
+
margin-bottom: 1%;
|
51 |
+
color: orange;
|
52 |
+
}
|
53 |
</style>
|
54 |
</head>
|
55 |
<body>
|
|
|
57 |
<h1>Today's Restaurant Suggestions</h1>
|
58 |
<p id="currentDate"></p>
|
59 |
<div id="restaurants"></div>
|
60 |
+
<div class="bonus-container">
|
61 |
+
<h3 id="bonusHeader">Bonus Suggestions</h3>
|
62 |
+
<div id="bonusRestaurants"></div>
|
63 |
+
</div>
|
64 |
</div>
|
65 |
<script src="script.js"></script>
|
66 |
</body>
|
restaurants.json
CHANGED
@@ -5,15 +5,21 @@
|
|
5 |
["후추포인트 (Italian)", "https://naver.me/GOzRKAoO"],
|
6 |
["파스타 트리오 (Italian)", "https://naver.me/5DbSwvXH"],
|
7 |
["진대감 (Korean, beef+pork)", "https://naver.me/5EQ3QCXL"],
|
8 |
-
["Taksim Kebab (Turkish, small place)", "https://
|
9 |
["Proteiner (low carb, high protein wraps, bowls)", "https://naver.me/xBhHYMfk"],
|
10 |
["쿠차라 강남점 (Mexican)", "https://maps.app.goo.gl/pGWzvT2Zm6KtNMLS7"],
|
11 |
["미엔아이 천등 (Chinese, beef and pork)", "https://naver.me/Ix7qUNzU"],
|
12 |
["상무초밥 (Sushi)", "https://naver.me/FfWO3pLI"],
|
13 |
-
["키토분식 (Kito)", "https://naver.me/G2xFx8vg"],
|
14 |
["인더비엣 (Vietnamese)", "https://inthevietsnh.modoo.at"],
|
15 |
["강남역 파스타 (Pasta, large space)", "https://naver.me/xL1EJLfC"],
|
16 |
-
["백가구내식당 (Korean)", "https://naver.me/xUSZRKEO"],
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
["강남교자 본점 (Dumplings)", "http://gyoja.gangnamlohas.com"],
|
18 |
["모범갈빗살 (Beef, lunch menu)", "https://naver.me/x9JcqgN7"],
|
19 |
["메차쿠차 (Don katsu)", "https://naver.me/GbEr52H0"]
|
|
|
5 |
["후추포인트 (Italian)", "https://naver.me/GOzRKAoO"],
|
6 |
["파스타 트리오 (Italian)", "https://naver.me/5DbSwvXH"],
|
7 |
["진대감 (Korean, beef+pork)", "https://naver.me/5EQ3QCXL"],
|
8 |
+
["Taksim Kebab (Turkish, small place)", "https://maps.app.goo.gl/6rwGVo5qbT9xKZAMA"],
|
9 |
["Proteiner (low carb, high protein wraps, bowls)", "https://naver.me/xBhHYMfk"],
|
10 |
["쿠차라 강남점 (Mexican)", "https://maps.app.goo.gl/pGWzvT2Zm6KtNMLS7"],
|
11 |
["미엔아이 천등 (Chinese, beef and pork)", "https://naver.me/Ix7qUNzU"],
|
12 |
["상무초밥 (Sushi)", "https://naver.me/FfWO3pLI"],
|
13 |
+
["키토분식 (Kito, This building)", "https://naver.me/G2xFx8vg"],
|
14 |
["인더비엣 (Vietnamese)", "https://inthevietsnh.modoo.at"],
|
15 |
["강남역 파스타 (Pasta, large space)", "https://naver.me/xL1EJLfC"],
|
16 |
+
["백가구내식당 (Korean, Menu changes every day)", "https://naver.me/xUSZRKEO"],
|
17 |
+
["돈비고고 (unlimited 돈까스 + 제육 (Pork) for 8.8K)", "https://naver.me/GGUfwvl9"],
|
18 |
+
["덕자네 방앗간 (cheap Gimbab & tteokbokki)", "https://maps.app.goo.gl/H6ZHQytb7ksxNma87"],
|
19 |
+
["싸다김밥 (Gimbab & tteokobkki & noodle & cutlet …)", "https://maps.app.goo.gl/bX1ubHKgp1ZgGUYLA"],
|
20 |
+
["노브랜드버거 (Chicken burger avail)", "https://naver.me/5IFsT0fz"],
|
21 |
+
["Halal guys (sandwich and platters with beef or chicken)", "https://naver.me/F0KtkgV9"],
|
22 |
+
["순남시래기 (Raddish soup, Ribka cannot eat here)", "https://naver.me/Ft8l8iJQ"],
|
23 |
["강남교자 본점 (Dumplings)", "http://gyoja.gangnamlohas.com"],
|
24 |
["모범갈빗살 (Beef, lunch menu)", "https://naver.me/x9JcqgN7"],
|
25 |
["메차쿠차 (Don katsu)", "https://naver.me/GbEr52H0"]
|
script.js
CHANGED
@@ -1,17 +1,19 @@
|
|
1 |
-
|
|
|
|
|
2 |
var m = array.length, t, i;
|
3 |
|
4 |
// While there remain elements to shuffle…
|
5 |
while (m) {
|
6 |
|
7 |
// Pick a remaining element…
|
8 |
-
i = Math.floor(random(seed) * m--);
|
9 |
|
10 |
// And swap it with the current element.
|
11 |
t = array[m];
|
12 |
array[m] = array[i];
|
13 |
array[i] = t;
|
14 |
-
++seed
|
15 |
}
|
16 |
|
17 |
return array;
|
@@ -35,7 +37,7 @@ async function fetchRestaurants() {
|
|
35 |
function getRandomRestaurants(restaurants, seed) {
|
36 |
// Generate three random indices based on the seed
|
37 |
randomRestaurants = shuffle(restaurants, seed);
|
38 |
-
return randomRestaurants.slice(0,
|
39 |
}
|
40 |
|
41 |
async function displayRestaurants() {
|
@@ -56,17 +58,6 @@ async function displayRestaurants() {
|
|
56 |
}
|
57 |
|
58 |
const dateKey = today.toISOString().split('T')[0];
|
59 |
-
let savedData = localStorage.getItem('restaurantSuggestions');
|
60 |
-
|
61 |
-
if (savedData) {
|
62 |
-
savedData = JSON.parse(savedData);
|
63 |
-
if (savedData.date === dateKey) {
|
64 |
-
document.getElementById('restaurants').innerHTML = savedData.restaurants.map(restaurant =>
|
65 |
-
`<a href="${restaurant[1]}" target="_blank">${restaurant[0]}</a>`
|
66 |
-
).join('<br>');
|
67 |
-
return;
|
68 |
-
}
|
69 |
-
}
|
70 |
|
71 |
try {
|
72 |
const restaurants = await fetchRestaurants();
|
@@ -75,19 +66,29 @@ async function displayRestaurants() {
|
|
75 |
console.log('Random seed per day: ', seed);
|
76 |
const randomRestaurants = getRandomRestaurants(restaurants, seed);
|
77 |
console.log('Random Restaurants:', randomRestaurants); // Debugging: Print random restaurants
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
`<a href="${restaurant[1]}" target="_blank">${restaurant[0]}</a>`
|
80 |
).join('<br>');
|
81 |
|
82 |
-
const dataToSave = {
|
83 |
-
date: dateKey,
|
84 |
-
restaurants: randomRestaurants
|
85 |
-
};
|
86 |
-
|
87 |
-
localStorage.setItem('restaurantSuggestions', JSON.stringify(dataToSave));
|
88 |
} catch (error) {
|
89 |
console.error('Error fetching restaurants:', error);
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
}
|
92 |
}
|
93 |
|
|
|
1 |
+
const restaurant_no = 5;
|
2 |
+
|
3 |
+
function shuffle(array, seed) {
|
4 |
var m = array.length, t, i;
|
5 |
|
6 |
// While there remain elements to shuffle…
|
7 |
while (m) {
|
8 |
|
9 |
// Pick a remaining element…
|
10 |
+
i = Math.floor(random(seed) * m--);
|
11 |
|
12 |
// And swap it with the current element.
|
13 |
t = array[m];
|
14 |
array[m] = array[i];
|
15 |
array[i] = t;
|
16 |
+
++seed
|
17 |
}
|
18 |
|
19 |
return array;
|
|
|
37 |
function getRandomRestaurants(restaurants, seed) {
|
38 |
// Generate three random indices based on the seed
|
39 |
randomRestaurants = shuffle(restaurants, seed);
|
40 |
+
return randomRestaurants.slice(0,restaurant_no);
|
41 |
}
|
42 |
|
43 |
async function displayRestaurants() {
|
|
|
58 |
}
|
59 |
|
60 |
const dateKey = today.toISOString().split('T')[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
try {
|
63 |
const restaurants = await fetchRestaurants();
|
|
|
66 |
console.log('Random seed per day: ', seed);
|
67 |
const randomRestaurants = getRandomRestaurants(restaurants, seed);
|
68 |
console.log('Random Restaurants:', randomRestaurants); // Debugging: Print random restaurants
|
69 |
+
|
70 |
+
const firstThreeRestaurants = randomRestaurants.slice(0, 3);
|
71 |
+
const bonusRestaurants = randomRestaurants.slice(3, 5);
|
72 |
+
|
73 |
+
document.getElementById('restaurants').innerHTML = firstThreeRestaurants.map(restaurant =>
|
74 |
+
`<a href="${restaurant[1]}" target="_blank">${restaurant[0]}</a>`
|
75 |
+
).join('<br>');
|
76 |
+
document.getElementById('bonusRestaurants').innerHTML = bonusRestaurants.map(restaurant =>
|
77 |
`<a href="${restaurant[1]}" target="_blank">${restaurant[0]}</a>`
|
78 |
).join('<br>');
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
} catch (error) {
|
81 |
console.error('Error fetching restaurants:', error);
|
82 |
+
const bestRestaurants = [
|
83 |
+
["돈비고고 (unlimited 돈까스 + 제육 (Pork) for 8.8K)", "https://naver.me/GGUfwvl9"],
|
84 |
+
["Taksim Kebab (Turkish, small place)", "https://maps.app.goo.gl/6rwGVo5qbT9xKZAMA"],
|
85 |
+
["강남역 파스타 (Pasta, large space)", "https://naver.me/xL1EJLfC"],
|
86 |
+
]
|
87 |
+
document.getElementById('restaurants').innerHTML = "Failed to load restaurant suggestions. <br>Below are my personal suggestions based on your review!!";
|
88 |
+
document.getElementById('bonusHeader').innerHTML = "";
|
89 |
+
document.getElementById('bonusRestaurants').innerHTML = bestRestaurants.map(restaurant =>
|
90 |
+
`<a href="${restaurant[1]}" target="_blank">${restaurant[0]}</a>`
|
91 |
+
).join('<br>') + "<br><br>";
|
92 |
}
|
93 |
}
|
94 |
|