-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
303 lines (263 loc) · 9.54 KB
/
Copy pathindex.html
File metadata and controls
303 lines (263 loc) · 9.54 KB
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
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>주소록 변환기</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
background: #f0f0f0;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
}
.wrap {
background: #fff;
border: 1px solid #ddd;
border-radius: 8px;
padding: 36px;
width: 100%;
max-width: 480px;
}
h1 {
font-size: 17px;
font-weight: 700;
margin-bottom: 4px;
}
.sub {
font-size: 13px;
color: #888;
margin-bottom: 28px;
}
.drop-zone {
border: 1.5px dashed #bbb;
border-radius: 6px;
padding: 36px 20px;
text-align: center;
cursor: pointer;
transition: border-color 0.15s, background 0.15s;
margin-bottom: 16px;
}
.drop-zone:hover, .drop-zone.over {
border-color: #555;
background: #fafafa;
}
.drop-zone p {
font-size: 14px;
color: #555;
}
#file-input { display: none; }
.file-name {
font-size: 13px;
color: #444;
margin-bottom: 12px;
display: none;
}
.msg {
font-size: 13px;
padding: 9px 12px;
border-radius: 5px;
margin-bottom: 14px;
display: none;
}
.msg.err { background: #fff0f0; color: #c00; border: 1px solid #fcc; }
.msg.ok { background: #f0fff4; color: #1a7a3a; border: 1px solid #b2dfca; }
.msg.info { background: #f5f5f5; color: #444; border: 1px solid #e0e0e0; }
.btn {
width: 100%;
padding: 12px;
background: #222;
color: #fff;
border: none;
border-radius: 6px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: background 0.15s;
}
.btn:hover { background: #000; }
.btn:disabled { background: #bbb; cursor: not-allowed; }
.map-toggle {
font-size: 12px;
color: #888;
cursor: pointer;
margin-top: 18px;
display: inline-block;
text-decoration: underline;
text-underline-offset: 2px;
}
.map-wrap { display: none; margin-top: 10px; }
table {
width: 100%;
border-collapse: collapse;
font-size: 12px;
}
th {
text-align: left;
padding: 6px 8px;
background: #f7f7f7;
color: #666;
border-bottom: 1px solid #e8e8e8;
}
td {
padding: 5px 8px;
color: #444;
border-bottom: 1px solid #f0f0f0;
}
tr:last-child td { border-bottom: none; }
.arr { color: #bbb; }
</style>
</head>
<body>
<div class="wrap">
<h1>다음 주소록 → Outlook 변환</h1>
<p class="sub">다음메일에서 내보낸 CSV를 Outlook용으로 바꿔줍니다.</p>
<div class="drop-zone" id="drop-zone">
<p>CSV 파일을 여기에 끌어다 놓거나 클릭해서 선택하세요</p>
<input type="file" id="file-input" accept=".csv">
</div>
<div class="file-name" id="file-name"></div>
<div class="msg" id="msg"></div>
<button class="btn" id="btn" disabled>변환하고 다운로드</button>
<span class="map-toggle" id="map-toggle">헤더 매핑 보기</span>
<div class="map-wrap" id="map-wrap">
<table>
<thead>
<tr><th>다음메일</th><th></th><th>Outlook</th></tr>
</thead>
<tbody id="map-body"></tbody>
</table>
</div>
</div>
<script>
// 다음 CSV 헤더(EUC-KR) → Outlook 헤더 매핑
const MAP = {
'이름': 'First Name',
'전자 우편 주소': 'E-mail Address',
'휴대용 전화': 'Mobile Phone',
'집 전화 번호': 'Home Phone',
'회사 기본 전화': 'Business Phone',
'회사': 'Company',
};
// Outlook CSV 전체 헤더 (샘플 양식 기준)
const OUTLOOK_HEADERS = [
'Title','First Name','Middle Name','Last Name','Suffix','Company','Department',
'Job Title','Business Street','Business Street 2','Business Street 3','Business City',
'Business State','Business Postal Code','Business Country/Region','Home Street',
'Home Street 2','Home Street 3','Home City','Home State','Home Postal Code',
'Home Country/Region','Other Street','Other Street 2','Other Street 3','Other City',
'Other State','Other Postal Code','Other Country/Region',"Assistant's Phone",
'Business Fax','Business Phone','Business Phone 2','Callback','Car Phone',
'Company Main Phone','Home Fax','Home Phone','Home Phone 2','ISDN','Mobile Phone',
'Other Fax','Other Phone','Pager','Primary Phone','Radio Phone','TTY/TDD Phone',
'Telex','Account','Anniversary',"Assistant's Name",'Billing Information','Birthday',
'Business Address PO Box','Categories','Children','Directory Server','E-mail Address',
'E-mail Type','E-mail Display Name','E-mail 2 Address','E-mail 2 Type',
'E-mail 2 Display Name','E-mail 3 Address','E-mail 3 Type','E-mail 3 Display Name',
'Gender','Government ID Number','Hobby','Home Address PO Box','Initials',
'Internet Free Busy','Keywords','Language','Location',"Manager's Name",'Mileage',
'Notes','Office Location','Organizational ID Number','Other Address PO Box','Priority',
'Private','Profession','Referred By','Sensitivity','Spouse','User 1','User 2',
'User 3','User 4','Web Page'
];
// 매핑 테이블 렌더링
const tbody = document.getElementById('map-body');
Object.entries(MAP).forEach(([ko, en]) => {
const tr = document.createElement('tr');
tr.innerHTML = `<td>${ko}</td><td class="arr">→</td><td>${en}</td>`;
tbody.appendChild(tr);
});
// 토글
document.getElementById('map-toggle').addEventListener('click', () => {
const w = document.getElementById('map-wrap');
const t = document.getElementById('map-toggle');
const open = w.style.display === 'block';
w.style.display = open ? 'none' : 'block';
t.textContent = open ? '헤더 매핑 보기' : '헤더 매핑 닫기';
});
// 드래그 앤 드롭
const dz = document.getElementById('drop-zone');
dz.addEventListener('click', () => document.getElementById('file-input').click());
dz.addEventListener('dragover', e => { e.preventDefault(); dz.classList.add('over'); });
dz.addEventListener('dragleave', () => dz.classList.remove('over'));
dz.addEventListener('drop', e => { e.preventDefault(); dz.classList.remove('over'); if (e.dataTransfer.files[0]) handleFile(e.dataTransfer.files[0]); });
document.getElementById('file-input').addEventListener('change', e => { if (e.target.files[0]) handleFile(e.target.files[0]); });
function showMsg(text, type) {
const el = document.getElementById('msg');
el.textContent = text;
el.className = `msg ${type}`;
el.style.display = 'block';
}
let parsed = null;
function handleFile(file) {
if (!file.name.endsWith('.csv')) { showMsg('CSV 파일만 가능합니다.', 'err'); return; }
document.getElementById('file-name').textContent = '📄 ' + file.name;
document.getElementById('file-name').style.display = 'block';
const reader = new FileReader();
reader.onload = e => {
try {
parsed = parseCSV(e.target.result);
const matched = parsed.headers.filter(h => MAP[h]).length;
showMsg(`컬럼 ${parsed.headers.length}개 인식 · ${matched}개 변환됨`, 'info');
document.getElementById('btn').disabled = false;
} catch(err) {
showMsg('파싱 실패: ' + err.message, 'err');
}
};
reader.readAsText(file, 'EUC-KR');
}
function parseCSV(text) {
const lines = text.trim().split('\n');
const headers = splitLine(lines[0]);
const rows = lines.slice(1).filter(l => l.trim()).map(splitLine);
return { headers, rows };
}
function splitLine(line) {
const result = [];
let cur = '', inQ = false;
for (let i = 0; i < line.length; i++) {
const c = line[i];
if (c === '"') { inQ = !inQ; }
else if (c === ',' && !inQ) { result.push(cur.trim()); cur = ''; }
else { cur += c; }
}
result.push(cur.trim());
return result;
}
function toCSV(rows) {
const esc = v => `"${(v||'').replace(/"/g,'""')}"`;
return rows.map(r => r.map(esc).join(',')).join('\n');
}
document.getElementById('btn').addEventListener('click', () => {
if (!parsed) return;
// 다음 헤더 → Outlook 헤더 인덱스 매핑
const colMap = {};
parsed.headers.forEach((h, i) => {
const outKey = MAP[h];
if (outKey) colMap[i] = OUTLOOK_HEADERS.indexOf(outKey);
});
// Outlook 행 생성
const outRows = parsed.rows.map(row => {
const out = new Array(OUTLOOK_HEADERS.length).fill('');
Object.entries(colMap).forEach(([srcIdx, dstIdx]) => {
if (dstIdx >= 0) out[dstIdx] = row[srcIdx] || '';
});
return out;
});
const csv = toCSV([OUTLOOK_HEADERS, ...outRows]);
const blob = new Blob(['' + csv], { type: 'text/csv;charset=utf-8;' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'outlook_contacts.csv';
a.click();
URL.revokeObjectURL(url);
showMsg('완료! outlook_contacts.csv 다운로드됐습니다.', 'ok');
});
</script>
</body>
</html>