You are not logged in.
Pages: 1
[설명]
- 아이콘 획득 이벤트
- API 데이터 연동 (노출 상태)
(function($){ if(typeof renewalEventFnc == 'undefined') renewalEventFnc = { eventData : {}, eventApply : {}, iconLayer : null, eventGet : function() { $.getJSON('getIconEventInfo.aspx?userid=' + (renewalEventFnc.getCookie('Joins_MemID') ? renewalEventFnc.getCookie('Joins_MemID') : renewalEventFnc.getCookie('JCUBE_SOCIAL_ID')) +'&type=' + (renewalEventFnc.getCookie('JCUBE_SOCIAL_TYPE') ? renewalEventFnc.getCookie('JCUBE_SOCIAL_TYPE') : 'joins' ), function (data) { //console.log(data); $.each(data, function(key, val) { //console.log('done():data ', key, val); renewalEventFnc.eventData[key] = val; }); }).success(function() { //console.log('success', renewalEventFnc.eventData); if($('.event-custom').length == 0) { $('head').append('<link rel="stylesheet" href="http://static.jtbc.joins.com/jtbc/ui/css/event/renewal/' + (!renewalEventFnc.isMobile() ? 'icon' : 'icon_m' ) + '.css" type="text/css" />'); $('body').append('<div class="event-custom"></div>').promise().done(function() { renewalEventFnc.iconLayer = $('body').find('.event-custom'); renewalEventFnc.eventLayer(); }); } else { renewalEventFnc.iconLayer = $('body').find('.event-custom'); renewalEventFnc.eventLayer(); } }).fail(function(message) { //console.log('fail', message); }); return; },//eventGet eventLayer : function() { var _iconLayer = '<!-- icon layer -->'; _iconLayer += '<div id="renewal-icon-id" class="renewal-icon-wrap icon'+ (Math.floor(Math.random() * 4) + 1) +'" style="display:block;">'; if(!!renewalEventFnc.eventData.data && renewalEventFnc.eventData.data.display == 'J') { _iconLayer += ' <div class="icon-con j">'; _iconLayer += ' <a href="#"><img src="http://images.jtbc.joins.com/ui_jtbc/2016/renewal/icon_catch_j.png" alt="J"></a>'; _iconLayer += ' <a class="icon-close" title="닫기"><img src="http://images.jtbc.joins.com/ui_jtbc/2016/renewal/icon_j_x.png" alt="닫기"></a>'; _iconLayer += ' </div>'; } if(!!renewalEventFnc.eventData.data && renewalEventFnc.eventData.data.display == 'T') { _iconLayer += ' <div class="icon-con t">'; _iconLayer += ' <a href="#"><img src="http://images.jtbc.joins.com/ui_jtbc/2016/renewal/icon_catch_t.png" alt="T"></a>'; _iconLayer += ' <a class="icon-close" title="닫기"><img src="http://images.jtbc.joins.com/ui_jtbc/2016/renewal/icon_t_x.png" alt="닫기"></a>'; _iconLayer += ' </div>'; } if(!!renewalEventFnc.eventData.data && renewalEventFnc.eventData.data.display == 'B') { _iconLayer += ' <div class="icon-con b">'; _iconLayer += ' <a href="#"><img src="http://images.jtbc.joins.com/ui_jtbc/2016/renewal/icon_catch_b.png" alt="B"></a>'; _iconLayer += ' <a class="icon-close" title="닫기"><img src="http://images.jtbc.joins.com/ui_jtbc/2016/renewal/icon_b_x.png" alt="닫기"></a>'; _iconLayer += ' </div>'; } if(!!renewalEventFnc.eventData.data && renewalEventFnc.eventData.data.display == 'C') { _iconLayer += ' <div class="icon-con c">'; _iconLayer += ' <a href="#"><img src="http://images.jtbc.joins.com/ui_jtbc/2016/renewal/icon_catch_c.png" alt="C"></a>'; _iconLayer += ' <a class="icon-close" title="닫기"><img src="http://images.jtbc.joins.com/ui_jtbc/2016/renewal/icon_c_x.png" alt="닫기"></a>'; _iconLayer += ' </div>'; } if(!!renewalEventFnc.eventData.data && renewalEventFnc.eventData.data.display == 'N') { _iconLayer += ' <div class="icon-con h">'; _iconLayer += ' <a href="#"><img src="http://images.jtbc.joins.com/ui_jtbc/2016/renewal/icon_catch_heart.png" alt="5TH"></a>'; _iconLayer += ' <a class="icon-close" title="닫기"><img src="http://images.jtbc.joins.com/ui_jtbc/2016/renewal/icon_heart_x.png" alt="닫기"></a>'; _iconLayer += ' </div>'; _iconLayer += '</div>'; } _iconLayer += '<!-- //icon layer -->'; renewalEventFnc.iconLayer.append(_iconLayer).promise().done(function() { $('#renewal-icon-id .icon-con .icon-close').bind('click', function() { $(this).parents('#renewal-icon-id').hide(0); return false; }); $('#renewal-icon-id .icon-con').bind('click', function() { $(this).parents('#renewal-icon-id').hide(0); $.getJSON('http://jtbc5th.jtbc.joins.com/api/applyIconEvent.aspx?key=' + renewalEventFnc.eventData.data.key, function (data) { //console.log(data); $.each(data, function(key, val) { //console.log('done():data ', key, val); renewalEventFnc.eventApply[key] = val; }); }).success(function() { //console.log('success', renewalEventFnc.eventApply); var _popupLayer = '<div id="popup-awards-id" class="popup-awards" style="display:none;">'; _popupLayer += ' <div class="popup-con">'; _popupLayer += ' <h4>내가 찾은 아이콘 확인하기</h4>'; _popupLayer += ' <a href="" class="popup-close" title="닫기"><img src="http://images.jtbc.joins.com/ui_jtbc/2016/awards/close.png" alt="닫기"></a>'; _popupLayer += ' <div class="popup-contents">'; _popupLayer += ' <ul class="enter-list">'; _popupLayer += ' <!-- on이 없는경우 회색 아이콘으로 됩니다 -->'; _popupLayer += ' <li class="icon-j '+ (renewalEventFnc.eventApply.data.icon_j == 'Y' ? 'on' : '') +'">icon J<img src="http://images.jtbc.joins.com/ui_jtbc/2016/awards/icon_space.png" alt="J"></li>'; _popupLayer += ' <li class="icon-t '+ (renewalEventFnc.eventApply.data.icon_t == 'Y' ? 'on' : '') +'">icon T<img src="http://images.jtbc.joins.com/ui_jtbc/2016/awards/icon_space.png" alt="T"></li>'; _popupLayer += ' <li class="icon-b '+ (renewalEventFnc.eventApply.data.icon_b == 'Y' ? 'on' : '') +'">icon B<img src="http://images.jtbc.joins.com/ui_jtbc/2016/awards/icon_space.png" alt="B"></li>'; _popupLayer += ' <li class="icon-c '+ (renewalEventFnc.eventApply.data.icon_c == 'Y' ? 'on' : '') +'">icon C<img src="http://images.jtbc.joins.com/ui_jtbc/2016/awards/icon_space.png" alt="C"></li>'; _popupLayer += ' <li class="icon-5 '+ (renewalEventFnc.eventApply.data.icon_n == 'Y' ? 'on' : '') +'">icon 5th<img src="http://images.jtbc.joins.com/ui_jtbc/2016/awards/icon_space.png" alt="5TH"></li>'; _popupLayer += ' </ul>'; _popupLayer += ' <p>'+ renewalEventFnc.eventApply.message +'</p>'; _popupLayer += ' <div class="btn-popup">'; _popupLayer += ' <a href="#" class="renewal-confirm" title="확인">확인</a>'; _popupLayer += ' <a href="#" class="renewal-num" title="나의 응모횟수">나의 응모횟수</a>'; _popupLayer += ' </div>'; _popupLayer += ' </div>'; _popupLayer += ' </div>'; _popupLayer += '</div>'; renewalEventFnc.iconLayer.remove('#popup-awards-id').append(_popupLayer).promise().done(function() { $('#popup-awards-id .btn-popup .renewal-confirm').bind('click', function() { $(this).parents('#popup-awards-id').hide(); return false; }); $('#popup-awards-id .btn-popup .renewal-num').bind('click', function() { window.open(renewalEventFnc.eventApply.link); return false; }); $('#popup-awards-id').show(0); }); }).fail(function(message) { //console.log('fail', message); }); return false; }); }); }, isMobile : function() { return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); }, getCookie : function (cname) {//쿠키 값 var name = cname + "="; var ca = document.cookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; }//쿠키 값 }//renewalEventFnc renewalEventFnc.eventGet(); })(jQuery);
Offline
Pages: 1