미디어위키:Common.js: 두 판 사이의 차이

SKY's Kingshot
편집 요약 없음
편집 요약 없음
 
1번째 줄: 1번째 줄:
/* =======================================
/* =======================================
   영웅 스탯 비교 계산기 구동 로직 (한글판)
   1. 마우스 오른쪽 클릭 및 단축키 방지
  ======================================= */
document.addEventListener('contextmenu', function(e) {
    e.preventDefault();
});
 
document.addEventListener('keydown', function(e) {
    if (e.key === 'F12' || (e.ctrlKey && e.key === 'c') || (e.ctrlKey && e.shiftKey && e.key === 'I')) {
        e.preventDefault();
    }
});
 
/* =======================================
  2. 항상 떠 있는(플로팅) 구글 자동 번역기 (언어 확장판)
  ======================================= */
$(document).ready(function() {
    // 중복 생성 방지
    if(document.getElementById('google_translate_element')) return;
 
    // 번역기를 담을 박스 생성
    var translateDiv = document.createElement('div');
    translateDiv.id = 'google_translate_element';
   
    // CSS 스타일 (화면 우측 하단 고정, 게이밍 디자인)
    translateDiv.style.position = 'fixed';
    translateDiv.style.bottom = '20px';
    translateDiv.style.right = '20px';
    translateDiv.style.zIndex = '9999';
    translateDiv.style.backgroundColor = '#121215';
    translateDiv.style.border = '2px solid #FF8C00';
    translateDiv.style.borderRadius = '8px';
    translateDiv.style.padding = '5px 10px';
    translateDiv.style.boxShadow = '0 0 15px rgba(255,140,0,0.4)';
   
    // 화면에 추가
    document.body.appendChild(translateDiv);
 
    // 구글 번역 스크립트 불러오기
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = '//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit';
    document.head.appendChild(script);
});
 
// 구글 번역기 실행 함수 (언어 대폭 추가)
window.googleTranslateElementInit = function() {
    new google.translate.TranslateElement({
        pageLanguage: 'ko',
        includedLanguages: 'ko,en,zh-CN,zh-TW,ja,vi,ru,es,fr,de,th,id,ar,pt,tr,it,nl,pl,ms,tl,hi,uk,ro,hu,cs,sv,el,da,fi,no',
        layout: google.translate.TranslateElement.InlineLayout.SIMPLE,
        autoDisplay: false
    }, 'google_translate_element');
};
 
/* =======================================
  3. 영웅 스탯 비교 계산기 구동 로직 (한글판 + 리스트 출력형)
   ======================================= */
   ======================================= */
$(document).ready(function() {
$(document).ready(function() {
     // 현재 열린 페이지에 'HeroBox'가 없으면 작동하지 않음
     // 현재 열린 페이지에 'HeroBox'가 없으면 작동하지 않음 (다른 문서 속도 저하 방지)
     if ($('#HeroBox').length === 0) return;
     if ($('#HeroBox').length === 0) return;


76번째 줄: 131번째 줄:
         let hasHigher = false;
         let hasHigher = false;
         heroes.forEach(function(hero, index) {
         heroes.forEach(function(hero, index) {
            // 병종(type)이 같고, 뒷 세대인 영웅만 필터링
             if(hero.type === selectedHero.type && index > hero1Index) {
             if(hero.type === selectedHero.type && index > hero1Index) {
                 $hero2Select.append('<option value="' + index + '">[' + hero.type + '] ' + hero.name + '</option>');
                 $hero2Select.append('<option value="' + index + '">[' + hero.type + '] ' + hero.name + '</option>');

2026년 5월 16일 (토) 23:50 기준 최신판

/* =======================================
   1. 마우스 오른쪽 클릭 및 단축키 방지
   ======================================= */
document.addEventListener('contextmenu', function(e) {
    e.preventDefault();
});

document.addEventListener('keydown', function(e) {
    if (e.key === 'F12' || (e.ctrlKey && e.key === 'c') || (e.ctrlKey && e.shiftKey && e.key === 'I')) {
        e.preventDefault();
    }
});

/* =======================================
   2. 항상 떠 있는(플로팅) 구글 자동 번역기 (언어 확장판)
   ======================================= */
$(document).ready(function() {
    // 중복 생성 방지
    if(document.getElementById('google_translate_element')) return; 

    // 번역기를 담을 박스 생성
    var translateDiv = document.createElement('div');
    translateDiv.id = 'google_translate_element';
    
    // CSS 스타일 (화면 우측 하단 고정, 게이밍 디자인)
    translateDiv.style.position = 'fixed';
    translateDiv.style.bottom = '20px';
    translateDiv.style.right = '20px';
    translateDiv.style.zIndex = '9999';
    translateDiv.style.backgroundColor = '#121215';
    translateDiv.style.border = '2px solid #FF8C00';
    translateDiv.style.borderRadius = '8px';
    translateDiv.style.padding = '5px 10px';
    translateDiv.style.boxShadow = '0 0 15px rgba(255,140,0,0.4)';
    
    // 화면에 추가
    document.body.appendChild(translateDiv);

    // 구글 번역 스크립트 불러오기
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = '//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit';
    document.head.appendChild(script);
});

// 구글 번역기 실행 함수 (언어 대폭 추가)
window.googleTranslateElementInit = function() {
    new google.translate.TranslateElement({
        pageLanguage: 'ko', 
        includedLanguages: 'ko,en,zh-CN,zh-TW,ja,vi,ru,es,fr,de,th,id,ar,pt,tr,it,nl,pl,ms,tl,hi,uk,ro,hu,cs,sv,el,da,fi,no',
        layout: google.translate.TranslateElement.InlineLayout.SIMPLE,
        autoDisplay: false
    }, 'google_translate_element');
};

/* =======================================
   3. 영웅 스탯 비교 계산기 구동 로직 (한글판 + 리스트 출력형)
   ======================================= */
$(document).ready(function() {
    // 현재 열린 페이지에 'HeroBox'가 없으면 작동하지 않음 (다른 문서 속도 저하 방지)
    if ($('#HeroBox').length === 0) return;

    // 한글화된 레벨/성급 데이터
    const levelNames = [
        "0성 (T0)","0성 (T1)","0성 (T2)","0성 (T3)","0성 (T4)","0성 (T5)",
        "1성 (T0)","1성 (T1)","1성 (T2)","1성 (T3)","1성 (T4)","1성 (T5)",
        "2성 (T0)","2성 (T1)","2성 (T2)","2성 (T3)","2성 (T4)","2성 (T5)",
        "3성 (T0)","3성 (T1)","3성 (T2)","3성 (T3)","3성 (T4)","3성 (T5)",
        "4성 (T0)","4성 (T1)","4성 (T2)","4성 (T3)","4성 (T4)","4성 (T5)","최대 레벨(Max)"
    ];

    // 한글화된 영웅 데이터 (이름 및 병종 번역)
    const heroes = [
        {"name": "올리브", "type": "궁병", "stats": [11.36, 12.42, 13.47, 14.53, 15.59, 16.65, 18.55, 20.03, 21.51, 22.99, 24.47, 25.95, 28.62, 30.69, 32.76, 34.83, 36.9, 38.98, 42.71, 45.61, 48.51, 51.41, 54.31, 57.22, 62.44, 66.5, 70.56, 74.63, 78.69, 82.75, 90.07], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/olive-avatar.webp"},
        {"name": "포레스트", "type": "보병", "stats": [11.36, 12.42, 13.47, 14.53, 15.59, 16.65, 18.55, 20.03, 21.51, 22.99, 24.47, 25.95, 28.62, 30.69, 32.76, 34.83, 36.9, 38.98, 42.71, 45.61, 48.51, 51.41, 54.31, 57.22, 62.44, 66.5, 70.56, 74.63, 78.69, 82.75, 90.07], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/forrest-avatar.webp"},
        {"name": "에드윈", "type": "기병", "stats": [11.36, 12.42, 13.47, 14.53, 15.59, 16.65, 18.55, 20.03, 21.51, 22.99, 24.47, 25.95, 28.62, 30.69, 32.76, 34.83, 36.9, 38.98, 42.71, 45.61, 48.51, 51.41, 54.31, 57.22, 62.44, 66.5, 70.56, 74.63, 78.69, 82.75, 90.07], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/edwin-avatar.webp"},
        {"name": "세스", "type": "보병", "stats": [11.36, 12.42, 13.47, 14.53, 15.59, 16.65, 18.55, 20.03, 21.51, 22.99, 24.47, 25.95, 28.62, 30.69, 32.76, 34.83, 36.9, 38.98, 42.71, 45.61, 48.51, 51.41, 54.31, 57.22, 62.44, 66.5, 70.56, 74.63, 78.69, 82.75, 90.07], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/seth-avatar.webp"},
        {"name": "다이애나", "type": "궁병", "stats": [13.88, 15.18, 16.47, 17.76, 19.05, 20.35, 22.67, 24.48, 26.29, 28.1, 29.91, 31.72, 34.98, 37.51, 40.04, 42.58, 45.11, 47.64, 52.5, 55.75, 59.29, 62.84, 66.39, 69.93, 76.32, 81.28, 86.25, 91.21, 96.18, 101.15, 110.08], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/diana-avatar-icon.webp"},
        {"name": "퀸", "type": "궁병", "stats": [17.76, 19.32, 20.96, 22.61, 24.25, 25.9, 28.86, 31.16, 33.46, 35.77, 38.07, 40.37, 44.52, 47.74, 50.96, 54.19, 57.41, 60.64, 66.44, 70.95, 75.46, 79.98, 84.49, 89.01, 97.13, 103.45, 109.77, 116.09, 122.41, 128.73, 140.11], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/quinn-avatar.webp"},
        {"name": "첸코", "type": "기병", "stats": [17.76, 19.32, 20.96, 22.61, 24.25, 25.9, 28.86, 31.16, 33.46, 35.77, 38.07, 40.37, 44.52, 47.74, 50.96, 54.19, 57.41, 60.64, 66.44, 70.95, 75.46, 79.98, 84.49, 89.01, 97.13, 103.45, 109.77, 116.09, 122.41, 128.73, 140.11], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/chenko-avatar.webp"},
        {"name": "하워드", "type": "보병", "stats": [17.76, 19.32, 20.96, 22.61, 24.25, 25.9, 28.86, 31.16, 33.46, 35.77, 38.07, 40.37, 44.52, 47.74, 50.96, 54.19, 57.41, 60.64, 66.44, 70.95, 75.46, 79.98, 84.49, 89.01, 97.13, 103.45, 109.77, 116.09, 122.41, 128.73, 140.11], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/howard-avatar.webp"},
        {"name": "고든", "type": "기병", "stats": [17.76, 19.32, 20.96, 22.61, 24.25, 25.9, 28.86, 31.16, 33.46, 35.77, 38.07, 40.37, 44.52, 47.74, 50.96, 54.19, 57.41, 60.64, 66.44, 70.95, 75.46, 79.98, 84.49, 89.01, 97.13, 103.45, 109.77, 116.09, 122.41, 128.73, 140.11], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/gordon-avatar.webp"},
        {"name": "파드", "type": "기병", "stats": [17.76, 19.32, 20.96, 22.61, 24.25, 25.9, 28.86, 31.16, 33.46, 35.77, 38.07, 40.37, 44.52, 47.74, 50.96, 54.19, 57.41, 60.64, 66.44, 70.95, 75.46, 79.98, 84.49, 89.01, 97.13, 103.45, 109.77, 116.09, 122.41, 128.73, 140.11], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/fahd-avatar.webp"},
        {"name": "아마네", "type": "궁병", "stats": [17.76, 19.32, 20.96, 22.61, 24.25, 25.9, 28.86, 31.16, 33.46, 35.77, 38.07, 40.37, 44.52, 47.74, 50.96, 54.19, 57.41, 60.64, 66.44, 70.95, 75.46, 79.98, 84.49, 89.01, 97.13, 103.45, 109.77, 116.09, 122.41, 128.73, 140.11], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/amane-avatar.webp"},
        {"name": "연우", "type": "궁병", "stats": [17.76, 19.32, 20.96, 22.61, 24.25, 25.9, 28.86, 31.16, 33.46, 35.77, 38.07, 40.37, 44.52, 47.74, 50.96, 54.19, 57.41, 60.64, 66.44, 70.95, 75.46, 79.98, 84.49, 89.01, 97.13, 103.45, 109.77, 116.09, 122.41, 128.73, 140.11], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/yeonwoo-avatar.webp"},
        {"name": "자벨", "type": "기병", "stats": [25.25, 27.6, 29.95, 32.3, 34.65, 37, 41.23, 44.52, 47.81, 51.1, 54.39, 57.68, 63.6, 68.2, 72.81, 77.42, 82.02, 86.63, 94.92, 101.37, 107.81, 114.26, 120.71, 127.16, 138.77, 147.79, 156.82, 165.85, 174.88, 183.91, 200.16], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/jabel.webp"},
        {"name": "사울", "type": "궁병", "stats": [25.25, 27.6, 29.95, 32.3, 34.65, 37, 41.23, 44.52, 47.81, 51.1, 54.39, 57.68, 63.6, 68.2, 72.81, 77.42, 82.02, 86.63, 94.92, 101.37, 107.81, 114.26, 120.71, 127.16, 138.77, 147.79, 156.82, 165.85, 174.88, 183.91, 200.16], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/saul-kingshot.webp"},
        {"name": "헬가", "type": "보병", "stats": [25.25, 27.6, 29.95, 32.3, 34.65, 37, 41.23, 44.52, 47.81, 51.1, 54.39, 57.68, 63.6, 68.2, 72.81, 77.42, 82.02, 86.63, 94.92, 101.37, 107.81, 114.26, 120.71, 127.16, 138.77, 147.79, 156.82, 165.85, 174.88, 183.91, 200.16], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/helga-kingshot.webp"},
        {"name": "아마데우스", "type": "보병", "stats": [32.82, 35.88, 38.93, 41.99, 45.04, 48.1, 53.59, 57.87, 62.15, 66.43, 70.7, 74.98, 82.68, 88.66, 94.65, 100.64, 106.62, 112.61, 123.39, 131.78, 140.15, 148.53, 156.92, 165.3, 180.4, 192.12, 203.86, 215.6, 227.34, 239.08, 260.2], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/amadeus.webp"},
        {"name": "조이", "type": "보병", "stats": [30.3, 33.12, 35.94, 38.76, 41.58, 44.4, 49.47, 53.42, 57.37, 61.32, 65.26, 69.21, 76.32, 81.84, 87.37, 92.9, 98.42, 103.95, 113.9, 121.64, 129.37, 137.11, 144.85, 152.59, 166.52, 177.34, 188.18, 192.02, 209.85, 220.69, 240.1], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/zoe-gen2-kingshot.webp"},
        {"name": "힐데", "type": "기병", "stats": [30.3, 33.12, 35.94, 38.76, 41.58, 44.4, 49.47, 53.42, 57.37, 61.32, 65.26, 69.21, 76.32, 81.84, 87.37, 92.9, 98.42, 103.95, 113.9, 121.64, 129.37, 137.11, 144.85, 152.59, 166.52, 177.34, 188.18, 192.02, 209.85, 220.69, 240.1], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/hilde-kingshot.webp"},
        {"name": "마를린", "type": "궁병", "stats": [30.3, 33.12, 35.94, 38.76, 41.58, 44.4, 49.47, 53.42, 57.37, 61.32, 65.26, 69.21, 76.32, 81.84, 87.37, 92.9, 98.42, 103.95, 113.9, 121.64, 129.37, 137.11, 144.85, 152.59, 166.52, 177.34, 188.18, 192.02, 209.85, 220.69, 240.1], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/marlin-kingshot.webp"},
        {"name": "에릭", "type": "보병", "stats": [36.61, 40.02, 43.42, 46.83, 50.24, 53.65, 59.78, 64.55, 69.32, 74.09, 78.86, 83.63, 92.22, 98.89, 105.57, 112.25, 118.92, 125.61, 137.63, 146.98, 156.32, 165.67, 175.02, 184.38, 201.21, 214.29, 227.38, 240.48, 253.57, 266.66, 290.23], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/eric-avatar-icon.webp"},
        {"name": "예거", "type": "궁병", "stats": [36.61, 40.02, 43.42, 46.83, 50.24, 53.65, 59.78, 64.55, 69.32, 74.09, 78.86, 83.63, 92.22, 98.89, 105.57, 112.25, 118.92, 125.61, 137.63, 146.98, 156.32, 165.67, 175.02, 184.38, 201.21, 214.29, 227.38, 240.48, 253.57, 266.66, 290.23], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/jaeger-icon-kingshot.webp"},
        {"name": "페트라", "type": "기병", "stats": [36.61, 40.02, 43.42, 46.83, 50.24, 53.65, 59.78, 64.55, 69.32, 74.09, 78.86, 83.63, 92.22, 98.89, 105.57, 112.25, 118.92, 125.61, 137.63, 146.98, 156.32, 165.67, 175.02, 184.38, 201.21, 214.29, 227.38, 240.48, 253.57, 266.66, 290.23], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/07/petra-avatar-icon.webp"},
        {"name": "알카르", "type": "보병", "stats": [46.71, 51.06, 55.4, 59.75, 64.1, 68.45, 76.27, 82.36, 88.44, 94.53, 100.62, 106.7, 117.66, 126.17, 134.69, 143.22, 151.73, 160.26, 175.6, 187.53, 199.44, 211.38, 223.31, 235.24, 256.72, 273.41, 290.11, 306.82, 323.52, 340.23, 370.29], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/09/alcar-avatar-image.webp"},
        {"name": "로사", "type": "궁병", "stats": [46.71, 51.06, 55.4, 59.75, 64.1, 68.45, 76.27, 82.36, 88.44, 94.53, 100.62, 106.7, 117.66, 126.17, 134.69, 143.22, 151.73, 160.26, 175.6, 187.53, 199.44, 211.38, 223.31, 235.24, 256.72, 273.41, 290.11, 306.82, 323.52, 340.23, 370.29], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/09/rosa-avatar-image.webp"},
        {"name": "마고", "type": "기병", "stats": [46.71, 51.06, 55.4, 59.75, 64.1, 68.45, 76.27, 82.36, 88.44, 94.53, 100.62, 106.7, 117.66, 126.17, 134.69, 143.22, 151.73, 160.26, 175.6, 187.53, 199.44, 211.38, 223.31, 235.24, 256.72, 273.41, 290.11, 306.82, 323.52, 340.23, 370.29], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/09/margot-avatar.webp"},
        {"name": "롱페이", "type": "보병", "stats": [56.05, 61.27, 66.48, 71.7, 76.92, 82.14, 91.53, 98.83, 106.13, 113.44, 120.74, 128.04, 141.19, 151.4, 161.63, 171.87, 182.08, 192.31, 210.72, 225.04, 239.33, 253.65, 267.97, 282.29, 308.06, 328.09, 348.14, 368.18, 388.23, 408.28, 444.35], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/12/long-fei-avatar-icon.webp"},
        {"name": "비비안", "type": "궁병", "stats": [56.05, 61.27, 66.48, 71.7, 76.92, 82.14, 91.53, 98.83, 106.13, 113.44, 120.74, 128.04, 141.19, 151.4, 161.63, 171.87, 182.08, 192.31, 210.72, 225.04, 239.33, 253.65, 267.97, 282.29, 308.06, 328.09, 348.14, 368.18, 388.23, 408.28, 444.35], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/12/vivian-avatar-icon.webp"},
        {"name": "트루드", "type": "기병", "stats": [56.05, 61.27, 66.48, 71.7, 76.92, 82.14, 91.53, 98.83, 106.13, 113.44, 120.74, 128.04, 141.19, 151.4, 161.63, 171.87, 182.08, 192.31, 210.72, 225.04, 239.33, 253.65, 267.97, 282.29, 308.06, 328.09, 348.14, 368.18, 388.23, 408.28, 444.35], "image": "https://kingshotcalculator.com/wp-content/uploads/2025/12/thrud-avatar-icon.webp"},
        {"name": "트리톤", "type": "보병", "stats": [68.17, 74.52, 80.86, 87.21, 93.55, 99.9, 111.32, 120.2, 129.08, 137.97, 146.85, 155.73, 171.72, 184.14, 196.58, 209.03, 221.45, 233.9, 256.28, 273.69, 291.08, 308.5, 325.91, 343.33, 374.67, 399.03, 423.41, 447.79, 472.17, 496.55, 540.43], "image": "https://kingshotcalculator.com/wp-content/uploads/2026/03/triton-avatar-icon.webp"},
        {"name": "양", "type": "궁병", "stats": [68.17, 74.52, 80.86, 87.21, 93.55, 99.9, 111.32, 120.2, 129.08, 137.97, 146.85, 155.73, 171.72, 184.14, 196.58, 209.03, 221.45, 233.9, 256.28, 273.69, 291.08, 308.5, 325.91, 343.33, 374.67, 399.03, 423.41, 447.79, 472.17, 496.55, 540.43], "image": "https://kingshotcalculator.com/wp-content/uploads/2026/03/yang-avatar-icon.webp"},
        {"name": "소피아", "type": "기병", "stats": [68.17, 74.52, 80.86, 87.21, 93.55, 99.9, 111.32, 120.2, 129.08, 137.97, 146.85, 155.73, 171.72, 184.14, 196.58, 209.03, 221.45, 233.9, 256.28, 273.69, 291.08, 308.5, 325.91, 343.33, 374.67, 399.03, 423.41, 447.79, 472.17, 496.55, 540.43], "image": "https://kingshotcalculator.com/wp-content/uploads/2026/03/sophia-avatar-icon.webp"}
    ];

    function populateDropdowns() {
        const $levelSelect = $('#levelSelect');
        const $hero1Select = $('#hero1Select');
        
        levelNames.forEach(function(name, index) {
            $levelSelect.append('<option value="' + index + '">' + name + '</option>');
        });
        $levelSelect.val(30);

        heroes.forEach(function(hero, index) {
            $hero1Select.append('<option value="' + index + '">[' + hero.type + '] ' + hero.name + '</option>');
        });

        updateHero1Selection();
    }

    function updateHero1Selection() {
        const hero1Index = parseInt($('#hero1Select').val(), 10);
        const $hero2Select = $('#hero2Select');
        const selectedHero = heroes[hero1Index];
        
        $('#hero1Image').attr('src', selectedHero.image);
        $hero2Select.empty();
        
        let hasHigher = false;
        heroes.forEach(function(hero, index) {
            if(hero.type === selectedHero.type && index > hero1Index) {
                $hero2Select.append('<option value="' + index + '">[' + hero.type + '] ' + hero.name + '</option>');
                hasHigher = true;
            }
        });

        if(!hasHigher) {
            $hero2Select.append('<option value="">상위 영웅 없음</option>');
            $('#hero2Image').attr('src', 'https://via.placeholder.com/80/333333/ffffff?text=None');
        } else {
            updateHeroImage('hero2');
        }
    }

    function updateHeroImage(type) {
        if(type === 'hero2') {
            const h2Index = $('#hero2Select').val();
            if(h2Index !== "") {
                $('#hero2Image').attr('src', heroes[h2Index].image);
            }
        }
    }

    function compareHeroes() {
        const levelIdx = parseInt($('#levelSelect').val(), 10);
        const h1Idx = parseInt($('#hero1Select').val(), 10);
        const h2Idx = $('#hero2Select').val();
        const $resBox = $('#results');

        if(h2Idx === "") {
            $resBox.show().css({'color': '#ff4444', 'border-color': '#ff4444'})
                   .html("❌ 비교할 상위 세대 영웅이 없습니다.");
            return;
        }

        const hero1 = heroes[h1Idx];
        const hero2 = heroes[h2Idx];
        const stat1 = hero1.stats[levelIdx];

        let html = `<div style="font-size: 15px; margin-bottom: 15px; color: #fff;"><b>${hero1.name}</b>의 <b>${levelNames[levelIdx]}</b> 스탯은 <span style="color:#00ff00;">+${stat1}%</span> 입니다.</div>`;
        html += `<div style="font-size: 14px; color: #ffaa00; margin-bottom: 10px; border-bottom: 1px solid #555; padding-bottom: 5px; text-align: left;">⚔️ <b>${hero2.name}</b>(이)가 더 강력해지는 교체 타이밍:</div>`;
        html += `<ul style="text-align: left; font-size: 13px; color: #ccc; line-height: 1.8; margin-top: 10px; padding-left: 20px;">`;

        let found = false;
        for(let i = 0; i < hero2.stats.length; i++) {
            if(hero2.stats[i] > stat1) {
                html += `<li><b>${levelNames[i]}</b> (스탯: +${hero2.stats[i]}%)</li>`;
                found = true;
            }
        }

        if(!found) {
            html += `<li style="color:#ff4444; list-style:none; margin-left:-20px;">❌ 모든 구간에서 현재 영웅이 더 강력합니다.</li>`;
        }
        
        html += `</ul>`;

        $resBox.css({
            'color': '#d1d5db', 
            'border-color': '#555', 
            'background-color': '#111',
            'padding': '20px'
        }).html(html).show();
    }

    $('#hero1Select').on('change', updateHero1Selection);
    $('#hero2Select').on('change', function() { updateHeroImage('hero2'); });
    $('#runCalcBtn').on('click', compareHeroes);

    populateDropdowns();
});