// widget.js
(function($, window, document) {
var WIDGET_INFO = {
Ad: {key: 'Ad', fn: 'loadAd'},
DepartmentSns: {key: 'DepartmentSns', fn: 'widgetDepartmentSns'}, // 부서별 SNS
HotArticles: {key: 'HotArticles', fn: 'widgetHotArticles'}, // 많이 본 기사
HotArticlesOrderByReplyCount: {key: 'HotArticlesOrderByReplyCount', fn: 'widgetHotArticlesOrderByReplyCount'}, // 댓글 많은 기사
HotIssues: {key: 'HotIssues', fn: 'widgetHotIssues'}, // 핫 이슈
HotJPlus: {key: 'HotJPlus', fn: 'widgetHotJPlus'}, // 인기 J플러스
HotJPlusOrderByReplyCount: {key: 'HotJPlusOrderByReplyCount', fn: 'widgetHotArticlesOrderByReplyCount'}, // 댓글 많은 수 인기 J플러스
HotVideos: {key: 'HotVideos', fn: 'widgetHotVideos'}, // 많이 본 동영상
JoongangIssue: {key: 'JoongangIssue', fn: 'widgetJoongangIssue'}, // 중앙 연재
Link: {key: 'Link', fn: 'widgetLink'}, // 링크
MoneyIndicator: {key: 'MoneyIndicator', fn: 'widgetMoneyIndicator'}, // 경제 지표
PhotoIssues: {key: 'PhotoIssues', fn: 'widgetPhotoIssues'}, // 포토 이슈
RecommendedIssues: {key: 'RecommendedIssues', fn: 'widgetRecommendedIssues'}, // 추천 연재
RelatedKeyword: {key: 'RelatedKeyword', fn: 'widgetRelatedKeyword'}, // 관련 키워드
RecommendedArticle: {key: 'RecommendedArticle', fn: 'widgetRecommendedArticle'}, // 추천 기사
RecommendedArticleForWide: {key: 'RecommendedArticleForWide', fn: 'widgetRecommendedArticleForWide'}, // 추천 기사 (와이드)
OpinionCast: {key: 'OpinionCast', fn: 'widgetOpinionCast'}, // 오피니언 방송 (최신기사3건)
PortalSearchKeyword: {key: 'PortalSearchKeyword', fn: 'widgetPortalSearchKeyword'}, // 포탈 실시간 검색어
SnsArticle: {key: 'SnsArticle', fn: 'widgetSnsArticle'}, // SNS 뉴스
MajorArticle: {key: 'MajorArticle', fn: 'widgetMajorArticle'}, // 주요 뉴스
FastNews: {key: 'FastNews', fn: 'widgetFastNews'}, // 지면보다 빠른 뉴스
TrendArticle: {key: 'TrendArticle', fn: 'widgetTrendArticle'}, // 추천 기사
ReporterQnA: {key: 'ReporterQnA', fn: 'widgetReporterQnA'}, // 기자 Q&A
PoemOneLine: { key: 'PoemOneLine', fn: 'widgetPoemOneLine' }, // 나를 흔든 시 한 줄
MorningPoem: { key: 'MorningPoem', fn: 'widgetMorningPoem' }, // 시가 있는 아침
DirectInterview: {key: 'DirectInterview', fn: 'widgetDirectInterview'}, // 직격 인터뷰
PopularReporter: {key: 'PopularReporter', fn: 'widgetPopularReporter'}, // 인기 기자
RetirementSelfTest: {key: 'RetirementSelfTest', fn: 'widgetRetirementSelfTest'}, // 퇴직 준비 셀프 테스트
TalkNk: {key: 'TalkNk', fn: 'widgetTalkNk'}, // TALK NK
VoiceOfAmerica: {key: 'VoiceOfAmerica', fn: 'widgetVoiceOfAmerica'}, // VoiceOfAmerica
WeeklyTravel: { key: 'WeeklyTravel', fn: 'widgetWeeklyTravel' }, // 금주의 Week&+
OpinionOnAir: { key: 'OpinionOnAir', fn: 'widgetOpinionOnAir' }, // 오피니언 온 에어(Wide)
ImcBanner: { key: 'ImcBanner', fn: 'widgetImcBanner' }, // Imc Banner
EditorialInsite: { key: 'EditorialInsite', fn: 'widgetEditorialInsite' }, // 사설 인사이트
SpecialCartoon: { key: 'SpecialCartoon', fn: 'widgetSpecialCartoon' }, // 디지털 스페셜 만평
SpecialColumnD: { key: 'SpecialColumnD', fn: 'widgetSpecialColumnD' }, // 스페셜 칼럼 D
SpecialCartoon: { key: 'SpecialCartoon', fn: 'widgetSpecialCartoon' }, // 디지털 스페셜 만평
DigitalOpinion: { key: 'DigitalOpinion', fn: 'widgetDigitalOpinion' } // 디지털 오피니언
};
var apiPath = utils.config('apiPath');
$.fn.widget = function () {
var $p = this;
$p.children().each(function (i, v) {
var $w = $(v),
type = $w.data('widgetType'),
service = $w.data('widgetService'),
category = $w.data('widgetCategory'),
fn = WIDGET_INFO[type] && WIDGET_INFO[type].fn;
if (type && typeof $.fn[fn] == 'function') {
$w[fn]({ type: service, category: category });
}
});
};
$.fn.wideWidget = function () {
var $p = this;
$p.children().each(function (i, v) {
var $w = $(v),
type = $w.data('widgetType'),
service = $w.data('widgetService'),
category = $w.data('widgetCategory'),
fn = WIDGET_INFO[type] && WIDGET_INFO[type].fn;
//utils.log($w);
//utils.log('## type : ' + type);
if (type != undefined) {
$w[fn]({ type: service, category: category });
}
});
};
$.fn.articleBottom = function () {
var $p = this;
//데이블
$('div.hot_click').hide();
$('div.hot_click_wrap', $p).widgetHotClickDable();
//핫클릭(중앙)
//$('div.hot_click_wrap').hide();
//$('div.hot_click', $p).widgetHotClick(); // 핫클릭
if (utils.getArticleSourceCode() == "b8") {
$('.ab_related', $p).widgetHotClickUSA(); // USA 핫클릭
}
$('>div.photo_video', $p).widgetPhotoVideo(); // PhotoVideo
$('>div.special_link', $p).widgetSpecialLink(); // widgetSpecialLink
$('>div.related_article', $p).widgetRelations(); //관련 태그 뉴스
//$('>div.shpping_life', $p).loadAd({ type: 'ad_article_shoppingbox_640_211' }); //쇼핑박스
//쇼핑박스
$('#shpping_life_1').loadAd({ type: 'ad_article_shoppingbox_1' });
$('#shpping_life_2').loadAd({ type: 'ad_article_shoppingbox_2' });
$('#shpping_life_3').loadAd({ type: 'ad_article_shoppingbox_3' });
// 아티클 바이라인 하단 광고
var randomNum = utils.getRandomNumber(1, 2);
switch (randomNum) {
case 1:
$('#ab_adtxt_lt').loadAd({ type: 'ab_adtxt_lt_1' });
$('#ab_adtxt_lt').loadAd({ type: 'ab_adtxt_lt_2' });
break;
case 2:
$('#ab_adtxt_lt').loadAd({ type: 'ab_adtxt_lt_2' });
$('#ab_adtxt_lt').loadAd({ type: 'ab_adtxt_lt_1' });
break;
default:
$('#ab_adtxt_lt').loadAd({ type: 'ab_adtxt_lt_1' });
$('#ab_adtxt_lt').loadAd({ type: 'ab_adtxt_lt_2' });
break;
}
$('#ab_adtxt_lt').loadAd({ type: 'ab_adtxt_lt_3' });
$('#ab_adtxt_lt').loadAd({ type: 'ab_adtxt_lt_4' });
$('#ab_adtxt_rt').loadAd({ type: 'ab_adtxt_rt' });
};
$.fn.widgetWeeklyTravel = function() {
var $w = this,
widgetHtml = '
금주의 week&+
',
template = '' +
'' +
' ' +
' ' +
' ' +
' ',
directives = {
list: {
link: utils.decorators.link,
image: utils.decorators.image,
thumb: {
html: function(params) {
if(params.index != 0) {
$(params.element).remove();
}
}
}
}
};
getApiData('/static/traveloftheweek', render);
function render(res) {
var html = '', data = { list: [] };
try {
res.List.forEach(function (v) {
data.list.push(utils.models.getLinkFromApiArticle(v));
});
} catch (e) { utils.log(e); };
if(data.list.length) {
html = $.renderTemplate({template: template, data: data, directives: directives});
renderWidgetBody($w, widgetHtml, html);
$w.show();
} else {
$w.hide();
}
}
};
$.fn.widgetVoiceOfAmerica = function() {
var $w = this,
widgetHtml = '
Voice of America
',
template = ' ',
directives = {link: utils.decorators.link, image: utils.decorators.image};
getApiData('/static/voiceofamerica', render);
function render(res) {
var html = '', data = { };
try {
data = utils.models.getLinkFromApiArticle(res.item);
} catch (e) { utils.log(e); };
if (data && data.link && data.link.href && data.link.text) {
html = $.renderTemplate({template: template, data: data, directives: directives});
renderWidgetBody($w, widgetHtml, html);
$w.show();
} else {
$w.hide();
}
}
};
// TALK NK
$.fn.widgetTalkNk = function() {
var $w = this,
widgetHtml = '
TALK NK
',
template = '',
directives = {list: {link: utils.decorators.link, image: utils.decorators.image}};
getApiData('/static/talknks', render);
function render(d) {
var html = '',
data = {list: []};
try {
d.List.forEach(function(v, i) {
var bbsLink = 'http://bbs.joins.com/app/index.php?mid={MID}&document_srl={ID}';
bbsLink = bbsLink.replace('{MID}', v.Mid).replace('{ID}', v.Id);
data.list.push({link: {href: bbsLink, html: v.Title}});
});
} catch (e) { utils.log(e); };
if(data.list.length) {
html = $.renderTemplate({template: template, data: data, directives: directives});
renderWidgetBody($w, widgetHtml, html);
$w.show();
} else {
utils.error('widgetTalkNk', true);
$w.hide();
}
}
};
// 퇴직준비 셀프 테스트
$.fn.widgetRetirementSelfTest = function() {
var $w = this,
widgetHtml = '
퇴직준비 셀프 테스트
',
template = '' +
'' +
'' +
' ' +
' ' +
' ' +
' ' +
' ',
directives = {
list: {
link: utils.decorators.link,
image: utils.decorators.image,
thumb: {
link: utils.decorators.link,
html: function(params) {
if(!this.image.src) {
$(params.element).remove();
}
}
}
}
};
getApiData('/static/retirementselftest', render);
function render(res) {
//utils.log('---------------widgetRetirementSelfTest');
//utils.log(res);
var html = '',
data = {list: []};
try {
res.List.forEach(function(v) {
if(v.Title) {
data.list.push({
type: v.Type, link: { text: v.Title, href: v.Link },
image: { src: v.Thumbnail, alt: v.Title },
subtitle: v.SubTitle
});
}
});
} catch (e) { utils.log(e); };
if(data.list.length) {
html = $.renderTemplate({template: template, data: data, directives: directives});
renderWidgetBody($w, widgetHtml, html);
$w.show();
} else {
$w.hide();
}
}
};
// 기자 Q&A
// TODO : 데이타 확인하고 작업하자.
$.fn.widgetReporterQnA = function() {
var $w = this,
department = ($w.data('widgetCategory') || 'Politics').toLowerCase(),
widgetHtml = '',
template = '' +
'' +
'' +
'
무엇이든 물어보세요, 기자의 꿀팁!
' +
'
' +
'Q. ' +
'Re: ' +
' ' +
'
' +
'',
directives = {
question: {
link: utils.decorators.link
},
answer: {
link: utils.decorators.link,
html: function (params) {
if (!this.answer.link.text) {
$(params.element).remove();
}
}
},
reporter: {link: utils.decorators.link}
};
getApiData('/static/reporterqna', render);
function render(d) {
var html = '', data = {};
try {
data = {
question: { link: { text: d.Qna.Title, href: d.Qna.TotalId == 0 ? d.Qna.Link : utils.getUrlFormat(URL_NAMES.article, d.Qna.TotalId) } },
answer: { link: { text: d.Qna.Content, href: d.Qna.TotalId == 0 ? d.Qna.Link : utils.getUrlFormat(URL_NAMES.article, d.Qna.TotalId) } },
reporter: {link: {href: utils.getUrlFormat(URL_NAMES.reporter, d.Qna.Reporter.Id)}}
};
} catch (e) { utils.log(e); };
if(data) {
html = $.renderTemplate({template: template, data: data, directives: directives});
$w.html(html);
$w.show();
} else {
$w.hide();
}
}
};
// 나를 흔든 시 한 줄
$.fn.widgetPoemOneLine = function () {
var $w = this,
widgetName = '나를 흔든 시 한 줄',
listLink = utils.config('webPcPath') + '/find/list?Keyword=%22' + encodeURIComponent(widgetName) + '%22&ServiceCode=20&SearchCategoryType=OnlyJoongangNews&display=' + encodeURIComponent(widgetName),
widgetHtml = '
',
template = '',
directives = {
list: {link: utils.decorators.link}
};
getApiData('/static/poemoneline', render);
function render(d) {
var html = '',
data = {list: []};
try {
d.List.forEach(function(v, i) {
var articleLink = utils.getUrlFormat(URL_NAMES.article, v.Id);
data.list.push({link: {href: articleLink, html: v.Title}});
});
} catch(e) { utils.log(e); };
if(data.list.length) {
html = $.renderTemplate({template: template, data: data, directives: directives});
renderWidgetBody($w, widgetHtml, html);
$w.show();
} else {
$w.hide();
}
}
};
// 시가 있는 아침
$.fn.widgetMorningPoem = function () {
var $w = this,
widgetName = '시가 있는 아침',
listLink = utils.config('webPcPath') + '/find/list?Keyword=%22' + encodeURIComponent(widgetName) + '%22&ServiceCode=20&SearchCategoryType=OnlyJoongangNews&display=' + encodeURIComponent(widgetName),
widgetHtml = '
',
template = '',
directives = {
list: { link: utils.decorators.link }
};
getApiData('/static/morningpoem', render);
function render(d) {
var html = '',
data = { list: [] };
try {
d.List.forEach(function (v, i) {
var articleLink = utils.getUrlFormat(URL_NAMES.article, v.Id);
data.list.push({ link: { href: articleLink, html: v.Title } });
});
} catch (e) { utils.log(e); };
if (data.list.length) {
html = $.renderTemplate({ template: template, data: data, directives: directives });
renderWidgetBody($w, widgetHtml, html);
$w.show();
} else {
$w.hide();
}
}
};
// 직격 인터뷰
$.fn.widgetDirectInterview = function() {
var $w = this,
widgetName = '직격 인터뷰',
listLink = utils.config('webPcPath') + '/find/list?Keyword=%22' + encodeURIComponent(widgetName) + '%22&ServiceCode=20&SearchCategoryType=OnlyJoongangNews&display=' + encodeURIComponent(widgetName),
widgetHtml = '
',
template = '',
directives = {
list: {link: utils.decorators.link}
};
getApiData('/static/directinterview', render);
function render(d) {
var html = '',
data = {list: []};
try {
d.List.forEach(function(v, i) {
var articleLink = utils.getUrlFormat(URL_NAMES.article, v.Id);
data.list.push({link: {href: articleLink, html: v.Title}});
});
} catch(e) {
utils.log(e);
};
if(data.list.length) {
html = $.renderTemplate({template: template, data: data, directives: directives});
renderWidgetBody($w, widgetHtml, html);
$w.show();
} else {
$w.hide();
}
}
};
// 인기 기자
$.fn.widgetPopularReporter = function() {
var $w = this;
$.getScript(utils.config('staticPath')+'/scripts/data/home/js/right_today_reporter_gen.js', render);
function render(d) {
var idx, reporter, reporterLink, listIdx;
var html = '',
data = { list: []}
reporterList = utils.convertList(today_reporter_list);
var strHtml = [];
strHtml.push("");
strHtml.push("");
try {
for (listIdx = 0; listIdx < reporterList.length; listIdx++) {
reporter = reporterList[listIdx];
reporterLink = utils.config('webPcPath') + "/reporter/" + reporter.ReporterSeq;
strHtml.push("
");
}
} catch (e) {
utils.log('widgetHomeTodayReporter');
utils.log(e);
};
strHtml.push("
이전 다음 ");
var randomRepIdx = 0;
try {
randomRepIdx = Math.floor(Math.random() * reporterList.length);
} catch (e) {
randomRepIdx = 0;
}
if (reporterList.length) {
$w.append(strHtml.join(''));
var $slideWrap = $('.slide_wrap', $w);
$slideWrap.find('.slide_list').slideMotion({
infinite: true,
initialSlide: randomRepIdx,
slidesToShow: 1,
slidesToScroll: 1,
swipe: false,
prevArrow: $slideWrap.find('.btn-prev'),
nextArrow: $slideWrap.find('.btn-next')
});
$w.show();
} else {
$w.hide();
}
$w.find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|home|todayreporter'));
});
}
};
// 추천연재
$.fn.widgetRecommendedIssues = function() {
utils.log('### widgetRecommendedIssues');
var $w = this,
widgetHtml = '' +
'
추천 연재 ' +
'',
template = '',
directives = {list: {link: utils.decorators.link, image: utils.decorators.image}};
getApiData('/static/travel/recommandedseries', render);
function render(d) {
var html = '',
data = {list: []},
groupIndex = 0;
try {
d.List.forEach(function(v, i) {
var articleLink = v.Id == 0 ? v.Link : utils.getUrlFormat(URL_NAMES.article, v.Id);
groupIndex = parseInt(i / 8, 16);
data.list.push({group: groupIndex, link: {href: articleLink, html: v.Title}});
});
} catch(e) {
utils.log(e);
};
if(data.list.length) {
$w.html(widgetHtml);
for(var i = 0, len = groupIndex + 1; i < len; i++) {
var listData = data.list.filter(function(v) {
return v.group == i;
});
html = $.renderTemplate({ template: template, data: { list: listData }, directives: directives });
$w.find('.slide_list').append(html);
}
// 낱장일때 Widget 높이 보정.
var $firstSlide = $w.find('.slide:first');
$firstSlide.closest('.slide_wrap').height($firstSlide.children().height());
//utils.log('# groupIndex : ' + groupIndex);
//utils.log('children height : ' + $firstSlide.children().height());
// Page(groupIndex) 가 1개 이상이면 버튼 활성화
if (groupIndex > 0) {
$w.find('.btn_wrap').show();
var $slideWrap = $('.slide_wrap', $w);
$slideWrap.find('.slide_list').slideMotion({
infinite: true,
slidesToShow: 1,
slidesToScroll: 1,
swipe: false,
prevArrow: $slideWrap.find('.btn-prev'),
nextArrow: $slideWrap.find('.btn-next')
});
}
$w.show();
} else {
utils.error('widgetRecommendedIssues', true);
$w.hide();
}
}
};
$.fn.widgetMoneyIndicator = function() {
var $w = this,
$iframe = $(''),
attr = {
src: 'http://www.gsifn.com/IR/joongang/ir2_main_index.html',
title: '경제지표',
width: 280,
height: 184,
frameborder: 0,
marginwidth: 0,
marginheight: 0,
scrolling: 'no'
};
$iframe.attr(attr);
$w.html($iframe).show();
};
$.fn.widgetLink = function() {
var $w = this,
department = ($w.data('widgetCategory') || 'Politics').toLowerCase(),
widgetHtml = '
정치 관련 사이트 바로가기
',
template = '',
linkInfo = {
politics: {
title: '정치',
list: [
utils.linkService.getData('assembly'), utils.linkService.getData('president'), utils.linkService.getData('mnd'), utils.linkService.getData('saenuriparty'), utils.linkService.getData('npad'), utils.linkService.getData('people21')
]
},
money: [],
society: [],
world: []
},
data = linkInfo[department],
directives = {
title: {
text: function(params) {
return this.title + ' ' + params.value;
}
},
list: {link: utils.decorators.link, image: utils.decorators.image}
};
render();
function render() {
var html = '',
data = [];
try {
data = linkInfo[department];
} catch(e) {
};
if(data.list.length) {
html = $.renderTemplate({template: template, data: data, directives: directives});
renderWidgetBody($w, widgetHtml, html);
$w.show();
} else {
utils.error('widgetLink', true);
$w.hide();
}
}
};
// 핫클릭
$.fn.widgetHotClick = function() {
var regExp = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+<>@\#$%&\\\=\(\'\"]/gi;
var irPath = utils.config('irPath');
var $w = this,
widgetHtml = '',
template = '',
directives = {
list: {
item: {
'class': function() {
if (!this.imgSrc && this.imgSrc == undefined) {
return 'banner_color0' + utils.getRandomNumber(1, 4, 'hotclick');
}
},
html: function(params) {
if (this.imgSrc) {
var src = irPath + '?u=' + this.imgSrc + '&w=210&h=140&t=c';
var title = this.title.link.html.replace(regExp, '');
var html = ' ';
$(params.element).prepend(html);
}
}
},
section: {link: utils.decorators.link},
title: { link: utils.decorators.link },
summary: { link: utils.decorators.link }
}
};
getApiData('/static/hotclick', render);
function render(d) {
//utils.log('---------- widgetHotClick');
//utils.log(d);
var html = '',
data = [];
try {
d.List.forEach(function(v) {
var obj = {imgSrc: v.Thumbnail};
obj.section = { link: { href: $.trim(v.Link), html: v.Title } };
obj.title = { link: { href: $.trim(v.Link), html: v.SubTitle } };
obj.summary = { link: { href: $.trim(v.Link), html: v.Summary } };
data.push(obj);
});
} catch(e) {
};
if(data.length) {
html = $.renderTemplate({template: template, data: {list: data}, directives: directives});
renderWidgetBody($w, widgetHtml, html);
$w.show();
} else {
utils.error('widgetHotClick', true);
$w.hide();
}
// 핫클릭 Cloc
$w.find('a').each(function() {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|article|hotclickj'));
});
}
};
// 데이블 임시코드
$.fn.widgetHotClickDable = function () {
var strHtml = "";
strHtml += "";
strHtml += " ";
strHtml += "
";
$(this).html(strHtml);
};
// 미주 중앙일보 핫클릭
$.fn.widgetHotClickUSA = function () {
var regExp = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+<>@\#$%&\\\=\(\'\"]/gi;
var $w = this,
widgetHtml = '미주 중앙일보 핫클릭 ',
template = ' ',
directives = {
list: {
link: utils.decorators.link,
title: this.title
}
};
getApiData('/static/hotclickusa', render);
function render(d) {
var html = '',
data = { list: [] };
try {
d.List.forEach(function (v, i) {
if (v.Title) {
data.list.push({
link: { href: v.Link },
title: String(v.Title).replace(/(<([^>]+)>)/ig,"")
});
}
});
} catch (e) {
utils.log(e);
};
if (data.list.length) {
html = $.renderTemplate({ template: template, data: data, directives: directives });
html = widgetHtml + html;
$w.html(html);
$w.show();
} else {
$w.hide();
}
// 핫클릭 Cloc
$w.find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|article|hotclickj'));
});
}
};
//부서별 sns
$.fn.widgetDepartmentSns = function(obj) {
/*
*/
var $w = this,
defaultCategory = 'politics',
category = obj.category ? obj.category.toLowerCase() : defaultCategory,
SNS_URI = {
joongang: {text: '중앙일보 FB', link: 'https://www.facebook.com/joongang'},
politics: {text: '정치부', link: 'https://www.facebook.com/joinspolitics'},
money: {text: '경제부', link: 'https://www.facebook.com/joinsmoney'},
society: {text: '사회부', link: 'https://www.facebook.com/joinssociety'},
world: {text: '국제부', link: 'https://www.facebook.com/joonganginternational'},
sports: {text: '스포츠', link: 'https://www.facebook.com/joongangilbosports'},
culture: {text: '문화부', link: 'https://www.facebook.com/jmoonhwa'},
opinion: {text: '오피니언', link: 'https://www.facebook.com/pages/%EC%A4%91%EC%95%99%EC%9D%BC%EB%B3%B4-%EB%85%BC%EC%84%A4%EC%9C%84%EC%9B%90%EC%8B%A4/756556791101437?fref=nf'},
travel: {text: 'Week', link: 'https://www.facebook.com/weeknplus'}
},
widgetHtml = '
부서 별 SNS 영역
',
snsData = SNS_URI[category] || SNS_URI[defaultCategory],
link = snsData.link,
text = snsData.text,
html_ = '',
html = '';
if(utils.browser && utils.browser.msie == true && parseInt(utils.browser.version, 10) <= 7) {
//$w.browserNotice();
} else {
render();
}
function render() {
//var html = $.renderTemplate({ data: {}, template: template, directives: directives });
$w.html(widgetHtml).show().find('.bd').html(html);
if(window.FB) {
window.FB.init({
appId: '1045198002178811',
version: 'v2.4'
});
window.FB.XFBML.parse($w[0]);
} else {
(function(d, s, id) {
var js,
fjs = d.getElementsByTagName(s)[0];
if(d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/ko_KR/sdk.js#xfbml=1&version=v2.4&appId=1045198002178811";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
}
}
};
// PhotoVideo
$.fn.widgetPhotoVideo = function() {
var $w = this,
widgetHtml = '
PHOTO & VIDEO
',
template = '' +
'' +
' ' +
' ' +
' ' +
' ',
directives = {
list: {
title: {link: utils.decorators.link},
thumb: {
image: utils.decorators.image,
link: utils.decorators.link,
html: function(params) {
if(this.thumb.iconClass) {
$(params.element).find('a').append('동영상 ');
}
}
}
}
};
getApiData('/static/homephotoandvideos', render);
function render(d) {
var html = '', data = {cls: 'list', list: []};
try {
d.List.forEach(function(v, i) {
if(i < 3) {
data.list.push({
title: {link: {href: v.Link, html: v.Title}},
thumb: {link: {href: v.Link}, image: {src: v.Thumbnail ,alt : v.Title}, iconClass: v.InfomationText, text: v.Title}
});
}
});
} catch(e) {
utils.log(e);
};
//utils.log(data);
if(data.list.length) {
html = $.renderTemplate({data: data, template: template, directives: directives});
renderWidgetBody($w, widgetHtml, html);
$w.show();
//utils.resetArticleSubWidget && utils.resetArticleSubWidget();
$('.thumb a', $w).each(function () {
var $link = $(this);
var href = $link.attr('href') || '';
var pathname = this.pathname;
var arrPathName = pathname.split('/');
var id = arrPathName[arrPathName.length -1];
if (isPhoto(href)) {
//#화보 레이어
$link.data({ viewer: 'photo', id: id });
$link.imageViewer();
}
function isPhoto(href) {
return href.indexOf('pic/photoviewer') > -1;
}
});
} else {
utils.error('widgetPhotoVideo', true);
$w.hide();
}
// 포토비디오 Cloc
$w.find('a').each(function() {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|article|photovod'));
});
}
};
// widgetSpecialLink
// @param options
$.fn.widgetSpecialLink = function(options) {
var $t = this;
$t.find('.link1').loadAd({type: 'special_link1'});
$t.find('.link2').loadAd({type: 'special_link2'});
$t.find('.rt').loadAd({type: 'da_250_1'});
};
// 추천기사(편집), 주요 포털 실시간 검색어, SNS 기사
$.fn.widgetRecommendedArticle = function() {
//utils.log('## widgetRecommendedArticle');
var regExp = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+<>@\#$%&\\\=\(\'\"]/gi;
var $w = this,
widgetHtml = '
추천기사
',
template = '' +
'' +
' ' +
' ' +
' ' +
' ',
directives = {
list: {
'class': function() {
return this.cls;
},
link: utils.decorators.link,
image: utils.decorators.image,
thumb: {
html: function(params) {
if(!this.image.src) {
$(params.element).remove();
}
}
}
}
};
getApiData('/static/news/recommandedarticles', render);
function render(d) {
//utils.log('------------------------ widgetRecommendedArticle');
//utils.log(d);
var topHtml = '',
html = '',
topData = {cls: 'list_top', list: []},
data = {cls: 'list', list: []};
try {
if (d.Top) {
var title = d.top.Title.replace(regExp, '');
topData.list.push({
link: {href: d.Top.Link, html: d.Top.Title},
image: { src: d.Top.Thumbnail, alt: title }
});
}
d.List.forEach(function (v, i) {
var title = v.Title.replace(regExp, '');
if(i == 0) {
topData.list.push({
link: {href: v.Link, html: v.Title},
image: { src: v.Thumbnail, alt: title }
});
} else {
data.list.push({
link: {href: v.Link, html: v.Title},
image: { src: v.Thumbnail, alt: title }
});
}
});
} catch(e) {
};
if(data.list.length) {
topHtml = $.renderTemplate({data: topData, template: template, directives: directives});
html = $.renderTemplate({data: data, template: template, directives: directives});
renderWidgetBody($w, widgetHtml, topHtml + html);
// 추천 기사 밑 텍스트 2줄 광고 div 추가
$w.find('.list > li').eq(4).after("
");
$('#ad_text_recommanded').loadAd({ type: 'ad_text_recommanded' });
$w.show();
utils.resetArticleSubWidget && utils.resetArticleSubWidget();
} else {
utils.error('widgetRecommendedArticle', true);
$w.hide();
}
// 추천 기사 Cloc
$w.find('a').each(function() {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|article|recommend'));
});
}
};
// 와이드 영역 추천기사
$.fn.widgetRecommendedArticleForWide = function() {
//utils.log('## widgetRecommendedArticleForWide');
var $w = this,
widgetHtml = '
신규 & 추천 뉴스
',
template = '' +
'' +
//' ' +
//' ' +
' ' +
' ',
directives = {
list: {
//'class': function () { return this.cls; },
//link: utils.decorators.link, image: utils.decorators.image,
item: {
html: function(params) {
if(this.image) {
$(params.element).addClass('text_type');
}
return itemDecorator.apply(this);
}
}
}
};
getApiData('/static/wide/recommandedarticles', render);
function itemDecorator() {
var html = '';
if(this.type == "Text") {
html += ' ' +
'' +
'' +
'' + this.link.html + ' ' +
' ' +
' ' +
' ';
} else {
html += ' ';
}
return html;
}
function render(d) {
var html = '',
data = {list: []},
pathname = location.pathname.toLowerCase(),
clocName = '';
//InfomationText > onair icon.
utils.log(d);
try {
d.List.forEach(function(v, i) {
if(v.Title) {
data.list.push({
type: v.Type,
link: {href: v.Link, html: v.Title},
image: {src: v.Thumbnail, alt: v.Title}
});
}
});
} catch (e) { utils.log(e); };
utils.log(data);
if(data.list.length) {
html = $.renderTemplate({data: data, template: template, directives: directives});
renderWidgetBody($w, widgetHtml, html);
$w.show();
utils.resetArticleSubWidget && utils.resetArticleSubWidget();
} else {
utils.error('widgetRecommendedArticleForWide', true);
//$w.hide();
}
// 더보기 스페셜아티클 Cloc
if(pathname == '/') {
clocName = 'joongang|home|morespecial';
} else if(pathname.indexOf('article') > -1) {
clocName = 'joongang|article|morespecial';
} else {
clocName = 'joongang|section|morespecial';
}
$w.find('a').each(function() {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), clocName));
});
}
};
$.fn.widgetOpinionOnAir = function () {
utils.log('####### widgetOpinionOnAir');
var $w = this,
widgetHtml = '
오피니언 온 에어
',
directives = {
list: {
item: {
}
}
};
utils.opinionCast.init();
utils.opinionCast.onAir = function (onAirInfo) {
utils.log('## utils.opinionCast.onAir');
// Wide Banner 설정 (s)
//var html = $.renderTemplate({ data: data, template: template, directives: directives });
var model = {};
try {
model = utils.convertList(index_onair_schedule);
} catch (e) { utils.log(e); };
var link = 'http://news.joins.com/opinion/opinioncast';
var title = model[0].title;
var content = model[0].content;
utils.log(model);
var html = '' +
'';
$w.html(html).show();
// Wide Banner 설정 (e)
utils.opinionCast.isOnAirSet(true);
};
utils.opinionCast.offAir = function (onAirInfo) {
utils.log('## utils.opinionCast.offAir');
// Wide Banner 설정 (s)
$w.hide();
// Wide Banner 설정 (e)
utils.opinionCast.isOnAirSet(false);
};
};
$.fn.widgetAppendItem = function () {
};
// 주요 포털 실시간 검색어
$.fn.widgetPortalSearchKeyword = function() {
//utils.log('## widgetPortalSearchKeyword');
var $w = this,
widgetData = $w.data(),
widgetHtml = '
주요 포털 실시간 검색어
',
template = '' +
'' +
' ' +
'' +
' ' + //HOT
' ' +
' ' +
' ' +
' ',
directives = {
list: {
thumb: {
link: utils.decorators.link,
image: utils.decorators.image,
html: function(params) {
if(!this.thumb.useThumbnail) {
$(params.element).remove();
}
}
},
title: {link: utils.decorators.link},
lead: {link: utils.decorators.link}
}
};
getApiData('/static/portalrealtimesearchwords', render);
function render(d) {
var html = '', data = {list: []
};
try {
d.List.forEach(function(v, i) {
if(i < 10) {
var link = utils.getUrlFormat(URL_NAMES.article, v.Id);
data.list.push({
thumb: {
link: {href: link, html: v.Title},
image: {src: utils.getIrPath(utils.getPdsFullPath(v.Thumbnail), 50, 50), alt: v.SubTitle},
useThumbnail: v.Thumbnail ? true : false
},
title: {link: {href: link, html: v.Title}},
lead: {link: {href: link, html: v.SubTitle}}
});
}
});
} catch(e) { utils.log(e); };
if(data.list.length) {
html = $.renderTemplate({data: data, template: template, directives: directives});
renderWidgetBody($w, widgetHtml, html);
$w.show();
utils.resetArticleSubWidget && utils.resetArticleSubWidget();
} else {
utils.error('widgetPortalSearchKeyword', true);
$w.hide();
}
// cloc 적용.
var clocPageType = utils.config('pageType'),
cloc = '';
if (clocPageType == 'Home' || clocPageType == 'Article') {
cloc = 'joongang|' + clocPageType.toLowerCase() + '|portalcheck';
} else {
cloc = 'joongang|section|portalcheck';
}
$w.find('a').each(function() {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), cloc));
});
}
};
// SNS 기사
$.fn.widgetSnsArticle = function() {
//utils.log('## widgetSnsArticle');
var $w = this,
widgetData = $w.data(),
widgetHtml = '
SNS 기사
',
template = '' +
'' +
' ' +
' ' +
' ' +
' ',
directives = {
list: {
link: utils.decorators.link,
image: utils.decorators.image,
thumb: {
html: function(params) {
if(!this.image.src) {
$(params.element).remove();
}
}
}
}
};
getApiData('/article/snsarticles', render);
function render(d) {
var topHtml = '',
html = '',
data = {list: []};
try {
d.forEach(function(v, i) {
if(i < 10) {
data.list.push({
link: {href: utils.getUrlFormat(URL_NAMES.article, v.TotalId), html: v.Title},
image: {src: utils.getIrPath(utils.getPdsFullPath(v.Thumbnail), 50, 50), alt: v.Title}
});
}
});
} catch(e) {
utils.log(e);
};
//utils.log(data);
if(data.list.length) {
html = $.renderTemplate({data: data, template: template, directives: directives});
renderWidgetBody($w, widgetHtml, topHtml + html);
$w.show();
utils.resetArticleSubWidget && utils.resetArticleSubWidget();
} else {
utils.error('widgetSnsArticle', true);
$w.hide();
}
// cloc 적용.
var clocPageType = utils.config('pageType'),
cloc = '';
if (clocPageType == 'Home' || clocPageType == 'Article') {
cloc = 'joongang|' + clocPageType.toLowerCase() + '|snscheck';
} else {
cloc = 'joongang|section|snscheck';
}
$w.find('a').each(function() {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), cloc));
});
}
};
var regTitleFilter = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+<>@\#$%&\\\=\(\'\"]/gi;
// 주요 뉴스
$.fn.widgetMajorArticle = function() {
//return false;
//utils.log('## widgetMajorArticle');
var $w = this,
widgetData = $w.data(),
apiFormat = '/static/wide/majorarticles',
widgetHtml = '',
template = '' +
'' +
' ' +
' ' +
' ' +
' ',
directives = {
list: {
link: utils.decorators.link,
image: utils.decorators.image,
thumb: {
html: function(params) {
if(!this.image.src) {
$(params.element).remove();
}
}
}
}
};
getApiData(apiFormat, render);
function render(d) {
//utils.log('----------------widgetMajorArticle');
//utils.log(d);
var topHtml = '',
html = '',
data = {list: []},
pathname = location.pathname.toLowerCase(),
clocName = '';
try {
d.List.forEach(function (v, i) {
var alt = v.Title.replace(regTitleFilter, '');
if(i < 10) {
data.list.push({ type: v.Type, link: { href: $.trim(v.Link), html: v.Title }, image: { src: utils.getPdsFullPath(v.Thumbnail), alt: alt } });
}
});
} catch(e) {
utils.log(e);
};
if(data.list.length) {
//html = $.renderTemplate({data: data, template: template, directives: directives});
//renderWidgetBody($w, widgetHtml, topHtml + html);
$w.html(widgetHtml).show();
data.list.forEach(function (v, i) {
appendItem(v, i);
});
$w.show();
utils.resetArticleSubWidget && utils.resetArticleSubWidget();
} else {
utils.error('widgetMajorArticle', true);
$w.hide();
}
function appendItem(item, i) {
var html = '';
if (item.image.src) {
html += ' ';
}
html += ' ';
html += ' ';
var $html = $(html);
$html.find('strong a').html(item.link.html);
$w.find('ul').append($html);
}
// 더보기 주요뉴스 Cloc
if(pathname == '/') {
clocName = 'joongang|home|morehomenews';
} else if(pathname.indexOf('article') > -1) {
clocName = 'joongang|article|morehomenews';
} else {
clocName = 'joongang|section|morehomenews';
}
$w.find('a').each(function() {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), clocName));
});
}
};
// 지면보다 빠른 뉴스
$.fn.widgetFastNews = function() {
//utils.log('## widgetFastNews');
var $w = this,
widgetData = $w.data(),
//widgetHtml =
template = '' +
'지면보다 빠른 뉴스 디지털에서만 만날 수 있는 중앙일보 뉴스
' +
'',
listTemplate = '' +
'' +
'' +
' ' +
' ' +
' ' +
' ' +
' ',
directives = {
list: {
link: utils.decorators.link,
image: utils.decorators.image,
thumb: {
html: function(params) {
if(!this.image.src) {
$(params.element).remove();
}
}
}
}
};
getApiData('/article/fastarticles', render);
function render(d) {
var html = '',
data = {times: [], list: []},
pathname = location.pathname.toLowerCase(),
clocName = '',
serviceDate = '';
try {
d.forEach(function(v, i) {
serviceDate = v.RegistedDateTime;
if(serviceDate.indexOf('.') > -1) {
serviceDate = serviceDate.substr(0, serviceDate.indexOf('.'));
}
serviceDate = serviceDate.toDateISO8061().format('HH:00');
if(!data.times.filter(function(v) {
return v.time == serviceDate;
}).length) {
data.times.push({time: serviceDate});
}
data.list.push({
time: serviceDate,
link: {href: utils.getUrlFormat(URL_NAMES.article, v.TotalId), html: v.Title},
image: { src: utils.getIrPath(utils.getPdsFullPath(v.Thumbnail.replace('.tn_120.jpg', '')), 170, 126, '.tn_250.jpg'), alt: v.Title }
});
});
} catch(e) {
utils.log(e);
};
if(data.times.length) {
html = $.renderTemplate({data: {group: data.times}, template: template});
//utils.log(html);
$w.html(html).show().find('[data-bind="time"]').each(function() {
var $group = $(this),
time = $group.text(),
listData = data.list.filter(function(v) {
return v.time == time;
}),
listHtml = html = $.renderTemplate({data: {list: listData}, template: listTemplate, directives: directives});
$group.parent().append(listHtml);
});
} else {
utils.error('widgetFastNews', true);
$w.hide();
}
// 지면보다 빠른뉴스 Cloc
if(pathname == '/') {
clocName = 'joongang|home|moredigitalfirst';
} else if(pathname.indexOf('article') > -1) {
clocName = 'joongang|article|moredigitalfirst';
}
else {
clocName = 'joongang|section|moredigitalfirst';
}
$w.find('a').each(function() {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), clocName));
});
}
};
// 와이드 영역 트렌드 뉴스
$.fn.widgetTrendArticle = function() {
//utils.log('## widgetTrendArticle');
var $w = this,
widgetData = $w.data(),
apiFormat = '/static/trendarticles/{SORT_TYPE}',
sortType = widgetData.sort || 'all', // All, ClickCount, Reply, Share, Recommand, Scrap
widgetHtml = '',
template = '' +
'' +
'' +
' ' +
' ' +
' ' +
' ' +
' ',
directives = {
list: {
link: utils.decorators.link,
image: utils.decorators.image,
position: {
'class': function(params) {
var pos = params.index + 1;
return 'rank' + (pos < 10 ? ('0' + pos) : pos);
},
text: function(params) {
return params.index + 1;
}
},
thumb: {
link: utils.decorators.link,
html: function(params) {
if(!this.image.src) {
$(params.element).remove();
}
}
}
}
};
getApiData(apiFormat.replace('{SORT_TYPE}', sortType), render);
function render(d) {
//utils.log('---------------------------------------- widgetTrendArticle');
//utils.log(d);
var html = '',
data = {list: []},
pathname = location.pathname.toLowerCase(),
clocName = '';
try {
d.List.forEach(function(v, i) {
if(i < 10) {
data.list.push({
type: v.Type,
link: {href: utils.getUrlFormat(URL_NAMES.article, v.Id), html: v.Title},
image: { src: utils.getIrPath(utils.getPdsFullPath(v.Thumbnail), 40, 40, '.tn_120.jpg'), alt: v.Title }
});
}
});
} catch(e) { utils.log(e); };
function appendItem(item, i) {
var pos = i + 1;
pos = 'rank' + (pos < 10 ? ('0' + pos) : pos);
var html = '';
if(item.image.src){
html += ' ';
}
html += '' + i + 1 + ' ';
html += ' ';
html += ' ';
var $html = $(html);
$html.find('strong a').html(item.link.html);
$w.find('ul').append($html);
}
if (data.list.length) {
$w.html(widgetHtml).show();
data.list.forEach(function (v, i) {
appendItem(v, i);
});
//html = $.renderTemplate({ data: data, template: template, directives: directives });
//utils.log(html);
//renderWidgetBody($w, widgetHtml, html);
//$w.show();
//utils.resetArticleSubWidget && utils.resetArticleSubWidget();
} else {
utils.error('widgetTrendArticle', true);
$w.hide();
}
//return false;
// 더보기 트렌드뉴스 Cloc - 미확인
if(pathname == '/') {
clocName = 'joongang|home|moretrend';
} else if(pathname.indexOf('article') > -1) {
clocName = 'joongang|article|moretrend';
} else {
clocName = 'joongang|section|moretrend';
}
$w.find('a').each(function() {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), clocName));
});
}
};
// 포토이슈
$.fn.widgetPhotoIssues = function() {
//utils.log('###### widgetPhotoIssues');
var $w = this,
widgetHtml = '
포토이슈
/
',
template = '' +
'
' +
'
' +
'
' +
' ' +
' ' +
'
' +
'
' +
'
prev ' +
'
next ' +
'
' +
'' +
'
' +
' ' +
' ' +
'
',
directives = {
list: {
link: utils.decorators.link,
image: utils.decorators.image
//active: { 'class': function (params) { return params.index == 0 ? $(params.element).addClass('active') : ''; } }
}
};
getApiData('/static/homephotoissues', render);
function render(d) {
//utils.log('--------------------------- widgetPhotoIssues');
//utils.log(d);
var html = '',
data = {cls: 'list', list: []};
//data.list = d;
try {
d.List.forEach(function(v, i) {
if(i < 5) {
data.list.push({link: {href: v.Link, text: v.Title}, image: {src: v.Thumbnail}});
}
});
} catch(e) {
utils.log(e);
};
if(data.list.length) {
html = $.renderTemplate({template: template, data: data, directives: directives});
$w.html(widgetHtml).find('.bd').html(html);
$w.find('.current_page').text('1');
$w.find('.total_page').text(data.list.length);
var $slideWrap = $('.slide_list_wrap', $w),
$thumbItems = $('div.thumb_list li', $w);
$slideWrap.find('.slide').eq(0).addClass('active');
$thumbItems.find('.slide').eq(0).addClass('active');
$slideWrap.find('.slide_list').slideMotion({
infinite: true,
slidesToShow: 1,
slidesToScroll: 1,
swipe: false,
thumbnails: $thumbItems,
prevArrow: $slideWrap.find('.btn-prev'),
nextArrow: $slideWrap.find('.btn-next'),
beforeChange: function(event, slick, currentIndex, nextIndex) {
$thumbItems.eq(nextIndex).addClass('active').siblings().removeClass('active');
$w.find('.current_page').text(nextIndex + 1);
}
});
$w.show();
} else {
$w.hide();
}
// 포토 뉴스 Cloc
$w.find('.slide_list a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|article|photoissue'));
});
}
};
// 많이 본 기사
$.fn.widgetHotArticles = function () {
$('#widget_favorite_articlesAD').loadAd({ type: 'favorite_ad' }).show();
//utils.log('---------------------widgetHotArticles start');
//많이 본 기사 하단광고
var $w = this,
pageType = utils.config('pageType'),
apiFormat = '/static/mostviewedarticles/{KEY}',
categoryKey = $w.data('widgetCategory') || '',
title = (categoryKey.toLowerCase() == 'jplus' ? '많이 본 J플러스' : '많이 본 기사'),
widgetHtml = '
' + title + '
',
template = '',
directives = {
list: {
link: utils.decorators.link,
image: utils.decorators.image,
item: {
'class': function (obj) {
return obj.index < 3 ? 'top' : '';
}
}
}
};
if (pageType === PAGE_TYPE.article) {
var sectionKey = utils.menu.getPageMenuKey().split(',')[0].toLowerCase();
categoryKey = sectionKey;
if (categoryKey == 'cartoon') categoryKey = '';
}
$w.hide();
getApiData(apiFormat.replace('{KEY}', categoryKey), render);
function render(d) {
//utils.log('---------------------widgetHotArticles 1');
var html = '',
data = { list: [] };
try {
d.List.forEach(function (v, i) {
data.list.push({ link: { href: utils.getUrlFormat(URL_NAMES.article, v.Id), html: v.Title }, position: (i + 1) });
});
} catch (e) {
//utils.log('widgetHotArticles');
utils.log(e);
};
//utils.log(data);
if (data.list.length) {
html = $.renderTemplate({ template: template, data: data, directives: directives });
renderWidgetBodyPrepend($w, widgetHtml, html);
$w.show();
utils.resetArticleSubWidget && utils.resetArticleSubWidget();
} else {
$w.hide();
}
// 많이 본 기사 Cloc - 미확인
$w.find('a').each(function () {
var pageType = utils.config('pageType') || '';
pageType = pageType.toLowerCase();
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|' + pageType + '|clickraking'));
});
}
};
// 많이 본 동영상 ( general, opinion )
$.fn.widgetHotVideos = function() {
var $w = this,
categoryKey = $w.data('widgetCategory') || '',
apiUrl = '/static/mostviewedvideos',
widgetHtml = '
많이 본 동영상
',
template = '' +
'' +
' ' +
' ' +
//'' +
' ' +
'',
directives = {
list: {link: utils.decorators.link, image: utils.decorators.image}
};
getApiData(apiUrl, render);
function render(d) {
var html = '',
data = {list: []};
try {
d.List.forEach(function(v, i) {
var atticleLink = utils.getUrlFormat(URL_NAMES.article, v.Id);
var image = utils.getPdsFullPath(v.Thumbnail);
//utils.log('## atticleLink : ' +atticleLink);
data.list.push({
link: {href: atticleLink, html: v.Title},
image: {src: image},
viewCount: v.ClickCount,
commentCount: v.ReplyCount
});
});
} catch (e) {
utils.log(e);
};
if(data.list.length) {
html = $.renderTemplate({template: template, data: data, directives: directives});
renderWidgetBody($w, widgetHtml, html);
$w.show();
} else {
$w.hide();
}
}
};
// 오피니언 방송 (최신기사3건)
$.fn.widgetOpinionCast = function() {
var $w = this,
categoryKey = $w.data('widgetCategory') || '',
listLink = utils.config('webPcPath') + '/opinion/opinioncast',
widgetHtml = '
',
template = '