';
$("#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();
});
};
// Outstream 광고
$.fn.widgetOutstreamAD = function () {
var $w = this;
var _c = new Date().getTime();
var adLink = 'http://ads.admaru.com/js/Joongangjoins.js?t=' + _c;
var html = '';
$w.after(html);
};
// 오피니언 평양 오디세이
$.fn.widgetSpecialCartoon = function () {
var $w = this,
widgetName = '평양 오디세이',
keywordStr = '평양 오디세이',
serviceCode = '',
listLink = utils.config('webPcPath') + '/find/list?Keyword=' + encodeURIComponent(keywordStr) + '&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.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();
}
}
};
//jplus 필진 최신글보기, 문구추가
/*
'
'
*/
$.fn.articleJplusRecentlyNews = function () {
var url = 'http://jplus.joins.com/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;
$.when(
$.ajax({
type: "GET",
//url: utils.config('apiPath') + "/pagecall/?u=http://static.joins.com/joongang_15re/scripts/data/home/xml/right_innovation_lab.xml",
url: utils.config('apiPath') + "/pagecall/?u=" + utils.config('staticPath') + "/scripts/data/home/xml/right_innovation_lab.xml",
dataType: "XML",
success: function (xml) {
var e = $(xml).find("innovation").first();
var itemHtml = "";
$(xml).find("innovation"). each(function () {
var focusItem = $(this).find("focus_item").text();
var image = $(this).find("article_image").text();
var title = $(this).find("title").text();
var byline = $(this).find("byline").text();
var link = $(this).find("pc_link").text();
var target = $(this).find("pc_link").attr("target");
itemHtml += '
' +
'
' +
'
' +
' ' +
' ' + title + ' ' +
' ' + byline + ' ' +
' ' +
' ' +
'
';
});
$(".sub_innov_lab .slide_wrap").html(itemHtml);
if ($("div.slide[data-src='focus-item']", $(".sub_innov_lab .slide_wrap")).length > 0) {
$("div.slide[data-src='']", $(".sub_innov_lab .slide_wrap")).remove();
}
$(".sub_innov_lab .slide_wrap").show();
$("#widget_innovation_lab").show();
widgetSponsoredContents();
},
error: function () {
}
})
).then(function (xml) {
var nFirstSlideIdx = 0;
var nSlideCounter = $("div.slide", $(".sub_innov_lab .slide_wrap")).length;
var slideShowCnt = 1;
if ($(xml).find("focus_item:contains('Y')").length > 1) {
slideShowCnt = 2;
} else {
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() {
$.when(
$.ajax({
type: "GET",
url: utils.config('apiPath') + "/pagecall/?u=" + utils.config('staticPath') + "/scripts/data/home/xml/right_digital_ad.xml",
dataType: "XML",
success: function (xml) {
var itemHtml = '
';
var i = 0;
$(xml).find("article").each(function () {
if (i < 3) {
var title = $(this).find("title").text();
var link = $(this).find("link").text();
var imgurl = $(this).find("image").text();
itemHtml += '';
if(imgurl) {
itemHtml += '';
itemHtml += ' ';
itemHtml += ' ';
}
itemHtml += '';
itemHtml += '' + title + ' ';
itemHtml += ' ';
itemHtml += ' ';
}
i++;
});
itemHtml += ' ';
$("#widget_sponsored_contents").html(itemHtml);
$("#widget_sponsored_div").show();
},
error: function () {
}
})
)
}
};
// 김민석의 Mr.밀리터리 배너광고
$.fn.widgetMmBannerAd = function () {
$('#li_da_slot_926').loadAd({ type: 'da_slot_926' });
$('#li_da_slot_927').loadAd({ type: 'da_slot_927' });
//$('#li_da_slot_928').loadAd({ type: 'da_slot_928' });
//$('#li_da_slot_929').loadAd({ type: 'da_slot_929' });
};
//대학평가 종합순위
$.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) { }
}
};
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);
}
});
}
function setADLogData(cloc) {
var strSetLogUrl = "http://app.joins.com/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("
"); }
}
})(jQuery, window, document);
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";
}
}