feat: 긴 종목명 글씨크기 자동맞춤(ellipsis 대신)

line1-held .stock 이 잘릴 만하면 폭 실측해 font-size를 0.5px씩 줄여 한 줄에 맞춤(min 10px).
MutationObserver는 행 추가(패널 swap)에만 반응하도록 필터 → 실시간 1초 갱신엔 재측정 안 함(레이아웃 부하 방지). resize도 재맞춤.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hyowons
2026-06-08 16:32:21 +09:00
parent aaea96ffe3
commit 0d9810f2b9
@@ -9077,6 +9077,25 @@ window.openPinModal = openPinModal;
})();</script>
<style>.rt-vi-badge{display:inline-block;margin-left:6px;padding:0 5px;border-radius:4px;font-size:10px;font-weight:700;color:#1a1205;background:#ffd166;vertical-align:middle}</style>'''
# 종목명 자동맞춤 — 길어서 잘릴 것 같으면 글씨를 줄여 한 줄에 맞춤(ellipsis 대신). 폭 실측 필요해 JS.
# 실시간 가격 갱신(1초)으로 재측정되면 레이아웃 부하 → MutationObserver는 '행 추가(패널 swap)'에만 반응하도록 필터.
stock_fit_script = r'''<script>(function(){
function fit(el){
el.style.fontSize=''; // 먼저 기본 크기로 복원(넓어지면 원복)
var min=10, size=parseFloat(getComputedStyle(el).fontSize)||14, guard=0;
while(el.scrollWidth>el.clientWidth+1 && size>min && guard++<14){ size-=0.5; el.style.fontSize=size+'px'; }
}
function fitAll(){ document.querySelectorAll('.line1-held .stock').forEach(fit); }
var t=null;
function schedule(){ if(t)clearTimeout(t); t=setTimeout(fitAll,80); }
function hasRow(n){ return n.nodeType===1 && ((n.matches&&n.matches('.line1-held'))||(n.querySelector&&n.querySelector('.line1-held .stock'))); }
new MutationObserver(function(ms){
for(var i=0;i<ms.length;i++){ var a=ms[i].addedNodes; for(var j=0;j<a.length;j++){ if(hasRow(a[j])){ schedule(); return; } } }
}).observe(document.body,{childList:true,subtree:true});
addEventListener('resize',schedule);
if(document.readyState!=='loading') schedule(); else addEventListener('DOMContentLoaded',schedule);
})();</script>'''
return f'''<!doctype html>
<html lang="ko">
<head>
@@ -9137,6 +9156,7 @@ window.openPinModal = openPinModal;
{order_modal_script}
{stock_name_tip_script}
{realtime_script}
{stock_fit_script}
</body>
</html>'''