console.log('namecard_common.js loaded');
$(()=>{
    $('#name,#group_names,#cid_no,#mobile_no').text('');
    $('#description').empty();
    const params = new URLSearchParams(window.location.search);
    params.forEach((value, key) => {
        try {
            if(key == 'description') {
                let desc = params.get('description').split(',');
                desc.forEach(item =>{
                    if(item.trim() != '' ){
                        $('#description').append(`<p>${item}</p>`);
                    }
                });
                if(desc.length < 3){
                    for(let i = 0;i<(3-desc.length);i++){
                        $('#description').append(`<p></p>`);
                    }
                }
            }else{
                if(key == 'group_names'){
                    value = value.replace(/@@/g,'/');
                }
                $(`#${key}`).html(value);
            }
        } catch (error) {
            console.log(error);
        }
    });


    $('a.close').on('click', function(){
        Native.hiddenPopupProfile();
    });


    const height = document.body.scrollHeight+10;
    let namecard = location.href;
    window.parent.postMessage({namecard : namecard, iframeHeight: height }, '*');  // '*'은 모든 도메인 허용

    $(document).on('click',(e)=>{
        window.parent.postMessage({namecard : namecard, clickEvent: true }, '*');  // '*'은 모든 도메인 허용
    });

});