';
$("#divRealtime").html(html);
$("#divRealtime").show();
// 실시감검색어 뉴스 Cloc
$("#divRealtime").find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|article|realtime'));
});
}
else {
$("#divRealtime").hide();
}
},
error: function () {
$("#divRealtime").hide();
}
})
).then(function () {
var slideFtArticle2 = {
init: function () {
this.slideInit();
},
slideInit: function () {
var realtime_slide = $(".ft_realtime_article .slide_wrap").slick({
arrows: true,
dots: true,
infinite: true,
speed: 300,
slidesToShow: 1,
slidesToScroll: 1
});
}
};
slideFtArticle2.init();
});
};
// 아웃스트림 광고
$.fn.widgetOutstreamAD = function () {
var $w = this;
var html = '';
var menuKey = utils.menu.getPageMenuKey().toLowerCase();
if (menuKey.indexOf('money') !== -1) {
html = '';
}
else if (menuKey.indexOf('culture') !== -1) {
html = '';
}
else if (menuKey.indexOf('sports') !== -1) {
html = '';
}
else {
html = '
';
var _c = new Date().getTime();
var adLink = '//ads.admaru.com/js/joongang_admaru_icv.js?t=' + _c
html += '';
html += '
';
}
$w.after(html);
};
// 오피니언 비즈니스현장에 묻다
$.fn.widgetSpecialColumnD = function () {
var $w = this,
widgetName = '비즈니스 현장에 묻다',
keywordStr = '"비즈니스 현장에 묻다"',
listLink = utils.config('webPcPath') + '/find/list?Keyword=' + encodeURIComponent(keywordStr) + '&scopetype=Title&servicecode=20&display=' + encodeURIComponent(widgetName),
widgetHtml = '
',
template = '
',
directives = {
list: { link: utils.decorators.link }
};
getApiData('/static/specialcolumnd', 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.widgetEditorialInsite = function () {
var $w = this,
widgetName = '한반도평화워치 / 차이나인사이트',
listLink = utils.config('webPcPath') + '/find/list?Keyword=' + encodeURIComponent('한반도평화워치') + '|' + encodeURIComponent('차이나인사이트') + '&scopetype=Title&servicecode=20&display=' + encodeURIComponent(widgetName),
widgetHtml = '
',
template = '
',
directives = {
list: { link: utils.decorators.link }
};
getApiData('/static/editorialInsite', 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.widgetDigitalOpinion = function () {
var $w = this,
widgetName = '퍼스펙티브',
listLink = utils.config('webPcPath') + '/find/list?Keyword=' + encodeURIComponent(widgetName) + '&ServiceCode=20&display=' + encodeURIComponent(widgetName),
widgetHtml = '
',
template = '
',
directives = {
list: { link: utils.decorators.link }
};
getApiData('/static/digitalopinion', 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.widgetSpecialCartoon = function () {
var $w = this,
widgetName = '이코노믹스',
keywordStr = '이코노믹스',
listLink = utils.config('webPcPath') + '/find/list?Keyword=' + encodeURIComponent(keywordStr) + '&scopetype=Title&servicecode=20&display=' + encodeURIComponent(widgetName),
widgetHtml = '
',
template = '
',
directives = {
list: { link: utils.decorators.link }
};
getApiData('/static/specialcartoon', 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 = '미래를 묻다',
keywordStr = '"미래를 묻다"',
listLink = utils.config('webPcPath') + '/find/list?Keyword=' + encodeURIComponent(keywordStr) + '&scopetype=Title&servicecode=20&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();
}
}
};
//jplus 필진 최신글보기, 문구추가
/*
'
'
*/
$.fn.articleJplusRecentlyNews = function () {
var url = utils.config('jplusPath') + '/Scripts/layout.js',
totalId = $('#total_id').val(),
self = this,
jplusNoticeHtml = '
' +
'
' +
'
J플러스의 게시물은 중앙일보 편집 방향 및 논조와 다를 수 있습니다.
' +
'
';
if (totalId !== undefined && totalId !== '') {
$.getScript(url, function () {
try {
self.append('
');
jplus.layout.articles.renderHtml(totalId);
self.find('.ab_jplus').before(jplusNoticeHtml);
} catch (e) {
}
});
} else {
//문구 추가
self.append(jplusNoticeHtml);
}
};
$.fn.widgetProbityLaw = function () {
$this = this;
$.when(
$.ajax({
type: "GET",
url: utils.config('apiPath') + "/pagecall/?u=" + utils.config('staticPath') + "/scripts/data/issue/xml/issue_top_article.xml",
dataType: "XML",
success: function (xml) {
if ($(xml).find("article").length > 0) {
var html = '';
var e = $(xml).find("article").first();
var title = $(e).find("title").text();
var content = $(e).find("content").text();
var image = $(e).find("image").text();
var url = $(e).find("link").text();
var target = $(e).find("target").text();
var relarticle = $(e).find("relarticle").text();
html += image.length > 5 ? '
' : '';
html += '
';
html += '
' + title + ' ';
if (relarticle.length > 5) {
html += '
';
html += relarticle
html += ' ';
}
else {
html += '
' + content + ' ';
}
html += '
';
$this.html(html);
$this.show();
}
},
error: function () {
$this.hide();
}
})
)
};
// 김민석의 Mr.밀리터리 캠페인
$.fn.widgetMmCampaign = 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
}
};
$.getScript(utils.config('staticPath') + '/scripts/data/mm/js/mm_campaign.js', render);
function render(d) {
var html = '',
//http://news.joins.com/find/list?keyword="Mr.밀리터리 캠페인"&key=mm&sourcegrouptype=all&display=Mr.밀리터리 캠페인
listLink = utils.config('webPcPath') + '/find/list?keyword=' + encodeURIComponent('Mr.밀리터리 캠페인') + '&scopetype=Keyword&key=mm&sourcegrouptype=all&display=' + encodeURIComponent('Mr.밀리터리 캠페인');
data = { sec: { link: { href: listLink } }, list: [] }
try {
var articles = utils.convertList(mm_Campaign_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('widgetMmCampaign');
//utils.log(e);
};
if (data.list.length) {
html = $.renderTemplate({ template: template, data: data, directives: directives });
$w.html(html).show();
} else {
$w.hide();
}
}
};
$.fn.widgetInnovationLab = function () {
$this = this;
$(".sub_innov_lab .slide_wrap").show();
$("#widget_innovation_lab").show();
widgetSponsoredContents();
var nFirstSlideIdx = 0;
var nSlideCounter = $("div.slide", $(".sub_innov_lab .slide_wrap")).length;
var slideShowCnt = $(this).find(".slide_wrap").data("slideshowcnt");
/*if (slideShowCnt == "1") {
nFirstSlideIdx = Math.floor(Math.random() * nSlideCounter);
}*/
var slideInnovationLab = {
init: function () {
this.slideInit();
},
slideInit: function () {
var slide = $('.sub_innov_lab .slide_wrap').slick({
arrows: true,
dots: false,
infinite: false,
speed: 300,
slidesToShow: slideShowCnt,
slidesToScroll: slideShowCnt,
initialSlide: nFirstSlideIdx
});
}
};
slideInnovationLab.init();
function widgetSponsoredContents() {
var slideBrandedContents = {
init: function () {
this.slideInit();
},
slideInit: function () {
var slide = $('.sub_branded_contents .slide_wrap').slick({
slidesToShow: 2,
slidesToScroll: 2,
infinite: true,
autoplay: true,
autoplaySpeed: 2000
});
}
};
slideBrandedContents.init();
$("#widget_sponsored_div").show();
}
};
// 김민석의 Mr.밀리터리 배너광고
$.fn.widgetMmBannerAd = function () {
$('#li_da_slot_926').loadAd({ type: 'da_slot_926' });
};
// 김민석의 Mr.밀리터리 배너
$.fn.widgetMmRequest = function () {
$this = this;
var html = '
';
html += ' 밀리터리 Request ';
html += ' Mr.밀리터리 측에서 군사/안보에 대해 다루었으면 하는 콘텐트를 알려주세요. 글쓰기 ';
html += ' ';
$this.html(html);
$this.show();
};
// 김민석의 Mr.밀리터리 소개 팝업
$.fn.widgetMmInfo = function () {
$this = this;
var html = '
';
html += '
군사안보연구소 ';
html += ' ';
html += '
';
//html += '
';
html += '
';
html += '
';
$this.html(html);
$this.show();
};
//대학평가 종합순위
$.fn.widgetUniversityRanking = function () {
var $this = this;
$.when(
$.ajax({
type: "GET",
url: utils.config("apiPath") + "/pagecall/?u=" + utils.config("staticPath") + "/scripts/data/university/xml/index_ranking.xml",
dataType: "XML",
success: function (xml) {
if ($(xml).find("article").length == 0) { $this.hide(); return; }
try {
var article = $(xml).find("article");
var html = '' +
'
' +
'
' + $(article).find("title").text() + ' ' +
'' +
'
' +
'
' +
'
' +
'
';
$this.html(html);
$this.show();
} catch (e) {
$this.hide();
}
},
error: function () {
$this.hide();
}
})
)
};
//추천 영화
$.fn.widgetRecommendedMovie = function () {
var $this = this;
$.when(
$.ajax({
type: "GET",
url: utils.config("apiPath") + "/pagecall/?u=" + utils.config("staticPath") + "/scripts/data/magazinem/xml/right_recommend.xml",
dataType: "XML",
success: function (xml) {
if ($(xml).find("article").length == 0) { $this.hide(); return; }
try {
var html = '' +
'
' +
'
추천 영화 ' +
'' +
'
';
$(xml).find("article").each(function (i, e) {
if ($(e).find("title").text() == "") return true;
html +=
'' +
'' +
'' + $(e).find("title").text() + ' ' +
' ' +
' ';
});
html += ' ';
$this.html(html);
$this.show();
} catch (e) {
$this.hide();
}
},
error: function () {
$this.hide();
}
})
)
};
//추천 테마
$.fn.widgetRecommendedTheme = function () {
var $this = this;
try {
var html = '' +
'
' +
'
추천 테마 ' +
'' +
'
' +
'
' +
'
' +
'
' +
'이전 ' +
'다음 ' +
' ' +
'
' +
'
';
$this.html(html);
$this.show();
$('.sub_recommend_series .slide_wrap .slide_list').slick({
speed: 300,
slidesToShow: 1,
slidesToScroll: 1,
draggable: true,
arrows: true,
prevArrow: $this.find('.btn-prev'),
nextArrow: $this.find('.btn-next')
});
} catch (e) {
$this.hide();
}
};
//시민마이크
$.fn.widgetPeopleMic = function () {
$this = this;
$.ajax({
type: "GET",
dataType: 'json',
url: utils.config('apiPath') + "/pagecall/?u=" + utils.config('staticPath') + '/scripts/data/peoplemic/json/peoplemic.json',
success: function (data) {
var html = '';
if (data.Items.length > 0) {
utils.getRandomNumberArray(data.Items)
html += '
시민마이크 ';
html += '
당신의 생각을 들려주세요
';
html += '
';
html += '
';
html += '
';
$this.html(html);
$this.show();
$this.find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'joongang|article|peoplemic'));
});
}
},
error: function () {
$this.hide();
}
})
};
//피플 > 최신 기사
$.fn.widgetPeopleLatest = function () {
var $this = this;
var categoryList = [
['최신 사랑방', 'TodayPeopleRoom', 'Room'],
['최신 인사', 'TodayPeoplePersonnel', 'Personnel'],
['최신 부음', 'TodayPeopleDeath', 'Death']
];
$.ajax({
type: 'GET',
dataType: 'JSON',
url: utils.config('apiPath') + '/Category/ArticleList?pageNum=1&pageSize=3&categoryKey=' + categoryList[0][1],
success: function (json) {
if (json == null || json == undefined) return;
render(0, json);
}
});
$.ajax({
type: 'GET',
dataType: 'JSON',
url: utils.config('apiPath') + '/Category/ArticleList?pageNum=1&pageSize=3&categoryKey=' + categoryList[1][1],
success: function (json) {
if (json == null || json == undefined) return;
render(1, json);
}
});
$.ajax({
type: 'GET',
dataType: 'JSON',
url: utils.config('apiPath') + '/Category/ArticleList?pageNum=1&pageSize=3&categoryKey=' + categoryList[2][1],
success: function (json) {
if (json == null || json == undefined) return;
render(2, json);
}
});
function render(index, json) {
try {
var html = '' +
'
' +
'
' +
'
';
for (var i = 0; i < json.length; i++) {
html += '';
if (json[i].Thumbnail != '') {
html += ' ';
}
html += '' + json[i].Title + ' ';
html += ' ';
}
html += ' ';
$this.find('.sub_jplus').eq(index).append(html).show();
} catch (e) { }
}
};
//e글중심 > 주간 인기 글
$.fn.widgetEgleWeekBest = function () {
var $this = this;
$.when(
$.ajax({
type: "GET",
url: utils.config('apiPath') + "/pagecall/?u=" + utils.config('staticPath') + "/scripts/data/sonagi/xml/article_right_sonagi_etextcenter.xml",
dataType: "XML",
success: function (xml) {
if ($(xml).find("article").length == 0) { $this.hide(); return; }
try {
var html = '
e글중심 베스트 ';
var num = 1;
$(xml).find("article").each(function (i, e) {
if ($(e).find("title").text() == "") return true;
var articleLink = utils.getUrlFormat(URL_NAMES.article, $(e).find("total_id").text());
var cls = "";
if (num < 4) { cls = "class='top'"; }
html +=
'' +
'' + num + ' ' +
'' +
'' + $(e).find("title").text() + ' ' +
' ' +
' ';
num++;
});
html += ' ';
$this.html(html);
$this.show();
} catch (e) {
$this.hide();
}
},
error: function () {
$this.hide();
}
})
)
};
// 미리듣는 오늘
$.fn.widgetPrehear = function (options) {
var $this = this;
var nNowTime = parseInt(__Ndaytime.ymdhm.toString().substr(8), 10);
var nNowWeekDay = parseInt(__Ndaytime.ba.weekday.toString(), 10);
//2월 15일부터 오후 3:10~ 오후 5:30 (2시간 20분 노출)
if (nNowWeekDay >= 1 && nNowWeekDay <= 5 && nNowTime >= parseInt("1510", 10) && nNowTime <= parseInt("1730", 10)) {
$.when(
$.ajax({
type: "GET",
url: utils.config('apiPath') + "/pagecall/?u=" + utils.config('staticPath') + "/scripts/data/home/xml/right_soundcloud.xml",
dataType: "XML",
success: function (xml) {
if ($(xml).find("article").length > 0) {
var e = $(xml).find("article").first();
var strText = $(e).find("title").text();
var srcUrl = $(e).find("link").text();
if ($.trim(srcUrl).length > 0) {
var strSoundUrl = "https://w.soundcloud.com/player/" +
"?url=" + escape(srcUrl) +
"&inverse=true&auto_play=false&show_user=true&download=false&sharing=false&show_artwork=true&show_user=true&start_track=0&show_teaser=false";
var html = '' +
'' +
'
' + strText + '
' +
'';
$this.html(html);
$this.show();
}
}
},
error: function (e) {
$this.hide();
}
})
);
}
}
// 핫이슈
// @param options
$.fn.widgetTagNews = function (options) {
$this = this;
var apiUri = utils.config('apiPath') + "/pagecall/?u=" + utils.config('staticPath') + "/scripts/data/issue/js/tagnews_article_list_pchome.json";
$.ajax({
type: "GET",
dataType: 'json',
url: apiUri,
success: function (data) {
try {
var html = '';
html += '
이슈패키지 ';
$this.html(html);
$this.show();
$this.find('a').each(function () {
$(this).attr('href', utils.getClocUrl($(this).attr('href'), 'Joongang|article|issuepkg'));
});
} catch (e) {
$this.hide();
}
},
error: function (e) {
$this.hide();
}
})
};
// 더,오래 필진신청하기
$.fn.widgetRetirementWriter = function () {
$this = this;
var html = '
';
$this.html(html);
$this.show();
};
//더,오래 공지사항
$.fn.widgetRetirementNotice = function () {
var $this = this;
$.getScript(utils.config('webPcPath') + '/retirement/noticedata?page=1&pageSize=3', function () {
var list = bbs_notice.data;
var html = '' +
'
' +
'
";
$this.append(html);
})
};
// Jpod
$.fn.widgetJpodEpisode = function (options) {
var $this = this;
/*$.ajax({
type: "GET",
url: utils.config('apiPath') + "/pagecall/?u=" + utils.config('staticPath') + "/scripts/data/jpod/episode.xml",
dataType: "XML",
success: function (xml) {
var html = '';
if ($(xml).find("article").length > 0) {
var itemno = Math.floor(Math.random() * $(xml).find("article").length);
var e = $(xml).find("article").eq(itemno);
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();
var thumb = $(e).find("thumb").text();
html += '
' + chtitle + ' ' + epno + ' ' + title + '
';
$("#jpoditems").html(html);
$this.show();
}
else {
html += '
';
$("#jpoditems").html(html);
$this.show();
}
},
error: function (e) {
$this.hide();
}
})*/
if (__Ndaytime.ymdhm <= 202004302359) {
var html = '';
html = '
'
$("#jpoditems").css('background-image', 'url("")').html(html);
$("a", $("#jpoditems")).eq(Math.floor(Math.random() * $("a", $("#jpoditems")).length)).show();
$this.show();
}
};
function renderWidgetBody($w, widgetHtml, html) {
/*var $body = $w.find('.bd');
if(!$body || $body.length == 0) {
$w.html(widgetHtml).find('.bd').html(html);
} else {
$body.html(html);
}*/
var $body = $w.find('.bd');
if (!$body || $body.length == 0) {
$w.html(widgetHtml).find('.bd').html(html.replace(/</gi, "<").replace(/>/gi, ">"));
} else {
$body.html(html);
}
}
function renderWidgetBodyPrepend($w, widgetHtml, html) {
var $body = $w.find('.bd');
if (!$body || $body.length == 0) {
$w.prepend(widgetHtml).find('.bd').html(html);
} else {
$body.html(html);
}
}
function getTempData(url, callback, temp) {
//var t = $.extend({}, temp);
callback(temp);
}
function getApiData(url, callback) {
url = url.indexOf('http') > -1 ? url : apiPath + url;
utils.getJsonp({
url: url,
success: function (res) {
callback && callback(res);
}
});
}
})(jQuery, window, document);
function setADLogData(cloc) {
var strSetLogUrl = utils.config('appPath') + "/news/common/set_page_log.asp?p=" + escape(document.location.href) + "&r=" + escape(document.referrer) + "&c=" + escape(cloc);
/*로그저장*/
if ($("iframe#ifrmHdnPageLog").length > 0) { $("iframe#ifrmHdnPageLog").attr("src", strSetLogUrl); }
else { $(document.body).append("
"); }
}
function openKakao() {
if (utils.isMobile()) {
window.open("kakaoplus://plusfriend/home/@joongangilbo");
}
else {
alert('지원하지 않는 플랫폼입니다.');
}
}
function openKakaoTalkJ() {
if (utils.isMobile()) {
window.open("kakaoplus://plusfriend/home/@talkpawonj");
}
else {
location.href = "http://plus.kakao.com/home/@talkpawonj";
}
}
function openLayerPopup(type) {
$.ajax({
type: 'GET',
dataType: 'HTML',
url: utils.config('apiPath') + '/pagecall/?u=' + utils.config('staticPath') + '/scripts/data/layer/' + type + '.html',
success: function (html) {
$.when($('#doc').append(html)).then(function () {
if (type == 'military') {
$('div.layer').addClass('layeron');
} else {
openLayerPopupReturn();
}
});
}
});
}