-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
307 lines (292 loc) · 10.2 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
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>중고책 매입가 검색 | 알라딘, YES24 비교</title>
<meta name="description" content="알라딘과 YES24의 중고도서 매입가를 쉽고 빠르게 비교해보세요. 최고의 중고도서 판매 가격을 찾아보세요!">
<meta name="keywords" content="중고도서, 매입가, 알라딘, YES24, 도서 판매, 중고책">
<meta name="author" content="도서 매입가 비교 서비스">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>📖</text></svg>">
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html, body {
height: 100%;
overflow: hidden;
}
body {
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
line-height: 1.6;
}
header, main {
width: 100%;
}
header {
background-color: #f0f0f0;
padding: 20px;
flex-shrink: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.search-box {
background-color: white;
padding: 15px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
width: 100%;
max-width: 400px;
margin-bottom: 20px;
}
h1 {
text-align: center;
color: #333;
margin-bottom: 15px;
font-size: 24px;
}
#searchForm {
display: flex;
flex-direction: column;
gap: 10px;
}
#searchInput {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 16px;
}
.search-buttons {
display: flex;
gap: 10px;
}
.search-buttons button {
flex: 1;
padding: 10px;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
transition: background-color 0.3s;
white-space: nowrap;
}
#aladinButton {
background-color: #ed145b;
}
#aladinButton:hover, #aladinButton:focus {
background-color: #be1049;
}
#yes24Button {
background-color: #0080ff;
}
#yes24Button:hover, #yes24Button:focus {
background-color: #0066cc;
}
main {
flex-grow: 1;
position: relative;
display: flex;
justify-content: center;
align-items: center;
background-color: #f9f9f9;
}
.iframe-message {
text-align: center;
color: #666;
font-size: 16px;
}
.iframe-message i {
font-size: 48px;
margin-bottom: 10px;
color: #999;
}
iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
display: none;
}
.toss-button {
font-family: Arial, sans-serif;
line-height: 1.6;
text-align: center;
font-size: 12px;
box-sizing: border-box;
margin: 0;
display: inline-block;
background-color: #0064FF;
color: white;
padding: 5px 10px;
border-radius: 4px;
text-decoration: none;
transition: background-color 0.3s;
}
.toss-button:hover, .toss-button:focus {
background-color: #0050CC;
}
.error-message {
color: #d9534f;
font-size: 14px;
margin-top: 5px;
display: none;
}
.loading {
display: none;
justify-content: center;
align-items: center;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.8);
z-index: 1000;
}
.loading::after {
content: "";
width: 50px;
height: 50px;
border: 5px solid #f3f3f3;
border-top: 5px solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@media (min-width: 768px) {
body {
flex-direction: row;
}
header {
width: 45%; /* 수정된 부분: 데스크톱에서 header 너비를 45%로 설정 */
height: 100%;
}
main {
width: 55%; /* 수정된 부분: 데스크톱에서 main 너비를 55%로 설정 */
height: 100%;
}
}
</style>
</head>
<body>
<header>
<div class="search-box">
<h1>📖중고책 매입가 조회</h1>
<form id="searchForm" role="search">
<label for="searchInput" class="sr-only">도서명 입력</label>
<input type="text" id="searchInput" placeholder="도서명을 입력해주세요" required aria-required="true">
<div class="error-message" id="errorMessage" role="alert"></div>
<div class="search-buttons">
<button type="button" id="aladinButton" aria-label="알라딘에서 검색">알라딘에서 검색</button>
<button type="button" id="yes24Button" aria-label="YES24에서 검색">YES24에서 검색</button>
</div>
</form>
</div>
<a href="https://toss.me/hongv" class="toss-button" target="_blank" rel="noopener noreferrer" aria-label="Toss로 후원하기">
<i class="fas fa-heart" aria-hidden="true"></i> Toss로 후원하기
</a>
</header>
<main>
<div class="iframe-message" aria-live="polite">
<i class="fas fa-search" aria-hidden="true"></i>
<p>검색 버튼을 클릭하면 이곳에 결과가 표시됩니다</p>
</div>
<iframe id="searchFrame" src="about:blank" title="검색 결과"></iframe>
</main>
<div class="loading" id="loadingIndicator" aria-hidden="true"></div>
<script>
const searchForm = document.getElementById('searchForm');
const searchInput = document.getElementById('searchInput');
const yes24Button = document.getElementById('yes24Button');
const aladinButton = document.getElementById('aladinButton');
const searchFrame = document.getElementById('searchFrame');
const iframeMessage = document.querySelector('.iframe-message');
const errorMessage = document.getElementById('errorMessage');
const loadingIndicator = document.getElementById('loadingIndicator');
function showLoading() {
loadingIndicator.style.display = 'flex';
}
function hideLoading() {
loadingIndicator.style.display = 'none';
}
function showError(message) {
errorMessage.textContent = message;
errorMessage.style.display = 'block';
}
function hideError() {
errorMessage.style.display = 'none';
}
function validateInput() {
const value = searchInput.value.trim();
if (value === '') {
showError('도서명을 입력해주세요.');
return false;
}
hideError();
return true;
}
searchInput.addEventListener('input', validateInput);
function encodeUTF16(str) {
var out = "";
var len = str.length;
for (var i = 0; i < len; i++) {
out += '%u' + ('0000' + str.charCodeAt(i).toString(16).toUpperCase()).slice(-4);
}
return out;
}
function searchYes24(searchTerm) {
showLoading();
const encodedSearchTerm = encodeUTF16(searchTerm);
const url = `https://www.yes24.com/Mall/buyback/Search?CategoryNumber=018&SearchWord=${encodedSearchTerm}&SearchDomain=BOOK,FOREIGN&SearchSort=SINDEX_ONLY&BuybackAccept=N`;
searchFrame.src = url;
searchFrame.onload = () => {
hideLoading();
iframeMessage.style.display = 'none';
searchFrame.style.display = 'block';
};
}
function searchAladin(searchTerm) {
showLoading();
const encodedSearchTerm = encodeURIComponent(searchTerm);
const url = `https://www.aladin.co.kr/m/c2b/c2b_search.aspx?actiontype=1&searchtarget=book&keyword=${encodedSearchTerm}&x=3&y=31`;
searchFrame.src = url;
searchFrame.onload = () => {
hideLoading();
iframeMessage.style.display = 'none';
searchFrame.style.display = 'block';
};
}
function handleSearch(searchFunction) {
if (validateInput()) {
searchFunction(searchInput.value.trim());
}
}
yes24Button.addEventListener('click', () => handleSearch(searchYes24));
aladinButton.addEventListener('click', () => handleSearch(searchAladin));
searchForm.addEventListener('submit', (e) => {
e.preventDefault();
handleSearch(searchAladin);
});
searchInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
e.preventDefault();
handleSearch(searchAladin);
}
});
</script>
</body>
</html>