/**
* index.js
* @use : news.joins.com (Pc Main) 에서만 사용한다.
*/
document.domain = "joins.com";
var joongang_timeout;
var homeLiveRefreshTimer;
(function (window, document, $) {
$(function ($) {
// home refresh.
// TODO : CMS 미리보기 등 예외 작업을 취한 refresh 예외 코드 추가.
var params = $.deparam(location.search.toLocaleLowerCase().replace('?', ''));
if (window.location.host.toLowerCase() == "joongang.joins.com" && params.ignorerefresh != 'y' && $('#ifr_vod').length == 0) {
var refreshTimer = 5 * 60 * 1000;
joongang_timeout = setTimeout(function () {
location.reload()
}, refreshTimer);
}
utils.newsRoom.init();
utils.newsRoom.onAir = function () {
utils.log('## utils.newsRoom.onAir');
var $target = null;
if (utils.serverDate.isWeekend()) {
$target = $('#div_weekend');
} else {
$target = $('#div_weekdays');
}
if ($target && $target.length) {
$target.show();
utils.newsRoom.isOnAirSet(true);
}
};
utils.newsRoom.offAir = function () {
utils.log('## utils.newsRoom.offAir');
//utils.newsRoom.isOnAir = false;
var $target = null;
if (utils.serverDate.isWeekend()) {
$target = $('#div_weekend');
} else {
$target = $('#div_weekdays');
}
//$('#div_weekend').hide();
if ($target && $target.length) {
//utils.log('************************************* off');
$target.hide();
utils.newsRoom.isOnAirSet(false);
}
};
//utils.newsRoom.onAir();
$(".scroll").mCustomScrollbar({ theme: "inset", autoHideScrollbar: true });
$('#body').find('div[data-widget-type]').indexWidget();
//utils.getJsonp({url:'http://labs.joins.com/Jmobile/V2/JMobile_Json.aspx?jt=list&code=time_edition&septb=Y', success: function () {utils.log(arguments);}});
//utils.log('####################');
//utils.log($('#body').find('div[data-widget-type]'));
//$('#today_column')
//$('div[data-effect]').setHomeEffect();
//homeSlideMotion('.top_article', 1);
$('.top_article').each(function () {
var $section = $(this),
$slides = $section.find('.slide'),
slideLength = $slides.length;
if ($section.find('.type1-2').length) {
homeTopArticle($section);
}
});
$('.today_column .btn_toggle').on('click', function () {
var $btn = $(this),
$wrap = $btn.closest('.toggle_wrap');
if ($wrap.hasClass("toggle_off")) {
$wrap.addClass('toggle_on').removeClass('toggle_off');
} else {
$wrap.addClass('toggle_off').removeClass('toggle_on');
}
return false;
});
$('div[data-widget-type="Ad"]', '#content').each(function () {
var $ad = $(this);
$ad.loadAd({ type: $ad.data('widgetService') });
});
$('div[data-widget-type="DepartmentSns"]').each(function () {
var $w = $(this);
$w.widgetDepartmentSns({ category: 'joongang' });
});
$('div.promotion_banner01').rollContents();
homeSlideMotion('.topic_click', 3);
homeSlideMotion('.reporter_pr', 1);
homeSlide('.special_article');
homeSlide('.photo_video');
//homeSlide('.top_article');
$('.photo_video .slide a').each(function () {
var $link = $(this);
var href = $link.attr('href');
var pathname = this.pathname;
var arrPathName = pathname.split('/');
var arrHref = href.split('/');
var id = arrHref[arrHref.length - 1];
var id = arrPathName[arrPathName.length - 1];
if (isPhoto(href)) {
//utils.log('-------------id : ' + id);
//utils.log('------------pathname : ' + pathname)
//#화보 레이어
$link.data({ viewer: 'photo', id: id });
$link.imageViewer();
//$link.on('click', function () {
// window.open(href, 'photo_viewer', 'directories=no,location=no,menubar=no,status=no,toolbar=no,scrollbars=no,resizable=no,width=800,height=700');
//});
//# 팝업
//window.open(href, 'photo_viewer', 'directories=no,location=no,menubar=no,status=no,toolbar=no,scrollbars=no,resizable=no,width=700,height=650');
}
function isPhoto(href) {
return href.indexOf('pic/photoviewer') > -1;
}
});
$('.photo_issue').selectImage();
$('#search_word').find();
var $peopleSearch = $('#search_word');
$peopleSearch.on('focusin', function () {
$peopleSearch.prev().hide();
}).on('focusout', function () {
var keyword = $peopleSearch.val() || '';
if (keyword.isEmpty()) {
$peopleSearch.prev().show();
} else {
$peopleSearch.prev().hide();
}
});
$peopleSearch.on('keyup', function (e) {
var keyword = $peopleSearch.val() || '',
keyCode = utils.getKeyCode(e);
if (keyCode == 13) {
utils.peopleSearch(keyword);
}
});
$peopleSearch.next().on('click', function () {
var keyword = $peopleSearch.val() || '';
if (keyword) {
utils.peopleSearch(keyword);
}
});
$('#btnFootAllService').click();
// 기자 QNA하단 프로모션 배너
var randomPro = Math.floor(Math.random() * 3) + 1;
$("#divpro_" + randomPro).show();
//이슈
//var issueUrl = 'http://';
//function getDataUrl(type) {
// return URL_INFO[type] || '';
//}
/* cloc - 추가 확인 필요 */
// J플러스 신청
//20180131 삭제예정
$('div.jplus_apply a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|home|jplusapply'));
});
// 오늘의 기자
$('div[name=divEditPartInfo] div.reporter_pr a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|home|todayreporter'));
});
// JTBC 뉴스룸 타이틀 link 제거
var jtbcNewsRoomTitle = $('div[name=divEditPartInfo] div.jtbc_newsroom h2.subtit_comm a').html();
$('div[name=divEditPartInfo] div.jtbc_newsroom .subtit_comm').html(jtbcNewsRoomTitle);
/* cloc */
// live 뉴스
var liveArtTotalId = homeLiveContent();
if ($.trim(liveArtTotalId).length > 0) {
homeLiveRefreshTimer = setInterval("homeLiveContent()", 60000);
}
// 소셜로그인 홍보 팝업
//setTimeout(hideLayerPopup, 5000);
$('#layer_social_login .btn_close').click(function () {
hideLayerPopup();
});
});
function hideLayerPopup() {
$('#layer_social_login').fadeOut();
}
function homeSlideMotion(selector, groupLen) {
var $slide = $(selector),
topicSlideLength = $slide.find('.slide').length,
totalPage = parseInt(topicSlideLength / groupLen, 10);
$slide.find('.info .total_page').text(totalPage);
if (totalPage == 1) {
$slide.find('.btn_wrap').hide();
$slide.find('.btn-prev').hide();
$slide.find('.btn-next').hide();
} else {
$slide.find('.slide_list').slideMotion({
//none : false,
infinite: false,
slidesToShow: groupLen,
slidesToScroll: groupLen,
swipe: false,
prevArrow: $slide.find('.btn-prev'),
nextArrow: $slide.find('.btn-next'),
beforeChange: function (event, slick, currentIndex, nextIndex) {
var page = parseInt(nextIndex / groupLen, 10);
$slide.find('.info .current_page').text(page + 1);
}
});
$slide.find('.btn_wrap').show();
}
}
function homeTopArticle(selector) {
//return;
var $section = typeof selector == 'string' ? $(selector) : selector,
$slideList = $section.find('.slide_list'),
$slideItem = $section.find('.slide'),
$descriptions = $section.find('.text_area'),
$btnPrev = $section.find('.btn-prev'),
$btnNext = $section.find('.btn-next'),
$currentPage = $section.find('.current_page'),
itemWidth = $slideItem.outerWidth(),
listWidth = itemWidth * ($slideItem.length + 1),
movePx = 0,
index = 0,
textHeight = [];
$section.find('.slide_list').width(listWidth);
//activeDesc(currentIndex);
slideInit();
function slideInit() {
var slideListOffset = $slideList.offset(),
activeOffset = {},
largeHeightText = 150;
$descriptions.each(function () { textHeight.push($(this).outerHeight(true)); });
largeHeightText = textHeight.sort()[textHeight.length - 1];
$descriptions.css('min-height', largeHeightText);
$slideItem.each(function (i) {
var $item = $(this),
page = 1;
if ($item.hasClass('active')) {
activeOffset = $item.offset();
index = i;
page = 1;
activeDescription(index);
$currentPage.html(page);
} else if ($item.hasClass('prev')) {
page = 3;
} else {
page = 2;
}
$item.data({
'index': i,
'page': page
});
});
movePx = slideListOffset.left - activeOffset.left;
$slideList.css('left', movePx);
bindEvent();
}
var isAnimate = false,
$removeElement = null,
direction = '',
aniOptions = {
easing: 'linear',
duration: 400,
complete: function () {
isAnimate = false;
if (direction === 'next') {
$slideList.css({ 'left': movePx + 'px' });
}
$removeElement.remove();
$slideItem = $slideList.find('.slide');
bindEvent();
}
};
$btnPrev.on('click', function () {
if (isAnimate) { return false; }
var currentSlideListLeft = parseInt($slideList.css('left').replace('px'), 10),
$targetElement = $slideItem.eq(index - 1),
page = $targetElement.data('page'),
descriptionIndex = $targetElement.data('index'),
$cloneElement = null;
isAnimate = true;
direction = 'prev';
$removeElement = $slideItem.eq(index + 1);
$cloneElement = $removeElement.clone(true, true);
$slideList
.prepend($cloneElement)
.css('left', currentSlideListLeft + movePx)
.stop(true, true)
.animate({ "left": '-=' + movePx + "px" }, aniOptions);
$currentPage.html(page);
activeDescription(descriptionIndex);
});
$btnNext.on('click', function () {
if (isAnimate) { return false; }
var $targetElement = $slideItem.eq(index + 1),
page = $targetElement.data('page'),
descriptionIndex = $targetElement.data('index'),
$cloneElement = null;
isAnimate = true;
direction = 'next';
$removeElement = $slideItem.eq(index - 1);
$cloneElement = $removeElement.clone(true, true);
$slideList
.append($cloneElement)
.stop(true, true)
.animate({ "left": '+=' + movePx + "px" }, aniOptions);
$currentPage.html(page);
activeDescription(descriptionIndex);
});
function activeDescription(displayIndex) {
$descriptions.eq(displayIndex).show().siblings(".text_area").hide();
}
function bindEvent() {
$slideItem.each(function () {
var $item = $(this);
$item.find('a').off('click').on('click', function (e) {
var $a = $(this),
$slide = $a.closest('.slide'),
index = $slideItem.index($slide);
if (index !== 1) {
e.preventDefault();
if (index == 2) { $btnNext.trigger('click'); }
else { $btnPrev.trigger('click'); }
}
});
});
}
}
function homeSlide(selector) {
//utils.log('homeSlide $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$' + selector);
var $section = typeof selector == 'string' ? $(selector) : selector,
$slideBox = $section.find('.slide_box'),
$slideList = $section.find('.slide_list'),
$slideItem = $section.find('.slide'),
$btnPrev = $section.find('.btn-prev'),
$btnNext = $section.find('.btn-next'),
itemWidth = $slideItem.outerWidth(),
listWidth = itemWidth * $slideItem.length;
$section.find('.slide_list').width(listWidth);
var boxOffsetLeft = $slideBox.offset().left;
var boxOffsetRight = $slideBox.offset().left + $slideBox.width();
var isAnimate = false;
var aniOptions = {
duration: "800", easing: "swing",
complete: function () {
isAnimate = false;
}
};
$(window).on('resize, resize_layout', function (e) {
boxOffsetLeft = $slideBox.offset().left;
boxOffsetRight = $slideBox.offset().left + $slideBox.width();
});
$btnPrev.on('click', function () {
var movePx = itemWidth,
listOffsetLeft = $slideList.offset().left;
if (isAnimate || boxOffsetLeft == listOffsetLeft) {
return false;
}
if (boxOffsetLeft - itemWidth < listOffsetLeft) {
movePx = boxOffsetLeft - listOffsetLeft;
}
isAnimate = true;
$slideList.animate({ "left": "+=" + movePx + "px" }, aniOptions);
});
$btnNext.on('click', function () {
var movePx = itemWidth,
listOffsetRight = $slideList.offset().left + listWidth;
if (isAnimate || boxOffsetRight == listOffsetRight) {
return false;
}
if (boxOffsetRight > $slideItem.filter(':last').offset().left) {
movePx = listOffsetRight - boxOffsetRight;
}
isAnimate = true;
$slideList.animate({ "left": "-=" + movePx + "px" }, aniOptions);
});
}
function getData(url, success) {
if (url.indexOf('http') == -1) {
url = utils.config('staticPath') + url;
}
//utils.log('## getDate : ' + url);
$.getScript(url, success);
}
var WIDGET_INFO = {
HomeIssue: { key: 'HomeIssue', fn: 'widgetHomeIssue' }
, HomeSectionNews: { key: 'HomeSectionNews', fn: 'widgetHomeSectionNews' }
, HomeJoinsBlog: { key: 'HomeJoinsBlog', fn: 'widgetHomeJoinsBlog' }
, HomeTrendNews: { key: 'HomeTrendNews', fn: 'widgetHomeTrendNews' }
, HomeTime7: { key: 'HomeTime7', fn: 'widgetHomeTime7' }
, HomeJMNet: { key: 'HomeJMNet', fn: 'widgetHomeJMNet' }
, HomeJPlusTop: { key: 'HomeJPlusTop', fn: 'widgetHomeJPlusTop' } //20180131 삭제예정
, HomeSectionShowcase: { key: 'HomeSectionShowcase', fn: 'widgetHomeSectionShowcase' }
, HomePrismReporters: { key: 'HomePrismReporters', fn: 'widgetHomePrismReporters' }
, HomeTodayReporter: { key: 'HomeTodayReporter', fn: 'widgetHomeTodayReporter' }
, HomeDigitalSsulzun: { key: 'HomeDigitalSsulzun', fn: 'widgetHomeDigitalSsulzun_Multiple' }
, HomeRealKeyWord: { key: 'HomeRealKeyWord', fn: 'widgetHomeRightRealKwd' }
, HomeStarReporter: { key: 'HomeStarReporter', fn: 'widgetHomeStarReporter' }
, HomeTagNews: { key: 'HomeTagNews', fn: 'widgetHomeTagNews' }
, HomeJpodEpisode: { key: 'HomeJpodEpisode', fn: 'widgetHomeJpodEpisode' }
};
$.fn.indexWidget = function () {
var $widgets = this;
$widgets.each(function (i, v) {
var $w = $(v),
type = $w.data('widgetType'),
service = $w.data('widgetService'),
fn = WIDGET_INFO[type] && WIDGET_INFO[type].fn;
//utils.log('type : ' + type);
if (type && typeof $.fn[fn] == 'function') {
$w[fn]({ type: service });
}
});
return this;
};
$.fn.rollContents = function () {
var $w = $(this),
$items = $w.find('.bd'),
changeTime = 3000,
time = 0,
timeout = null,
showIndex = 0,
trigger = false,
isOver = false;
var interV = null;
function showItem() {
$items.eq(showIndex).show().siblings().hide();
}
//utils.log('$items.length : ' + $items.length);
if ($items.length > 1) {
showItem();
rolling();
}
$items.on('mouseover', function () {
aa = clearInterval(interV)
}).on('mouseleave', function () {
rolling();
});
function addTimer() {
time++;
if (time * 1000 == changeTime) {
if (showIndex == $items.length - 1) {
showIndex = 0;
} else {
showIndex++;
}
showItem();
time = 0;
}
}
function rolling() {
interV = setInterval(function () {
//utils.log('##interver : ' + time)
addTimer();
}, 1000);
}
};
$.fn.selectImage = function () {
var $section = $(this),
$slide = $section.find('.slide_list .slide');
$thumbList = $section.find('.thumb_list');
$thumbList.find('a').on('mouseover', function () {
var $link = $(this),
$itemWrap = $link.closest('li');
$itemWrap.addClass('on').siblings().removeClass('on');
return false;
}).on('click', function () {
var $link = $(this),
$itemWrap = $link.closest('li'),
$item = $itemWrap.find('.thumb').clone(),
link = $link.attr('href'),
desc = $link.find('img').attr('alt');
$item.find('.frame').removeClass('frame').addClass('shadow');
$slide.find('.thumb').replaceWith($item);
$slide.find('.headline a').text(desc).attr('href', link);
return false;
});
};
$.fn.setHomeEffect = function () {
var $section = this;
var defaults = {
directive: 'hori',
showItem: 1
};
utils.log('setHomeEffect');
utils.log($section);
};
$.fn.widgetHomeTime7 = function () {
//utils.log('---------------------widgetHomeTime7 start');
var $w = this,
template = '' +
'
타임7 ' +
'',
directives = {
list: {
photo: { link: utils.decorators.link, image: utils.decorators.image },
summary: { link: utils.decorators.link },
title: { link: utils.decorators.link },
editor: {
html: function () {
return '' + this.editor.name + ' | ' + this.editor.position + ' ';
}
}
}
};
utils.getJsonp({
url: utils.config('apiPath') + '/' + 'time7',
success: function (res) {
render(res);
}
});
function render(d) {
//utils.log('---------------------widgetHomeTime7');
var html = '',
data = { list: [] },
time7 = d.List.filter(function (v) {
return v.Articles[0].Editor.Name;
})[0];
//utils.log(d);
//utils.log(time7);
try {
time7.Articles.forEach(function (v, i) {
var articleLink = utils.getUrlFormat(URL_NAMES.article, v.TotalId);
var imgSrc = v.Editor.Profile;
imgSrc = imgSrc.replace('/mw/time7', '/pc/main').replace('time7_editor_', 'v_time7_editor').replace('.png', '.jpg');
data.list.push({
photo: { image: { src: imgSrc }, link: { href: articleLink } },
summary: { link: { href: articleLink, text: v.Editor.Summery } },
title: { link: { href: articleLink, text: v.Title } },
editor: { name: v.Editor.Name, position: v.Editor.Position }
});
});
} catch (e) {
utils.log('widgetHomeTime7');
utils.log(e);
};
//utils.log(data);
if (data.list.length) {
html = $.renderTemplate({ template: template, data: data, directives: directives });
$w.html(html).show();
var $slide = $w.find('.slide_list'),
$page = $w.find('.slide'),
$play = $w.find('.btn-play');
//utils.log('-----------------');
//utils.log($play);
$slide.slideMotion({
infinite: true,
slidesToShow: 1,
slidesToScroll: 1,
swipe: false,
play: $play
});
} else {
$w.hide();
}
$w.find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|home|time7'));
});
}
};
$.fn.widgetHomeIssue = function () {
var $w = this,
template = '' +
'' +
'' +
'
' +
'' +
' ' +
' ' +
' ' +
' ' +
'
' +
'',
directives = {
sec: { link: utils.decorators.link },
list: {
tag: { link: utils.decorators.link },
headline: { link: utils.decorators.link }
}
};
getData('/scripts/data/home/js/right_issue_list.js', render);
function render(d) {
var html = '',
data = { sec: { link: { href: utils.config('webPcPath') + '/issue' } }, list: [] },
articles = utils.convertList(right_issue_list);
try {
articles.forEach(function (v, i) {
var issueLink = utils.getUrlFormat(URL_NAMES.issue, v.issue_seq);
var atticleLink = utils.getUrlFormat(URL_NAMES.article, v.total_id);
var regExp = /[.*]/gi;
var title = v.title.replace(regExp, "");
data.list.push({
tag: { link: { href: issueLink, text: '#' + v.issue_title } },
headline: { link: { href: atticleLink, html: title } }
});
});
} catch (e) {
utils.log('widgetHomeIssue');
utils.log(e);
};
if (data.list.length) {
html = $.renderTemplate({ template: template, data: data, directives: directives });
$w.html(html).show();
} else {
$w.hide();
}
$w.find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|home|issue'));
});
var $home_issue_page = $('#HomeIssuePage');
if ($home_issue_page.length > 0) {
$home_issue_page.find('li').each(function () {
var $item = $(this);
$item.addClass('banner_color0' + utils.getRandomNumber(1, 4, 'homeIssuePage'));
});
}
}
};
$.fn.widgetHomeTagNews = function () {
var $this = this
var apiUri = utils.config('apiPath') + "/pagecall/?u=" + utils.config('staticPath') + "/scripts/data/issue/js/tagnews_article_list_pchome.json";
$.when(
$.ajax({
type: "GET",
dataType: 'json',
url: apiUri,
success: function (data) {
var html = '';
var kwdCnt = data.length;
var cnti = 1;
html += '';
html += '
';
$.each(data, function (i, v) {
html += '';
html += ' ';
html += ' ';
html += ' ' + data[i].edit_iss_title + ' ';
html += ' ';
$.each(data[i].kwd_list, function (j) {
if (data[i].kwd_list[j].length > 0) {
html += '#' + data[i].kwd_list[j] + ' ';
}
});
html += ' ';
html += ' ';
html += ' ';
html += ' ' + data[i].edit_iss_title + ' 관련기사 ';
$.each(data[i].article_list, function (k) {
var articleLink = utils.getUrlFormat(URL_NAMES.article, data[i].article_list[k].total_id);
var articleThumbnail = utils.getIrPath(utils.getPdsFullPath(data[i].article_list[k].thumbnail), 40, 40)
html += ' ';
if (data[i].article_list[k].thumbnail.length > 0) {
html += ' ';
}
html += ' ';
html += ' ';
html += ' ' + data[i].article_list[k].title + ' ';
html += ' ';
html += ' ';
html += ' ';
html += ' ';
});
html += ' ';
html += '';
});
html += ' ';
$this.html(html);
$this.show();
$this.find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'Joongang|home|issuepkg'));
});
},
error: function () {
$this.hide();
}
})
).then(function () {
// TagNews
var $tagNews = null;
var $tagNewsItems = null;
var $overTagNewsItem = null;
$tagNews = $('.main_tagnews ul');
$tagNewsItems = $tagNews.find('li');
$tagNews.mouseleave(function () {
if ($overTagNewsItem != null) {
var $item = $overTagNewsItem;
$item.removeClass('active');
}
});
$tagNewsItems.mouseenter(function () {
if ($overTagNewsItem != null) {
var $item = $overTagNewsItem;
$item.removeClass('active');
}
$overTagNewsItem = $(this);
var $item = $overTagNewsItem;
$item.addClass('active');
});
})
};
$.fn.widgetHomeSectionNews = function () {
var $w = this,
sectionDatas = [
{ name: '정치', code: 'politics', url: '/scripts/data/home/js/leading_article_politics.js' },
//{ name: '경제', code: 'money', url: '/scripts/data/home/js/leading_article_economy.js' },
{ name: '더,오래', code: 'retirement', url: '/scripts/data/home/js/leading_article_retirement.js' },
{ name: '사회', code: 'society', url: '/scripts/data/home/js/leading_article_society.js' },
{ name: '국제', code: 'world', url: '/scripts/data/home/js/leading_article_world.js' },
{ name: '문화', code: 'culture', url: '/scripts/data/home/js/leading_article_culture.js' },
{ name: '오피니언', code: 'opinion', url: '/scripts/data/home/js/leading_article_opinion.js' },
{ name: '스포츠', code: 'sports', url: '/scripts/data/home/js/leading_article_sports.js' },
{ name: '연예', code: 'star', url: '/scripts/data/home/js/leading_article_star.js' }
],
dataList = [],
template = '' +
'
섹션 주요 뉴스 ' +
'' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
' ' +
' ' +
'
정치 뉴스 더보기' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
이전 ' +
'
다음 ' +
'
' +
'
',
directives = {
sections: {
section: { link: utils.decorators.link },
articles: { link: utils.decorators.link },
reporters: {
link: utils.decorators.link,
'data-dept': function () {
return this.section.link.text;
}
}
}
};
function initData() {
var obj = sectionDatas[0];
if (obj && obj.url) {
getData(obj.url, function () {
try {
dataList.push({ name: obj.name, code: obj.code, list: utils.convertList(section_article_list) });
} catch (e) {
};
sectionDatas.splice(0, 1);
initData();
});
} else {
render();
}
}
initData();
function render() {
var html = '',
data = { sections: [] };
try {
dataList.forEach(function (v, i) {
var obj = { section: {}, articles: [], reporters: [] };
obj.section.link = { href: utils.getUrlFormat(URL_NAMES.section, v.code), text: v.name };
v.list.forEach(function (_v) {
obj.articles.push({ link: { href: utils.getUrlFormat(URL_NAMES.article, _v.total_id), html: _v.title } });
obj.reporters.push({ link: { href: utils.getUrlFormat(URL_NAMES.reporter, _v.reporter_seq) }, image: { src: _v.reporter_img } });
});
data.sections.push(obj);
});
} catch (e) {
utils.log('widgetHomeSectionNews');
utils.log(e);
};
if (data.sections.length) {
html = $.renderTemplate({ template: template, data: data, directives: directives });
$w.html(html).show();
$w.find('.slide_list').width($w.find('.slide').length * 220);
$w.find('img[data-bind="image"]').setDefaultImage();
$w.find('dl[data-bind="reporters"]').each(function () {
var $reporters = $(this);
$reporters.prepend('' + $reporters.data('dept') + ' 부문 기자 ');
});
homeSlide($w);
} else {
$w.hide();
}
$w.find('dl[data-bind="reporters"] a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|home|sectionreporter'));
});
$w.not('dl[data-bind="reporters"]').find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|home|sectiontop'));
});
}
};
$.fn.widgetHomeJMNet = function () {
//utils.log('^^ widgetHomeJMNet');
var $w = this,
secHtml = '' +
'
중앙그룹 ' +
'' +
'',
template = '' +
'' +
'' +
' ' +
' ' +
' ',
directives = {
section: { link: utils.decorators.link },
list: {
summary: { link: utils.decorators.link, image: utils.decorators.image },
title: { link: utils.decorators.link, image: utils.decorators.image }
}
};
$w.html(secHtml).show();
$w.find('.tab a').on('click', function () {
var $link = $(this),
$wrap = $link.parent(),
type = $(this).data('type');
//utils.log('click type : ' + type);
$wrap.addClass('on').siblings().removeClass('on');
setActiveData(type);
return false;
});
setActiveData();
//trend_news_hits_list
function setActiveData(type) {
type = type || 'jtbc';
var urlInfo = {
jtbc: { url: 'https://fs.jtbc.joins.com/common/data/news/jtbc_top_news_vod.js', name: 'JTBC', data: 'jtbc_top_news_vod', link: "http://jtbc.joins.com/" },
jmaganine_mm: { url: '/scripts/data/home/js/jmnet_channel_jmagazine_mm.js', name: '월간중앙', data: 'jmnet_channel_list', link: "http://jmagazine.joins.com/monthly" },
jmaganine_mf: { url: '/scripts/data/home/js/jmnet_channel_jmagazine_mf.js', name: '포브스', data: 'jmnet_channel_list', link: "http://jmagazine.joins.com/forbes" },
jmaganine_me: { url: '/scripts/data/home/js/jmnet_channel_jmagazine_me.js', name: '이코노미스트', data: 'jmnet_channel_list', link: "http://jmagazine.joins.com/economist" },
jmaganine_mw: { url: '/scripts/data/home/js/jmnet_channel_jmagazine_mw.js', name: '뉴스위크한국판', data: 'jmnet_channel_list', link: "http://jmagazine.joins.com/newsweek" },
koreaDaily: { url: '/scripts/data/home/js/jmnet_channel_korea_daily.js', name: 'Korea Daily', data: 'jmnet_channel_list', link: "http://www.koreadaily.com/" },
china: { url: '/scripts/data/home/js/jmnet_channel_china.js', name: '중국연구소', data: 'jmnet_channel_list', link: "http://china.joins.com/portal/index.html" }
},
obj = urlInfo[type];
//utils.log('$$ setActiveData url : ' + obj.url);
if (obj.url) {
getData(obj.url, render);
}
function render() {
utils.log('## widgetHomeJMNet render : ' + obj.name);
var html = '',
data = { list: [] },
articles = utils.convertList(window[obj.data]);
//utils.log(articles);
try {
articles.forEach(function (v, i) {
var atticleLink = utils.getUrlFormat(URL_NAMES.article, v.total_id);
var target = '_self';
if (v.link) {
target = '_blank';
atticleLink = v.link;
}
//utils.log('atticleLink : ' +atticleLink);
data.list.push({
section: obj.name,
title: { link: { href: atticleLink, html: v.title, target: target } },
summary: { link: { href: atticleLink, html: v.summary, target: target } }
});
});
} catch (e) {
utils.log('widgetHomeJMNet Data Mapping Error.');
utils.log(e);
};
utils.log(data);
if (data.list.length) {
html = $.renderTemplate({ template: template, data: data, directives: directives });
html = '' + obj.name + ' ' + $(html).html() + '' + obj.name + ' 바로가기 ';
$w.find('.con').html(html);
$w.find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|home|medianetwork'));
});
} else {
$w.find('.con').html('');
}
}
}
};
$.fn.widgetHomeTrendNews = function () {
var $w = this,
secHtml = '' +
'' +
'' +
'',
template = '' +
'조회순 ' +
'' +
'' +
' ' +
'' +
'' +
' ' +
' ' +
' ' +
' ' +
' ' +
' ' +
'' +
'조회순 ' +
' ' +
' ' +
' ' +
' ',
directives = {
sec: { link: utils.decorators.link },
list: {
position: {
text: function (params) {
$(params.element).addClass('rank' + (this.position < 10 ? '0' + this.position : this.position));
return this.position;
}
},
thumb: {
link: utils.decorators.link,
image: utils.decorators.image,
html: function (params) {
var $ele = $(params.element);
if (!this.thumb.image.src) {
$ele.remove();
}
}
},
title: { link: utils.decorators.link },
reporter: { link: utils.decorators.link },
count: {
html: function (params) {
//utils.log(this);
var $ele = $(params.element);
$ele.find('span').addClass(this.count.cls);
$ele.find('em').text(this.count.text);
//return this.count.cls;
}
}
}
};
$w.html(secHtml).show();
$w.find('.tab a').on('click', function () {
var $link = $(this),
$wrap = $link.parent(),
type = $(this).data('type');
//utils.log('click type : ' + type);
$wrap.addClass('on').siblings().removeClass('on');
setActiveData(type);
return false;
});
setActiveData();
//trend_news_hits_list
function setActiveData(type) {
type = type || 'hits';
var urlInfo = {
hits: { url: '/scripts/data/common/js/trend_news_hits_list.js', name: 'trend_news_hits_list', cls: 'icon_trend_view', property: 'clickcnt' },
comment: { url: '/scripts/data/common/js/trend_news_comment_list.js', name: 'trend_news_comment_list', cls: 'icon_trend_comment', property: 'replycnt' },
share: { url: '/scripts/data/common/js/trend_news_share_list.js', name: 'trend_news_share_list', cls: 'icon_trend_share', property: 'shrcnt' },
recommend: { url: '/scripts/data/common/js/trend_news_recommend_list.js', name: 'trend_news_recommend_list', cls: 'icon_trend_recommend', property: 'likecnt' },
scrap: { url: '/scripts/data/common/js/trend_news_scrap_list.js', name: 'trend_news_scrap_list', cls: 'icon_trend_scrap ', property: 'scbcnt' },
total: { url: '/scripts/data/common/js/trend_news_total_list.js', name: 'trend_news_total_list', cls: 'icon_trend_view', property: 'clickcnt' }
},
obj = urlInfo[type];
//utils.log('$$ setActiveData url : ' + obj.url);
if (obj.url) {
getData(obj.url, render);
}
function render() {
var html = '',
data = { list: [] },
articles = utils.convertList(window[obj.name]),
clocNum = '';
try {
articles.forEach(function (v, i) {
if (i < 10) {
var reporterLink = utils.getUrlFormat(URL_NAMES.issue, v.reporter_id),
atticleLink = utils.getUrlFormat(URL_NAMES.article, v.total_id),
displayCount = utils.getDisplayCount(v[obj.property]);
data.list.push({
position: i + 1,
thumb: { image: { src: utils.getIrPath(utils.getPdsFullPath(v.thumbnail), 112, 70, '.tn_250.jpg') }, link: { href: atticleLink } },
title: { link: { href: atticleLink, html: v.title } },
reporter: { link: { href: reporterLink, html: v.reporter_name } },
count: { cls: obj.cls, text: displayCount }
});
}
});
} catch (e) { utils.log(e); };
//utils.log(data);
if (data.list.length) {
$(".scroll", $w).mCustomScrollbar("destroy");
html = $.renderTemplate({ template: template, data: data, directives: directives });
$w.find('.con').html(html);
$(".scroll", $w).mCustomScrollbar({ theme: "inset" });
/* 트렌드 뉴스 cloc */
if (type == 'hits') {
clocNum = '1';
} else if (type == 'comment') {
clocNum = '2';
} else if (type == 'share') {
clocNum = '3';
} else if (type == 'recommend') {
clocNum = '4';
} else if (type == 'scrap') {
clocNum = '5';
}
$w.find('div.scroll a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|home|trendnews' + clocNum));
});
/* 트렌드 뉴스 cloc */
} else {
$w.find('.con').html('');
}
}
}
};
//20180115
$.fn.widgetHomeSectionShowcase = function(options) {
var $this = this, dataUri = "", showcaseType = $.trim(options.type), showcaseInfo = {};
if(showcaseType == "retirement") {
showcaseInfo = {
title: "더, 오래",
titleImg: utils.config('imagePath') + "/pc/main/t_retirement.png",
dataUri: "/scripts/data/" + showcaseType + "/js/index_showcase_2.js",
mainUrl: utils.config('webPcPath') + "/" + showcaseType + "/",
cloc: "?cloc=joongang|home|" + showcaseType
}
}
else if(showcaseType == "mm") {
showcaseInfo = {
title: "Mr.밀리터리",
titleImg: utils.config('imagePath') + "/pc/main/t_mm.png",
dataUri: "/scripts/data/" + showcaseType + "/js/index_showcase_v2.js",
mainUrl: utils.config('webPcPath') + "/" + showcaseType + "/",
cloc: "?cloc=joongang|home|" + showcaseType
}
}
else if(showcaseType == "nk") {
showcaseInfo = {
title: "통일무지개",
titleImg: utils.config('imagePath') + "/pc/main/t_nk.png",
dataUri: "/scripts/data/" + showcaseType + "/js/index_showcase_v2.js",
mainUrl: utils.config('webPcPath') + "/" + showcaseType + "/",
cloc: "?cloc=joongang|home|" + showcaseType
}
}
else {
return;
}
$.when(
$.ajax({
type: "GET",
//url: "http://dev.apis.joins.com/pagecall/?u=http://dev.static.joins.com/joongang_15re" + showcaseInfo.dataUri,
url: utils.config('apiPath') + "/pagecall/?u=" + utils.config('staticPath') + showcaseInfo.dataUri,
dataType: "JSON",
success: function (json) {
try {
if (json.length == 0) { $this.hide(); return; }
var strHtml = '' +
' ' +
'';
for (var i = 0; i < json.length; i++) {
var list = json[i];
var strTotalId = list.total_id;
var strTitle = $.trim(list.title).replace(/\"/ig, """);
var strContent = list.content.replace(/\"/ig, """);
var strImage = $.trim(list.image);
var strLink = $.trim(list.link.url) + $.trim(showcaseInfo.cloc);
var strLinkTarget = "_self";//list.link.url.target;
if (strContent != "" && strImage != "" && strLink != "") {
strContent = strContent.replace(/\[.+?\]\s*/ig, "");
strContent = strContent.replace(/[.+?]\s*/ig, "");
strHtml += '' +
'
';
}
}
strHtml += '
';
$this.html(strHtml);
$('.slide_wrap', $this).slick({speed:300, arrows:false, dots:true});
}
catch (e) {
$this.hide();
}
},
error: function () {
$this.hide();
}
})
).then(function () {
});
};
//스타기자
$.fn.widgetHomePrismReporters = function () {
var $this = this;
$.when(
$.ajax({
type: "GET",
//url: "http://dev.apis.joins.com/IssueSeries/LatestList/?exceptionID=0&exceptionSeqNo=1008&getCnt=12",
url: utils.config('apiPath') + '/IssueSeries/LatestList/?exceptionID=0&exceptionSeqNo=1013&getCnt=12',
dataType: "JSON",
success: function (json) {
try {
if (json.Result == false || json.List.length == 0) { $this.hide(); return; }
var strHtml = '' +
'스타기자 ' +
'';
for (var i = 0; i < json.List.length; i++) {
var list = json.List[i];
var strStarTitle = list.starTitle;
var strTotalId = list.totalID;
var strTitle = $.trim(list.articleTitle);
var strColorCode = list.colorCode;
var strRepPhoto = list.repPhoto;
var strIssSeriesLink = utils.config('webPcPath') + "/issueseries/" + list.seqNo + "?cloc=joongang|home|starreporterlist";
var strArticleLink = utils.config('webPcPath') + "/article/" + strTotalId + "?cloc=joongang|home|starreporterlist";
var strIssueLink = utils.config('webPcPath') + "/issue/" + list.issSeq + "?cloc=joongang|home|starreporterlist";
var strReporterLink = utils.config('webPcPath') + "/reporter/" + list.repSeq + "?cloc=joongang|home|starreporterlist";
strTitle = strTitle.replace(/\[.+?\]\s*/ig, "");
strTitle = strTitle.replace(/[.+?]\s*/ig, "");
if((i % 4) == 0) {
strHtml += '' +
'
';
}
}
strHtml += '
';
$this.html(strHtml);
//$('.slide_wrap', $this).slick({speed:300, arrows:false, dots:true});
$('.prism_star .slide_wrap').slick({speed:300});
}
catch (e) {
alert(e.description);
$this.hide();
}
},
error: function () {
$this.hide();
}
})
).then(function () {
});
};
//20180131 삭제예정
$.fn.widgetHomeJPlusTop = function () {
var $w = this,
dataUri = '/static/traveloftheweek',
widgetHtml = '
',
template = '' +
'' +
'' +
'
' +
'' +
'' +
' ' +
' ' +
' ' +
' ' +
' ' +
' ' +
' ' +
'
' +
'',
directives = {
list: {
article: {
thumb: {
link: utils.decorators.link,
image: utils.decorators.image,
html: function (params) {
if (!this.thumb.image.src) {
$(params.element).remove();
}
}
},
title: { link: utils.decorators.link },
summary: { link: utils.decorators.link }
},
reporter: {
html: function () {
return '' + this.reporter.name + ' | ' + this.reporter.desc + ' ';
}
}
}
};
utils.getJsonp({
url: utils.config('apiPath') + '/static/homejplusarticles',
success: function (res) {
render(res);
}
});
function render(res) {
var html = '',
data = { list: [] };
try {
res.List.forEach(function (v) {
var reporter = v.Reporters[0] || {},
reporterLink = utils.getUrlFormat(URL_NAMES.reporter, reporter.Id),
articleLink = utils.getUrlFormat(URL_NAMES.article, v.Id);
data.list.push({
article: {
thumb: { link: { href: articleLink, text: v.Title }, image: { src: v.Thumbnail } },
title: { link: { href: articleLink, text: v.Title } },
summary: { link: { href: articleLink, text: v.Summary } }
},
reporter: { link: reporterLink, name: reporter.Name, desc: reporter.Description }
});
});
} catch (e) {
};
//utils.log(data);
if (data.list.length) {
html = $.renderTemplate({ template: template, data: data, directives: directives });
$w.html(html).show();
} else {
$w.hide();
}
$w.find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|home|jplustop'));
});
}
};
$.fn.widgetHomeTodayReporter = function () {
var $w = this;
getData('/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.widgetHomeDigitalSsulzun_Multiple = function () {
var $w = this;
getData('/scripts/data/home/js/right_digital_ssulzun_list.js', render);
function render(d) {
var html = '';
try {
if (right_digital_ssulzun_list != undefined) {
var articles = utils.convertList(right_digital_ssulzun_list);
var atticleLink = utils.getUrlFormat(URL_NAMES.article, articles[0].total_id);
var listLink = utils.config('webPcPath') + '/opinion/debate_polllist';
var countArray = [];
var itemArray = [];
for (var i = 1; i <= articles[0].itemcnt; i++) {
switch (i) {
case 1:
countArray.push({ "id": i, "title": articles[0].item_1, "votecnt": articles[0].itemvote_1 });
break;
case 2:
countArray.push({ "id": i, "title": articles[0].item_2, "votecnt": articles[0].itemvote_2 });
break;
case 3:
countArray.push({ "id": i, "title": articles[0].item_3, "votecnt": articles[0].itemvote_3 });
break;
case 4:
countArray.push({ "id": i, "title": articles[0].item_4, "votecnt": articles[0].itemvote_4 });
break;
//case 5:
// countArray.push({ "id": i, "title": articles[0].item_5, "votecnt": articles[0].itemvote_5 });
// break;
}
}
for (var i = 0; i < countArray.length; i++) {
itemArray.push(countArray[i]);
}
countArray.sort(function (a, b) {
return b.votecnt - a.votecnt;
});
var firstItem = countArray.shift();
var secondItem = countArray.shift();
var Sdate = articles[0].sdate.substring(0, 4) + "." + articles[0].sdate.substring(4, 6) + "." + articles[0].sdate.substring(6, 8);
var Edate = articles[0].edate.substring(0, 4) + "." + articles[0].edate.substring(4, 6) + "." + articles[0].edate.substring(6, 8);
html += ' ';
html += '
';
html += '
';
html += ' ';
html += '
';
html += ' ';
html += ' Q ';
html += ' ' + articles[0].title + ' ';
html += ' ';
itemArray.forEach(function (v) {
var cls = '';
if (v.id == firstItem.id) cls = 'answer01';
if (v.id == secondItem.id) cls = 'answer02';
var percent = Math.round(v.votecnt / articles[0].votecnt * 100);
html += '';
html += ' ' + percent + '% ';
html += ' ' + v.title + ' ';
html += ' ';
});
//if(articles[0].itemcnt > 5) {
// html += '';
// html += ' 보기 더 보기... ';
// html += ' ';
//}
html += ' ';
html += '
';
html += ' 참여하기 ';
html += ' ';
html += '
';
html += ' ';
$w.html(html).show();
}
else {
$w.hide();
}
} catch (e) {
utils.log('widgetHomeDigitalSsulzun_Multiple');
utils.log(e);
};
$w.find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|home|digitalssulzun'));
});
}
};
$.fn.widgetHomeDigitalSsulzun = function () {
var $w = this,
template = '' +
'' +
'' +
'
' +
'' +
'Q ' +
' ' +
' ' +
' ' +
' ' +
' ' +
' ' +
'
' +
'',
directives = {
sec: { link: utils.decorators.link },
list: {
date: {
html: function () {
var Sdate = this.sdate.substring(0, 4) + "." + this.sdate.substring(4, 6) + "." + this.sdate.substring(6, 8);
var Edate = this.edate.substring(0, 4) + "." + this.edate.substring(4, 6) + "." + this.edate.substring(6, 8);
return "참여기간 : " + Sdate + " ~ " + Edate;
}
},
right: {
"class": function () {
if (this.itemvote_1 > this.itemvote_2) return "answer02";
else return "answer01";
},
html: function () {
var percent = Math.round(this.itemvote_1 / this.votecnt * 100);
return '' + this.item_1 + ' ' + percent + '% ';
}
},
left: {
"class": function () {
if (this.itemvote_2 >= this.itemvote_1) return "answer02";
else return "answer01";
},
html: function () {
var percent = Math.round(this.itemvote_2 / this.votecnt * 100);
return '' + this.item_2 + ' ' + percent + '% ';
}
},
title: { link: utils.decorators.link },
link: utils.decorators.link
}
};
getData('/scripts/data/home/js/right_digital_ssulzun_list.js', render);
function render(d) {
var html = '',
data = { sec: { link: { href: utils.config('webPcPath') + '/opinion/debate_polllist' } }, list: [] }
try {
var articles = utils.convertList(right_digital_ssulzun_list);
var atticleLink = utils.getUrlFormat(URL_NAMES.article, articles[0].total_id);
data.list.push({
title: { link: { href: atticleLink, html: articles[0].title } },
item_1: articles[0].item_1,
item_2: articles[0].item_2,
sdate: articles[0].sdate,
edate: articles[0].edate,
votecnt: articles[0].votecnt,
itemcnt: articles[0].itemcnt,
itemvote_1: articles[0].itemvote_1,
itemvote_2: articles[0].itemvote_2,
link: { href: atticleLink }
});
} catch (e) {
utils.log('widgetHomeDigitalSsulzun');
utils.log(e);
};
if (data.list.length) {
html = $.renderTemplate({ template: template, data: data, directives: directives });
$w.html(html).show();
} else {
$w.hide();
}
$w.find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|home|digitalssulzun'));
});
}
};
$.fn.widgetHomeRightRealKwd = function () {
var slideRealKwd = {
init: function () {
this.slideInit2();
},
slideInit2: function () {
var slide = $('.rankup_wrap .slide_list').slick({
speed: 0,
slidesToShow: 3,
slidesToScroll: 3
});
}
};
var $w = this,
template = '' +
'
실시간 인기 검색어 ' +
''
directives = {
list: {
link: utils.decorators.link,
kwd: {
html: function () {
var srownum, hoticon = '';
if (this.hot == 'h') hoticon = ' HOT ';
if (this.rownum > 9) {
srownum = this.rownum;
} else {
srownum = '0' + (this.rownum);
}
return '';
}
},
}
};
utils.ajaxGet({
dataType: 'json',
url: utils.config('apiPath') + '/pagecall/?u=' + utils.config('staticPath') + '/scripts/data/sonagi/json/right_real_kwd_auto.json',
success: function (data) {
if (data.length > 0) {
render(data);
}
},
//error: render(d_org)
});
function render(res) {
var html = '',
data = { list: [] };
try {
res.forEach(function (v, i) {
var articleLink = utils.getUrlFormat(URL_NAMES.article, v.total_id);
data.list.push({
hot: v.hot,
kwd: v.kwd,
total_id: v.total_id,
updown: v.updown,
link: articleLink,
rownum: i + 1
});
});
} catch (e) {
};
if (data.list.length) {
html = $.renderTemplate({ template: template, data: data, directives: directives });
$w.html(html).show();
slideRealKwd.init();
} else {
$w.hide();
$(".rankup_wrap").hide();
}
$w.find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|home|realtimekeyword'));
});
}
};
$.fn.widgetHomeTodayReporterV2 = function () {
var $w = this;
getData('/scripts/data/home/js/right_today_reporter_v2_gen.js', render);
var slideReporterList = {
init: function () {
this.slideInit();
},
slideInit: function () {
var slide = $('.reporter_area .slide_wrap').slick({
arrows: false,
dots: true,
infinite: false,
speed: 300,
slidesToShow: 1,
slidesToScroll: 1
});
}
};
function render(d) {
var idx, todayReorter, reporterLink, listIdx;
reporterList = utils.convertList(today_reporter_list_v2);
var strHtml = [];
strHtml.push("");
strHtml.push(" ");
try {
if (reporterList.length > 5) {
reporterList.length = 5;
}
for (listIdx = 0; listIdx < reporterList.length; listIdx++) {
todayReorter = reporterList[listIdx];
reporterLink = utils.config('webPcPath') + "/reporter/" + todayReorter.ReporterSeq;
if (todayReorter.ReporterImg == "") {
todayReorter.ReporterImg = utils.config('imagePath') + "/pc/issue/v_noimg_journalist.jpg";
}
strHtml.push("
");
strHtml.push("
");
strHtml.push("
");
if (todayReorter.ArticleLink == "") {
strHtml.push("
" + todayReorter.ArticleTitle + " ");
} else {
strHtml.push("
" + todayReorter.ArticleTitle + " ");
}
if (todayReorter.IssueSeq == "") {
strHtml.push("
" + todayReorter.IssueTitle + " ");
} else {
strHtml.push("
" + todayReorter.IssueTitle + " ");
}
strHtml.push("
");
strHtml.push("
");
}
strHtml.push("
");
strHtml.push("
");
} catch (e) {
utils.log('widgetHomeTodayReporter');
utils.log(e);
};
if (reporterList.length > 0) {
$w.append(strHtml.join(''));
$w.show();
slideReporterList.init();
} else {
$w.hide();
}
$w.find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|home|todayreporter'));
});
}
};
//스타기자
$.fn.widgetHomeStarReporter = function () {
var $this = this;
$.when(
$.ajax({
type: 'GET',
url: utils.config('apiPath') + '/IssueSeries/LatestList?homeYN=Y',
dataType: 'JSON',
success: function (json) {
try {
if (json.Result == false || json.List.length == 0) { $this.hide(); return; }
var html = '' +
'' +
'
스타기자 ' +
'' +
'';
for (var i = 0; i < json.List.length; i++) {
var list = json.List[i];
var starLink = utils.config('webPcPath') + '/issueseries/' + list.seqNo + "?cloc=joongang|home|starreporter1";
var articleLink = utils.config('webPcPath') + '/article/' + list.totalID + "?cloc=joongang|home|starreporter2";
var articleImg = utils.config('irPath') + '/?u=' + utils.getPdsFullPath(list.articleThumbnail) + '&w=230&h=159&t=k&bg=ffffff';
var reporterLink = utils.config('webPcPath') + '/reporter/' + list.repSeq + "?cloc=joongang|home|starreporter3";
var articleTitle = list.articleTitle;
if (articleTitle != "") {
articleTitle = articleTitle.replace(/\[.+?\]\s*/ig, "");
articleTitle = articleTitle.replace(/[.+?]\s*/ig, "");
}
html +=
'
';
}
html += '
';
$this.html(html);
$this.show();
$('.star_article_v2 .slide_list').slick({
centerMode: true,
variableWidth: true
});
} catch (e) {
$this.hide();
}
},
error: function () {
$this.hide();
}
})
)
};
$.fn.widgetHomeJpodEpisode = function () {
var $this = this;
try {
$.when(
$.ajax({
type: 'GET',
url: utils.config('apiPath') + "/pagecall/?u=" + utils.config('staticPath') + "/scripts/data/home/jpod/xml/right_jpod.xml",
dataType: "XML",
success: function (xml) {
if ($(xml).find("article").length > 0) {
var e = $(xml).find("article").first();
var selcted = $(e).find("select").text();
if (selcted == "Y") {
$.ajax({
type: 'GET',
url: utils.config('apiPath') + "/pagecall/?u=" + utils.config('staticPath') + "/scripts/data/jpod/episode.xml",
dataType: "XML",
success: function (xml) {
if ($(xml).find("article").length > 0) {
var html = '' +
'' +
'
J팟 중앙일보 기자들의 다채로운 팟캐스트 공간 ' +
'' +
'';
for (var i = 0; i < $(xml).find("article").length; i++) {
var e = $(xml).find("article").eq(i);
var title = $(e).find("title").text();
var seq = $(e).find("total_id").text();
var chtitle = $(e).find("subtitle").text();
var epno = $(e).find("epno").text();
html += '
' + chtitle + ' ' + epno + ' ' + title + '
';
}
html += '
';
html += '';
$this.html(html);
$this.show();
if ($('.jpod_temp .slide_wrap p').length > 1) {
$('.jpod_temp .slide_wrap').slick({
dots: true, arrows: false, infinite: true, vertical: true, swipe: false, verticalSwiping: true, slidesToShow: 1, autoplay: true, autoplaySpeed: 1500
})
}
}
}, error: function () {
$this.hide();
}
})
}
}
}, error: function () {
$this.hide();
}
})
).then(function () {
})
} catch (e) {
$this.hide();
}
};
})(window, document, jQuery);
// 새로고침에서 사용
function homeLiveContent() {
var total_id = "";
var url = "";
var $DivLiveTimeline = $("#div_live_timeline");
try {
$.when(
$.ajax({
type: "GET",
//url: "http://dev.apis.joins.com/pagecall/?u=http://dev.static.joins.com/joongang_15re/scripts/data/home/xml/right_live_article.xml",
url: utils.config('apiPath') + "/pagecall/?u=" + utils.config('staticPath') + "/scripts/data/home/xml/right_live_article.xml",
dataType: "XML",
success: function (xml) {
if ($(xml).find("article").length > 0) {
var e = $(xml).find("article").first();
total_id = $(e).find("total_id").text();
}
},
error: function () {
$DivLiveTimeline.hide();
}
})
).then(function () {
if (total_id !== undefined && total_id !== null && total_id !== "") {
url = utils.config('apiPath') + "/pagecall/?u=" + utils.config('webPcPath') + "/article/homelivecontent?totalid=" + total_id + "&page=1&order=Newly";
$.ajax({
type: "GET",
url: url,
dataType: "HTML",
success: function (content) {
try {
if (content !== undefined && content !== null && content !== "") {
$DivLiveTimeline.html(content);
$DivLiveTimeline.find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|home|timeline'));
});
$DivLiveTimeline.show();
$("#div_live_timeline_scroll", $DivLiveTimeline).mCustomScrollbar({ theme: "inset", autoHideScrollbar: false });
}
else {
$DivLiveTimeline.hide();
}
}
catch (e) {
$DivLiveTimeline.hide();
}
},
beforeSend: function () {
$(".timeline_list", $DivLiveTimeline).hide();
},
complete: function () {
$(".timeline_list", $DivLiveTimeline).show();
},
error: function () {
$DivLiveTimeline.hide();
}
});
}
else {
$DivLiveTimeline.hide();
clearInterval(homeLiveRefreshTimer);
}
});
}
catch (e) { }
finally {
return total_id;
}
}