Repository navigation
Expand file tree
/
Copy pathadmin.html
More file actions
684 lines (638 loc) · 27.9 KB
/
Copy pathadmin.html
File metadata and controls
684 lines (638 loc) · 27.9 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
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="#f2f3f5">
<title>본점 매장 도면 (관리자)</title>
<style>
*{box-sizing:border-box;}
body{
margin:0;
background:#f2f3f5;
color:#1a1e21;
font-family:"Pretendard","Apple SD Gothic Neo","Malgun Gothic",sans-serif;
padding:14px;
}
h1{font-size:16px;margin:0 0 4px;}
.sub{font-size:12px;color:#637075;margin-bottom:10px;}
.toolbar{display:flex;gap:8px;margin-bottom:10px;}
button{
border:1px solid #d8dcde;background:#fff;color:#1a1e21;
padding:8px 13px;border-radius:9px;font-size:13px;cursor:pointer;
}
button.primary{background:#1a1e21;color:#fff;border-color:#1a1e21;}
.search-wrap{margin-bottom:10px;}
.search-wrap input{
width:100%;padding:11px 14px;border-radius:9px;
border:1px solid #d8dcde;background:#fff;color:#1a1e21;
font-size:14px;outline:none;
}
.search-wrap input:focus{border-color:#e0392f;}
.floor{
position:relative;
background:#fff;
border:1px solid #d8dcde;
border-radius:10px;
height:640px;
overflow:auto;
touch-action:none;
}
.floorInner{
position:relative;
width:1800px;
height:1200px;
background-image:
linear-gradient(rgba(0,0,0,.06) 1px, transparent 1px),
linear-gradient(90deg, rgba(0,0,0,.06) 1px, transparent 1px);
background-size:20px 20px;
}
.floor.line-mode{cursor:crosshair;}
.lineLayer{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;}
.floor.line-mode .lineLayer{pointer-events:auto;}
.lineLayer line{stroke:#c0392b;stroke-width:3;cursor:pointer;}
.lineLayer text{font-size:13px;font-weight:700;fill:#c0392b;font-family:inherit;user-select:none;}
.lineLayer .hitline{stroke:transparent;stroke-width:16;cursor:pointer;}
.lineLayer line.selected{stroke:#1a56db;}
.lineActions{
position:absolute;display:none;gap:6px;transform:translate(-50%,-100%);
background:#1a1e21;padding:5px;border-radius:8px;z-index:9;
}
.lineActions button{
padding:5px 9px;font-size:11.5px;border-radius:6px;border:none;
background:#2c3438;color:#fff;cursor:pointer;
}
.lineActions button.danger{background:#d1372c;}
.boxLayer{position:absolute;inset:0;}
.box{
position:absolute;
border-radius:8px;
border:2px solid #b23b2f;
background:#e0392f;
color:#fff;
display:flex;align-items:center;justify-content:center;
cursor:grab;
touch-action:none;
user-select:none;
overflow:hidden;
}
.boxLabel{
font-size:12px;font-weight:700;text-align:center;padding:3px;
outline:none;width:100%;
word-break:keep-all;
}
.boxLabel:empty::before{
content:"이름 입력";
opacity:.6;font-weight:500;
}
.boxLabel[contenteditable="true"]{
background:rgba(0,0,0,.25);border-radius:4px;cursor:text;
user-select:text;
}
.box.dragging{cursor:grabbing;box-shadow:0 6px 18px rgba(0,0,0,.35);z-index:5;filter:brightness(1.1);}
.box.dim{opacity:.18;}
.box.match{box-shadow:0 0 0 3px #1a56db, 0 6px 18px rgba(26,86,219,.5);z-index:6;}
.resize-handle{
position:absolute;right:2px;bottom:2px;width:16px;height:16px;
cursor:nwse-resize;border-radius:3px;
background:rgba(255,255,255,.5);
}
.dup-handle{
position:absolute;left:2px;top:2px;width:18px;height:18px;
cursor:pointer;border-radius:4px;
background:rgba(255,255,255,.55);
display:flex;align-items:center;justify-content:center;
font-size:12px;color:#1a1e21;font-weight:800;
}
.dup-handle:hover{background:#fff;}
.del-handle{
position:absolute;left:2px;bottom:2px;width:16px;height:16px;
cursor:pointer;border-radius:4px;
background:rgba(255,255,255,.55);
display:flex;align-items:center;justify-content:center;
font-size:11px;color:#7a1410;font-weight:800;
}
.del-handle:hover{background:#fff;}
.kw-handle{
position:absolute;right:2px;top:2px;width:16px;height:16px;
cursor:pointer;border-radius:4px;
background:rgba(255,255,255,.55);
display:flex;align-items:center;justify-content:center;
font-size:10px;color:#1a1e21;font-weight:800;
}
.kw-handle:hover{background:#fff;}
.kw-handle.has-kw{background:#ffd76a;}
.flow{display:flex;justify-content:space-between;font-size:11px;color:#637075;margin-top:8px;}
.out{
margin-top:14px;background:#1c2226;color:#eef1f2;border-radius:9px;padding:12px 14px;
font-family:monospace;font-size:11.5px;white-space:pre-wrap;word-break:break-all;
max-height:160px;overflow:auto;display:none;
}
</style>
</head>
<body>
<h1>본점 매장 도면 (관리자용 · 편집 가능)</h1>
<div class="sub">이 페이지는 배치를 수정하는 관리자용입니다. 직원들에게는 별도의 조회 전용 페이지(staff.html)를 공유하세요.</div>
<div class="search-wrap">
<input id="search" type="text" placeholder="상품명·구역 검색 (예: 릭, 소모품, 각인기)" autocomplete="off">
</div>
<div class="toolbar">
<button class="primary" id="exportBtn">좌표 내보내기</button>
<button id="addBtn">박스 추가</button>
<button id="lineModeBtn">선 그리기: 꺼짐</button>
<button id="clearLinesBtn">선 전체 지우기</button>
<button id="growBtn">캔버스 키우기</button>
<button id="uniformBtn">박스 크기 통일</button>
<button id="alignBtn">정렬 정리</button>
<button id="resetBtn">초기 배치로 리셋</button>
</div>
<div class="floor" id="floor">
<div class="floorInner" id="floorInner">
<div class="boxLayer" id="boxLayer"></div>
<svg class="lineLayer" id="lineLayer"></svg>
<div class="lineActions" id="lineActions">
<button id="renameLineBtn">이름 수정</button>
<button id="deleteLineBtn" class="danger">삭제</button>
</div>
</div>
</div>
<div class="flow"><span>◂ 창고 방향(B-3)</span><span>입구·외부자판기 ▸</span></div>
<div class="out" id="out"></div>
<script>
const STORAGE_KEY = 'vf_bonjeom_plain_layout_v1';
const DEFAULTS = {
"1":{x:58,y:15,w:5,h:5,label:"소모품",keywords:"파티 닷모드 팟*,발라코일V2 0.6옴,발라코일V2 0.8옴,발라코일V2 1.0옴,발라맥스프로팟 0.6옴"},
"2":{x:50,y:15,w:5,h:5,label:"봉투,쿠폰",keywords:"봉투,쿠폰"},
"3":{x:64,y:21,w:5,h:5,label:"소모품",keywords:"아스몬 0.6옴*,아스몬 공팟*,아스몬0.6옴체결팟*,아스몬 하이팟 0.6옴,글렌트 0.6옴팟,에이펙스 팟,마이팟 프로 0.6옴팟,디오x팟,럭스Q팟 0.6옴*,크로스0.8옴팟*,아르거스 V3 0.7옴팟,페보 0.6옴팟,칼미아팟,하부 1.6옴,AX 0.6옴팟*,썬더Q 0.6옴팟*,프로스텐다드코일"},
"4":{x:70,y:21,w:5,h:5,label:"소모품/케이스",keywords:"발라 투명케이스,젤로맥스 케이스,닷파티 케이스*,말론S 케이스,불렛 드립팁,말론 510 드립팁,베이비 탑캡,닷 드립팁 화이트,닷 드립팁 블랙"},
"5":{x:70,y:6,w:5,h:5,label:"각인,일회용 진열장",keywords:""},
"6":{x:70,y:15,w:5,h:5,label:"소모품",keywords:"말론팟 0.6옴,말론S 0.6옴팟,말론S 0.4옴팟,베이비0.7옴팟*,베이비프로0.6옴팟*,아스몬 드립팁,젤로드립팁,아스몬 투명케이스,브이메이트E캡,스타일러스 공팟"},
"7":{x:58,y:21,w:5,h:5,label:"소모품",keywords:"플러키 0.6옴팟,발라R 0.6옴팟*,발라클리어공팟*,발라맥스공팟*,발라맥스 프로공팟"},
"8":{x:70,y:42,w:5,h:5,label:"빈곳",keywords:""},
"9":{x:64,y:15,w:5,h:5,label:"소모품",keywords:"젤로0.8옴*,젤로맥스 0.6옴팟*,젤로맥스 0.6옴팟 5ml,젤로 크리스탈 0.6옴 팟,0.15옴 팟,소울 0.6옴팟*,브이메이트v2팟*,젤로 울트라팟"},
"10":{x:50,y:21,w:5,h:5,label:"소모품",keywords:"아스트로 레드팟,발라리안 에어 0.6옴팟*,하복코일 0.25옴*,하복코일 0.6*,하복공팟*,베놈 레드팟,아스트로 블랙팟,조바 0.7옴팟"},
"11":{x:78,y:28,w:5,h:5,label:"케이스/빌지",keywords:"영수증빌지,맥스프로 스티그마 화이트케이스,맥스프로 스티그마 블랙케이스,맥스프로 스티그마 케이스"},
"12":{x:78,y:70,w:5,h:5,label:"일회용",keywords:"팜팜바"},
"13":{x:78,y:90,w:5,h:5,label:"기기",keywords:"조바,발라리안맥스프로스티그마"},
"14":{x:78,y:83,w:5,h:5,label:"기기",keywords:"발라리안맥스프로스티그마,플러키,아스트로모터헤드,말론"},
"15":{x:78,y:42,w:5,h:5,label:"빈곳",keywords:""},
"16":{x:70,y:83,w:5,h:5,label:"기기",keywords:"발라리안맥스프로,하복,말론S"},
"19":{x:50,y:70,w:5,h:5,label:"보관함",keywords:""},
"21":{x:70,y:90,w:5,h:5,label:"기기",keywords:"조바"},
"23":{x:58,y:90,w:5,h:5,label:"세면대",keywords:"청소기롤,에어건"},
"24":{x:70,y:70,w:5,h:5,label:"빈곳",keywords:""},
"25":{x:70,y:76,w:5,h:5,label:"엘프바5%",keywords:"엘프바5%"},
"26":{x:7,y:21,w:5,h:5,label:"빌런액상",keywords:""},
"27":{x:13,y:21,w:5,h:5,label:"빌런액상",keywords:""},
"28":{x:7,y:28,w:5,h:5,label:"종이가방",keywords:""},
"29":{x:13,y:28,w:5,h:5,label:"릭액상",keywords:""},
"30":{x:20,y:28,w:5,h:5,label:"문구류",keywords:""},
"31":{x:20,y:21,w:5,h:5,label:"문구류",keywords:""},
"32":{x:26,y:28,w:5,h:5,label:"휴지,유리세정제",keywords:""},
"33":{x:26,y:21,w:5,h:5,label:"폐호흡코일/말론0.4옴",keywords:""},
"34":{x:34,y:21,w:5,h:5,label:"폐호흡코일",keywords:"제우스서브옴 0.2옴코일*,제우스맥스 0.14옴코일*"},
"35":{x:34,y:28,w:5,h:5,label:"구급함/폐호흡코일",keywords:""},
"36":{x:20,y:0,w:5,h:5,label:"빌런/릭",keywords:""},
"37":{x:20,y:6,w:5,h:5,label:"릭/일회용",keywords:""},
"38":{x:7,y:6,w:5,h:5,label:"빌런/택배박스",keywords:""},
"39":{x:7,y:0,w:5,h:5,label:"빌런",keywords:""},
"40":{x:44,y:90,w:5,h:5,label:"쿨멘솔",keywords:"쿨멘솔"},
"41":{x:38,y:90,w:5,h:5,label:"빌런시리즈",keywords:"빌런"},
"42":{x:38,y:83,w:5,h:5,label:"빌런시리즈",keywords:"빌런"},
"43":{x:50,y:90,w:5,h:5,label:"릭시리즈",keywords:"릭시리즈"},
"44":{x:26,y:70,w:5,h:5,label:"RDA/18650",keywords:"RDA용품,18650,건전지"},
"46":{x:13,y:70,w:5,h:5,label:"폐호흡 프리미엄",keywords:""},
"47":{x:20,y:70,w:5,h:5,label:"디오리퀴드",keywords:"디오"},
"49":{x:7,y:70,w:5,h:5,label:"시연용액상",keywords:""},
"51":{x:7,y:76,w:5,h:5,label:"시연용액상",keywords:""},
"52":{x:13,y:76,w:5,h:5,label:"폐호흡 프리미엄",keywords:""},
"53":{x:20,y:76,w:5,h:5,label:"디오리퀴드",keywords:"디오"},
"54":{x:26,y:76,w:5,h:5,label:"폐호흡 관련",keywords:""},
"55":{x:7,y:83,w:5,h:5,label:"기타제품들",keywords:""},
"56":{x:13,y:83,w:5,h:5,label:"프라임액상/폐호흡프라임액상",keywords:""},
"57":{x:20,y:83,w:5,h:5,label:"디오리퀴드",keywords:"디오"},
"58":{x:26,y:83,w:5,h:5,label:"단종 프라임액상",keywords:"수리퀴드,스노우,러브"},
"60":{x:7,y:90,w:5,h:5,label:"기타제품들",keywords:""},
"61":{x:13,y:90,w:5,h:5,label:"폐호흡프리미엄액상",keywords:""},
"62":{x:20,y:90,w:5,h:5,label:"디오리퀴드",keywords:"디오"},
"63":{x:26,y:90,w:5,h:5,label:"퀸즈시리즈/리퀴드랩",keywords:"마피아퀸,사무라이퀸,아마조네스퀸,크루세이더퀸,리퀴드랩"},
"66":{x:50,y:76,w:5,h:5,label:"보관함",keywords:""},
"68":{x:32,y:76,w:5,h:5,label:"보관함",keywords:""},
"69":{x:44,y:83,w:5,h:5,label:"812시가",keywords:"812시가"},
"71":{x:50,y:83,w:5,h:5,label:"단종 액상",keywords:"단종액상"},
"72":{x:44,y:76,w:5,h:5,label:"AS",keywords:"명함,쿠폰"},
"74":{x:44,y:70,w:5,h:5,label:"AS",keywords:"AS기기,명함,쿠폰"},
"75":{x:32,y:70,w:5,h:5,label:"말론0.6옴팟",keywords:"말론0.6옴팟"},
"76":{x:38,y:76,w:5,h:5,label:"빈곳",keywords:""},
"77":{x:32,y:83,w:5,h:5,label:"리퀴드랩",keywords:"리퀴드랩액상"},
"78":{x:32,y:90,w:5,h:5,label:"무니코틴",keywords:""},
"79":{x:43,y:11,w:4,h:5,label:"PC",keywords:""},
"80":{x:50,y:6,w:4,h:5,label:"포스",keywords:""},
"81":{x:78,y:21,w:3,h:4,label:"각인기",keywords:""},
"82":{x:78,y:76,w:5,h:5,label:"일회용",keywords:"모스바"},
"83":{x:70,y:28,w:5,h:5,label:"케이스",keywords:"맥스프로 스티그마 블랙케이스,맥스프로 스티그마 화이트케이스,말론 케이스"},
"84":{x:78,y:35,w:5,h:5,label:"립클링/일회용",keywords:"립클링"},
"85":{x:70,y:35,w:5,h:5,label:"각인용지",keywords:"각인용지"},
"90":{x:70,y:56,w:13,h:2,label:"일회용제품",keywords:"모스바,엘프바1%"},
"91":{x:65,y:55,w:5,h:5,label:"고농도제품",keywords:"2%액상"},
"92":{x:65,y:61,w:5,h:5,label:"에어릭스",keywords:"에어릭스"},
"93":{x:1,y:21,w:5,h:5,label:"화확물질작성 및 잡다",keywords:""},
"94":{x:1,y:28,w:5,h:5,label:"물티슈,곽티슈",keywords:""},
"95":{x:70,y:59,w:13,h:2,label:"일회용제품",keywords:"팜팜바,드래곤바"},
"96":{x:70,y:61,w:13,h:2,label:"일회용제품",keywords:"네스티원,카오린,엘프바10,000펌프,팜팜바"},
"97":{x:70,y:64,w:13,h:2,label:"일회용제품",keywords:"팜팜바"},
"98":{x:38,y:70,w:5,h:5,label:"빈곳",keywords:"말론0.6옴팟"}
};
let layout = loadLayout() || JSON.parse(JSON.stringify(DEFAULTS));
function loadLayout(){
try{ return JSON.parse(localStorage.getItem(STORAGE_KEY) || 'null'); }catch(e){ return null; }
}
function saveLayout(){
try{ localStorage.setItem(STORAGE_KEY, JSON.stringify(layout)); }catch(e){}
}
const floorEl = document.getElementById('floor');
const floorInnerEl = document.getElementById('floorInner');
const boxLayer = document.getElementById('boxLayer');
const lineLayer = document.getElementById('lineLayer');
const LINE_KEY = 'vf_bonjeom_plain_lines_v1';
const DEFAULT_LINES = [
{x1:0.17,y1:66.75,x2:83.06,y2:66.83,label:"벽면"},
{x1:0.33,y1:15.92,x2:39.39,y2:16.08,label:"카운터2"},
{x1:77.22,y1:13.17,x2:48.39,y2:13.5,label:"카운터1"},
{x1:77.22,y1:13.08,x2:85.33,y2:31.17,label:"카운터3"},
{x1:85.67,y1:31.5,x2:83.83,y2:67.08,label:"카운터4"},
{x1:92.17,y1:0.5,x2:92.06,y2:24.5,label:"입구"},
{x1:92.17,y1:34.17,x2:92.5,y2:99.42,label:"자판기벽"}
];
let lines = loadLines() || JSON.parse(JSON.stringify(DEFAULT_LINES));
function loadLines(){
try{ return JSON.parse(localStorage.getItem(LINE_KEY) || 'null'); }catch(e){ return null; }
}
function saveLines(){
try{ localStorage.setItem(LINE_KEY, JSON.stringify(lines)); }catch(e){}
}
function render(){
boxLayer.innerHTML = '';
Object.keys(layout).forEach(num=>{
const pos = layout[num];
const box = document.createElement('div');
box.className = 'box';
box.dataset.num = num;
box.style.left = pos.x + '%';
box.style.top = pos.y + '%';
box.style.width = pos.w + '%';
box.style.height = pos.h + '%';
const label = document.createElement('div');
label.className = 'boxLabel';
label.spellcheck = false;
label.textContent = pos.label || '';
box.appendChild(label);
boxLayer.appendChild(box);
label.addEventListener('dblclick', (e)=>{ e.stopPropagation(); });
label.addEventListener('blur', ()=>{
label.contentEditable = 'false';
pos.label = label.textContent.trim();
saveLayout();
});
label.addEventListener('keydown', (e)=>{
if(e.key === 'Enter'){ e.preventDefault(); label.blur(); }
});
const handle = document.createElement('div');
handle.className = 'resize-handle';
box.appendChild(handle);
const dupHandle = document.createElement('div');
dupHandle.className = 'dup-handle';
dupHandle.textContent = '⧉';
dupHandle.title = '옆에 복제';
box.appendChild(dupHandle);
dupHandle.addEventListener('pointerdown', (e)=>{
e.stopPropagation();
});
dupHandle.addEventListener('click', (e)=>{
e.stopPropagation();
const nums = Object.keys(layout).map(Number);
const nextNum = nums.length ? Math.max(...nums) + 1 : 1;
const gap = 1;
let nx = pos.x + pos.w + gap;
let ny = pos.y;
if(nx + pos.w > 100){ nx = 0; ny = Math.min(100 - pos.h, pos.y + pos.h + gap); }
layout[nextNum] = { x:nx, y:ny, w:pos.w, h:pos.h, label:pos.label, keywords:pos.keywords||"" };
saveLayout();
render();
});
const delHandle = document.createElement('div');
delHandle.className = 'del-handle';
delHandle.textContent = '✕';
delHandle.title = '박스 삭제';
box.appendChild(delHandle);
delHandle.addEventListener('pointerdown', (e)=>{ e.stopPropagation(); });
delHandle.addEventListener('click', (e)=>{
e.stopPropagation();
if(!confirm(num + '번 박스를 삭제할까요?')) return;
delete layout[num];
saveLayout();
render();
});
const kwHandle = document.createElement('div');
kwHandle.className = 'kw-handle' + (pos.keywords ? ' has-kw' : '');
kwHandle.textContent = '🔍';
kwHandle.title = '검색 키워드 편집';
box.appendChild(kwHandle);
kwHandle.addEventListener('pointerdown', (e)=>{ e.stopPropagation(); });
kwHandle.addEventListener('click', (e)=>{
e.stopPropagation();
const cur = pos.keywords || '';
const input = prompt(
num + '번 박스 검색 키워드 (쉼표로 구분, 화면엔 안 보이고 검색에만 씀)\n예: 말론 0.4옴, 폐호흡 코일, XROS 코일',
cur
);
if(input === null) return;
pos.keywords = input.trim();
saveLayout();
render();
});
let lastDown = 0;
box.addEventListener('pointerdown', (e)=>{
if(e.target === handle || e.target === dupHandle || e.target === delHandle || e.target === kwHandle) return;
if(label.contentEditable === 'true') return; // let text editing/caret placement work normally
const now = Date.now();
const isDouble = (now - lastDown) < 350;
lastDown = now;
if(isDouble){
label.contentEditable = 'true';
label.focus();
document.execCommand('selectAll', false, null);
return;
}
const startX = e.clientX, startY = e.clientY;
const startPX = pos.x, startPY = pos.y;
const rect = floorInnerEl.getBoundingClientRect();
box.setPointerCapture(e.pointerId);
box.classList.add('dragging');
function onMove(ev){
const dxPct = (ev.clientX - startX) / rect.width * 100;
const dyPct = (ev.clientY - startY) / rect.height * 100;
let nx = Math.max(0, Math.min(100 - pos.w, startPX + dxPct));
let ny = Math.max(0, Math.min(100 - pos.h, startPY + dyPct));
pos.x = nx; pos.y = ny;
box.style.left = nx + '%'; box.style.top = ny + '%';
}
function onUp(){
box.releasePointerCapture(e.pointerId);
box.classList.remove('dragging');
box.removeEventListener('pointermove', onMove);
box.removeEventListener('pointerup', onUp);
saveLayout();
}
box.addEventListener('pointermove', onMove);
box.addEventListener('pointerup', onUp);
});
handle.addEventListener('pointerdown', (e)=>{
e.stopPropagation();
const startX = e.clientX, startY = e.clientY;
const startW = pos.w, startH = pos.h;
const rect = floorInnerEl.getBoundingClientRect();
handle.setPointerCapture(e.pointerId);
function onMove(ev){
const dxPct = (ev.clientX - startX) / rect.width * 100;
const dyPct = (ev.clientY - startY) / rect.height * 100;
let nw = Math.max(2, Math.min(100 - pos.x, startW + dxPct));
let nh = Math.max(2, Math.min(100 - pos.y, startH + dyPct));
pos.w = nw; pos.h = nh;
box.style.width = pos.w + '%'; box.style.height = pos.h + '%';
}
function onUp(){
handle.releasePointerCapture(e.pointerId);
handle.removeEventListener('pointermove', onMove);
handle.removeEventListener('pointerup', onUp);
saveLayout();
}
handle.addEventListener('pointermove', onMove);
handle.addEventListener('pointerup', onUp);
});
});
if(typeof applySearch === 'function') applySearch();
}
const searchEl = document.getElementById('search');
function applySearch(){
const q = searchEl.value.trim().toLowerCase();
const boxEls = boxLayer.querySelectorAll('.box');
let firstMatch = null;
boxEls.forEach(b=>{
const num = b.dataset.num;
const p = layout[num] || {};
const haystack = ((p.label||'') + ' ' + (p.keywords||'')).toLowerCase();
b.classList.remove('dim','match');
if(!q) return;
if(haystack.includes(q) || num.includes(q)){
b.classList.add('match');
if(!firstMatch) firstMatch = b;
}else{
b.classList.add('dim');
}
});
if(firstMatch){
firstMatch.scrollIntoView({behavior:'smooth', block:'center', inline:'center'});
}
}
searchEl.addEventListener('input', applySearch);
render();
document.getElementById('growBtn').addEventListener('click', ()=>{
const curW = parseInt(floorInnerEl.style.width || '1800', 10);
const curH = parseInt(floorInnerEl.style.height || '1200', 10);
floorInnerEl.style.width = (curW + 400) + 'px';
floorInnerEl.style.height = (curH + 300) + 'px';
});
document.getElementById('alignBtn').addEventListener('click', ()=>{
const thIn = prompt('정렬 민감도(%) — 이 값보다 가까운 것들끼리 줄을 맞춰요', '2.5');
if(thIn === null) return;
const threshold = Math.max(0.5, parseFloat(thIn) || 2.5);
function snapAxis(axis){
const nums = Object.keys(layout);
const items = nums.map(k=>({k, v: layout[k][axis]})).sort((a,b)=>a.v-b.v);
let group = [];
function flush(){
if(!group.length) return;
const avg = group.reduce((s,it)=>s+it.v,0)/group.length;
group.forEach(it=> layout[it.k][axis] = Math.round(avg*10)/10 );
group = [];
}
items.forEach(it=>{
if(group.length && (it.v - group[group.length-1].v) > threshold){
flush();
}
group.push(it);
});
flush();
}
snapAxis('x');
snapAxis('y');
// clamp back into bounds after snapping
Object.keys(layout).forEach(k=>{
const p = layout[k];
p.x = Math.max(0, Math.min(100 - p.w, p.x));
p.y = Math.max(0, Math.min(100 - p.h, p.y));
});
saveLayout();
render();
});
document.getElementById('uniformBtn').addEventListener('click', ()=>{
const nums = Object.keys(layout);
if(!nums.length) return;
const avgW = nums.reduce((s,k)=>s+layout[k].w,0)/nums.length;
const avgH = nums.reduce((s,k)=>s+layout[k].h,0)/nums.length;
const wIn = prompt('통일할 가로 크기(%)', Math.round(avgW));
if(wIn === null) return;
const hIn = prompt('통일할 세로 크기(%)', Math.round(avgH));
if(hIn === null) return;
const w = Math.max(1, parseFloat(wIn) || avgW);
const h = Math.max(1, parseFloat(hIn) || avgH);
nums.forEach(k=>{
layout[k].w = Math.min(w, 100 - layout[k].x);
layout[k].h = Math.min(h, 100 - layout[k].y);
});
saveLayout();
render();
});
document.getElementById('addBtn').addEventListener('click', ()=>{
const nums = Object.keys(layout).map(Number);
const nextNum = nums.length ? Math.max(...nums) + 1 : 1;
layout[nextNum] = { x:5, y:5, w:14, h:14, label:"" };
saveLayout();
render();
});
document.getElementById('resetBtn').addEventListener('click', ()=>{
if(!confirm('초기 배치로 되돌릴까요?')) return;
layout = JSON.parse(JSON.stringify(DEFAULTS));
saveLayout();
render();
});
document.getElementById('exportBtn').addEventListener('click', ()=>{
const out = document.getElementById('out');
const rounded = {};
Object.keys(layout).forEach(k=>{
const p = layout[k];
rounded[k] = {x:Math.round(p.x), y:Math.round(p.y), w:Math.round(p.w), h:Math.round(p.h), label:p.label||"", keywords:p.keywords||""};
});
out.textContent = JSON.stringify({boxes:rounded, lines:lines}, null, 2);
out.style.display = 'block';
});
// ---- line drawing ----
const lineActions = document.getElementById('lineActions');
const renameLineBtn = document.getElementById('renameLineBtn');
const deleteLineBtn = document.getElementById('deleteLineBtn');
let selectedIdx = null;
function renderLines(){
lineLayer.innerHTML = '';
lines.forEach((ln, idx)=>{
const g = document.createElementNS('http://www.w3.org/2000/svg','g');
const hit = document.createElementNS('http://www.w3.org/2000/svg','line');
hit.setAttribute('class','hitline');
hit.setAttribute('x1', ln.x1+'%'); hit.setAttribute('y1', ln.y1+'%');
hit.setAttribute('x2', ln.x2+'%'); hit.setAttribute('y2', ln.y2+'%');
const vis = document.createElementNS('http://www.w3.org/2000/svg','line');
vis.setAttribute('x1', ln.x1+'%'); vis.setAttribute('y1', ln.y1+'%');
vis.setAttribute('x2', ln.x2+'%'); vis.setAttribute('y2', ln.y2+'%');
if(selectedIdx === idx) vis.classList.add('selected');
g.appendChild(vis);
g.appendChild(hit);
if(ln.label){
const midX = (ln.x1+ln.x2)/2, midY = (ln.y1+ln.y2)/2;
const text = document.createElementNS('http://www.w3.org/2000/svg','text');
text.setAttribute('x', midX+'%'); text.setAttribute('y', (midY-1)+'%');
text.setAttribute('text-anchor','middle');
text.textContent = ln.label;
g.appendChild(text);
}
hit.addEventListener('pointerdown', (e)=>{
e.stopPropagation();
selectedIdx = idx;
renderLines();
showLineActions(ln);
});
lineLayer.appendChild(g);
});
if(selectedIdx === null || selectedIdx >= lines.length){
lineActions.style.display = 'none';
}
}
function showLineActions(ln){
const rect = floorInnerEl.getBoundingClientRect();
const midX = (ln.x1+ln.x2)/2, midY = (ln.y1+ln.y2)/2;
lineActions.style.left = midX + '%';
lineActions.style.top = 'calc(' + midY + '% - 8px)';
lineActions.style.display = 'flex';
}
renameLineBtn.addEventListener('click', ()=>{
if(selectedIdx === null) return;
const ln = lines[selectedIdx];
const newLabel = prompt('선 이름', ln.label || '');
if(newLabel !== null){
ln.label = newLabel.trim();
saveLines();
renderLines();
showLineActions(ln);
}
});
deleteLineBtn.addEventListener('click', ()=>{
if(selectedIdx === null) return;
lines.splice(selectedIdx, 1);
selectedIdx = null;
saveLines();
renderLines();
});
document.getElementById('clearLinesBtn').addEventListener('click', ()=>{
if(!confirm('그려둔 선을 전부 지울까요?')) return;
lines = [];
selectedIdx = null;
saveLines();
renderLines();
});
boxLayer.addEventListener('pointerdown', ()=>{
if(selectedIdx !== null){ selectedIdx = null; renderLines(); }
});
renderLines();
const lineModeBtn = document.getElementById('lineModeBtn');
let lineMode = false;
lineModeBtn.addEventListener('click', ()=>{
lineMode = !lineMode;
floorEl.classList.toggle('line-mode', lineMode);
lineModeBtn.textContent = '선 그리기: ' + (lineMode ? '켜짐' : '꺼짐');
selectedIdx = null;
renderLines();
});
let drawing = null;
lineLayer.addEventListener('pointerdown', (e)=>{
if(!lineMode) return;
if(e.target.closest('.hitline')) return; // handled above, selects instead
selectedIdx = null;
lineActions.style.display = 'none';
const rect = floorInnerEl.getBoundingClientRect();
const x1 = (e.clientX - rect.left) / rect.width * 100;
const y1 = (e.clientY - rect.top) / rect.height * 100;
drawing = { x1, y1, x2:x1, y2:y1, label:'' };
lines.push(drawing);
renderLines();
lineLayer.setPointerCapture(e.pointerId);
function onMove(ev){
const rect2 = floorInnerEl.getBoundingClientRect();
drawing.x2 = (ev.clientX - rect2.left) / rect2.width * 100;
drawing.y2 = (ev.clientY - rect2.top) / rect2.height * 100;
renderLines();
}
function onUp(){
lineLayer.releasePointerCapture(e.pointerId);
lineLayer.removeEventListener('pointermove', onMove);
lineLayer.removeEventListener('pointerup', onUp);
const label = prompt('선 이름 (예: 입구, 외벽) — 취소하면 이름 없이 저장', '');
if(label !== null) drawing.label = label.trim();
saveLines();
renderLines();
drawing = null;
}
lineLayer.addEventListener('pointermove', onMove);
lineLayer.addEventListener('pointerup', onUp);
});
</script>
</body>
</html>