');
width = 435; height = 435;
} else if (rotype == 3) {
szHtml.push('
');
width = 326; height = 580;
} else {
szHtml.push('
');
}
szHtml.push('
');
szHtml.push(' ');
szHtml.push('
');
if ($.trim(config.caption).length > 0) {
szHtml.push('
' + config.caption + '
');
}
szHtml.push('
');
$(target).html(szHtml.join(''));
$(target).find("iframe").attr('src', url);
$(target).removeAttr('data-id');
$(target).find('iframe').show();
if (utils.config('articleType') != ARTICLE_TYPE.spTimeLine && rotype != 3 && ovpRecommendType > 0) setOvpRecommend($target, rotype, ovpRecommendType); //추천동영상
utils.resetArticleSubWidget && utils.resetArticleSubWidget();
ooyalacnt++;
}
function setVodPlayerForOvpLive($target, config, options) {
var params = config.id.slice(config.id.indexOf('?') + 1).split('&');
var target = $target;
var autoplay = false;
var mute = false;
if ($.trim(config.autoPlay).length > 0 || $.trim(config.autoplay).length > 0) {
if (config.autoPlay == true || config.autoplay == true) {
autoplay = true;
}
}
if ($.trim(config.mute).length > 0) {
if (config.mute == true) {
mute = true;
}
}
var szHtml = [];
var url = config.id;
if (url.indexOf('?') >= 0) {
url = config.id.substring(0, url.indexOf('?'));
}
var rq_url = document.location.href.toString().toLowerCase();
var ovpUrl = (url.length > 20) ? 'https://oya.joins.com/bc_iframe.html?ec=' : 'https://oya.joins.com/bc_iframe.html?videoId=';
url = ovpUrl + url + "&options[autoplay]=" + autoplay + "&options[muteFirstPlay]=" + mute;
url += "&docUrl=" + encodeURIComponent(rq_url);
var width = 580; height = 326;
$(target).removeAttr('data-service');
$(target).removeAttr('data-src');
$(target).removeAttr('class');
szHtml.push('
');
szHtml.push('
');
szHtml.push(' ');
szHtml.push('
');
if ($.trim(config.caption).length > 0) {
szHtml.push('
' + config.caption + '
');
}
szHtml.push('
');
$(target).html(szHtml.join(''));
$(target).find("iframe").attr('src', url);
$(target).removeAttr('data-id');
$(target).find('iframe').show();
utils.resetArticleSubWidget && utils.resetArticleSubWidget();
}
function setOvpRecommend($player, ro, type) {
var PDS_DOMAIN = utils.config('pdsPath');
var szHtml = [];
var opt = (type == 3) ? 2 : 1;
var cruzUrl = [];
var cnt = 9;
if (ro == "2") cnt = 6;
cruzUrl.push(utils.config('cruzPath') + '/vod?');
cruzUrl.push("th=Y");
cruzUrl.push("&tid=" + utils.getTotalId());
cruzUrl.push("&cnt=" + cnt);
cruzUrl.push("&rnd=Y");
cruzUrl.push("&opt=" + opt);
if (type == 1) {
cruzUrl.push('&scd=' + $("#servcode").val());
cruzUrl.push('&from=7d');
} else if (type == 2) {
cruzUrl.push('&from=3d');
} else if (type == 3) {
cruzUrl.push('&from=3d');
}
$.ajax({
type: 'GET',
url: cruzUrl.join(''),
dataType: 'json',
success: function (res) {
if (res.length > 0) {
szHtml.push('
');
szHtml.push('
');
szHtml.push(' ');
szHtml.push('
');
szHtml.push('
');
szHtml.push('
');
$.each(res, function (i, r) {
szHtml.push(' - ');
szHtml.push(' ');
szHtml.push(' ');
szHtml.push(' ' + r.art_title + '');
szHtml.push(' ');
szHtml.push('
');
});
szHtml.push('
');
szHtml.push('
');
szHtml.push('
');
szHtml.push('
');
szHtml.push('
');
$player.find(".ab_player").append(szHtml.join(''));
$player.find(".ovp_recommend").find(".btn_more").on('click', function (e) {
e.preventDefault();
e.stopPropagation();
$(this).parent().parent().toggleClass("open");
});
var recommnedCount = 0;
if (ro == 1) {
recommnedCount = 3
} else if (ro == 2) {
recommnedCount = 2
}
$player.find('.ovp_recommend_ul').slideMotion({
infinite: true,
slidesToShow: recommnedCount,
slidesToScroll: 1,
swipe: false,
prevArrow: $player.find('.btn-prev'),
nextArrow: $player.find('.btn-next')
});
}
}
});
}
function getParamString(params) {
var strParams = '';//'?';
$.each(params, function (i, v) {
if (v != '') {
if (strParams.length > 0) {
strParams += "&"
}
strParams += i + '=' + v;
}
});
return '?' + strParams;
}
function getVodId($ele) {
var id = '';
// Legacy 대응.
if ($ele.hasClass('jtbc_vod')) {
id = $ele[0].id.substr(4);
} else {
id = $ele.data('id');
}
return id;
}
function getService(id) {
var s = ''; // default : youtube.
if (id.substring(0, 2) == "NV") {
s = SERVICE_TYPE.news;
} else if (id.substring(0, 2) == "VO") {
s = SERVICE_TYPE.jtbc;
}
return s;
}
return this.each(function (i, v) {
var $ele = $(v),
vodConfig = { id: '', service: SERVICE_TYPE.jtbc, caption: '' },
ratio = 0.6,
width = ARTICLE_SIZE.body,
height = parseInt(width * ratio, 10),
options = { 'width': width, 'height': height, "ad_presn": 309, "ad_postsn": 324 };
// Legacy Code
//$ele.css({ "width": $('#article_body').width(), "text-align": "center"});
// TODO : * Vod List 정보에 대한 처리.
// TODO : config 로 들어오는 vodIds 정보와 비교하여 Content 에서 삭제되어 있는 동영상에 대한 Dom 을 추가 해주는 작업이 Legacy 에 존재함.
// TODO : 당일 정보로 들어오던 vodId 가 리스트 형식으로 바뀔 예정임으로 작업 대기.
vodConfig.id = getVodId($ele);
vodConfig.service = getService(vodConfig.id) || $ele.data('service');
vodConfig.caption = $ele.attr("data-caption") || "";
//utils.log('^^^^^^^^^^^^^^^^^^^^');
//utils.log(vodConfig);
if (!vodConfig.id) {
return;
}
// ovp 추가
if (vodConfig.service == SERVICE_TYPE.ovp || vodConfig.service == SERVICE_TYPE.ovplive || vodConfig.service == SERVICE_TYPE.ooyala || vodConfig.service == SERVICE_TYPE.ooyalalive) {
var aVodOpt = fnGetParamArray(vodConfig.id);
for (var key in aVodOpt) { vodConfig[key] = aVodOpt[key]; }
}
if (articleType == ARTICLE_TYPE.piki || articleType == ARTICLE_TYPE.live) {
}
if (utils.config('pageType') == PAGE_TYPE.article || utils.menu.getPageMenuKey().toLowerCase().indexOf('election2017') !== -1) {
options.width = $ele.parent().width();
options.height = parseInt(options.width * ratio, 10);
} else {
options.width = $ele.outerWidth();
options.height = $ele.outerHeight(); //parseInt(options.width * ratio, 10);
}
if ((vodConfig.service == SERVICE_TYPE.jtbc || vodConfig.service == SERVICE_TYPE.news) && $ele.outerWidth() <= 0) {
if (location.host.indexOf('jcms.') > -1) {
options.width = 380;
options.height = parseInt(options.width * ratio, 10);
}
}
//utils.log($ele.parent());
//utils.log('$$$ options');
//utils.log(options);
// 뉴스용 플레이어입니다. Jucode의 앞 두자리로 비교해서 분기문 처리 해서 방송, 제보쪽 작업 진행하셔야 할듯...
// GetVod는 news도메인에 있는 뉴스DB를 조회하게 되니 이쪽으로 id넘겨봐야 데이타 없어요.
if (vodConfig.service == SERVICE_TYPE.jtbc || vodConfig.service == SERVICE_TYPE.news) {
fnVodPlayForJtbc(vodConfig, cRefType, options, $ele);
} else if (vodConfig.service == SERVICE_TYPE.ovp || vodConfig.service == SERVICE_TYPE.ooyala) {
setVodPlayerForOvp($ele, vodConfig, options);
} else if (vodConfig.service == SERVICE_TYPE.ovplive || vodConfig.service == SERVICE_TYPE.ooyalalive) {
setVodPlayerForOvpLive($ele, vodConfig, options);
} else if (vodConfig.service == SERVICE_TYPE.wsj || vodConfig.service == SERVICE_TYPE.navercast || vodConfig.service == SERVICE_TYPE.fblive || vodConfig.service == SERVICE_TYPE.kakaotv || vodConfig.service == SERVICE_TYPE.youtube) {
setVodPlayerForIFrame($ele, vodConfig, options);
} else {
utils.error('ARTICLE COMPONENT ERROR : not defined vod service.', true);
}
});
};
/**
* SNS Card 컴포넌트
*/
$.fn.articleSns = function () {
var services = {
load: {
twitter: function (v, id) {
//if (window.twttr === undefined) {
scriptLoader('twitter-wjs', 'https://platform.twitter.com/widgets.js');
//}
},
facebook: function () {
if (window.FB) {
window.FB.init({ appId: '1011513095546498', version: 'v2.4' });
window.FB.XFBML.parse();
} else {
scriptLoader('facebook-jssdk', '//connect.facebook.net/ko_KR/all.js#xfbml=1&version=v2.2');
}
},
google: function (v, id) {
scriptLoader('google-sdk', 'https://apis.google.com/js/platform.js');
},
pinterest: function (v, id) {
scriptLoader('pinterest-sdk', '//assets.pinterest.com/js/pinit_main.js');
},
instagram: function (v, id) {
if (window.instgrm) {
instgrm.Embeds.process()
} else {
scriptLoader('instagram', '//platform.instagram.com/en_US/embeds.js');
}
}
},
html: {
twitter: '
',
facebook: '
',
google: '
',
pinterest: '
',
instagram: '
'
}
};
var articleType = utils.config('articleType');
function scriptLoader(id, src, options) {
//utils.log('## scriptLoader id : ' + id);
var d = document,
s = 'script',
js,
fjs = d.getElementsByTagName('head')[0],
ele = d.getElementById(id);
if (ele) {
if (ele.remove) {
ele.remove();
}
else {
$(ele).remove();
}
}
js = d.createElement(s);
js.id = id;
js.type = 'text/javascript';
js.src = src;
js.async = true;
js.defer = true;
$(fjs).append(js);
}
return this.each(function (i, v) {
var $dom = $(v),
service = $dom.data('service'),
id = $dom.data('id'),
url = $dom.data('url'),
width = '',
load = services.load[service],
html = services.html[service] || '';
var browserVersion = (service == 'google' || service == 'facebook' ? 8 : 9);
if (utils.browser && utils.browser.msie == true && parseInt(utils.browser.version, 10) < browserVersion) {
$dom.browserNotice();
} else {
if (html && html.length > 0) {
if (articleType == ARTICLE_TYPE.piki) width = "350";
else if (articleType == ARTICLE_TYPE.live) width = "380";
else if (utils.menu.getPageMenuKey().toLowerCase().indexOf('election2017') !== -1) width = "580";
else width = "500";
if ('instagram' == service) {
html = $(html.replace('{data.url}', url.replace('/tv/', '/p/')).replace('{WIDTH}', width));
} else {
html = $(html.replace('{data.url}', url).replace('{WIDTH}', width));
}
$dom.replaceWith(html); // position 조절이 필요한 구조이므로 replaceWith 하면 안됨.
utils.resetArticleSubWidget && utils.resetArticleSubWidget();
if (articleType == ARTICLE_TYPE.piki || articleType == ARTICLE_TYPE.live) {
html.find('span[class^=icon]').remove();
} else {
if (service != 'google') {
setPosition(html);
}
}
}
if ($.isFunction(load)) {
load(v, id);
}
}
});
};
/*
* 사운드 클라우드 widget
* @params
*/
$.fn.audioPlayer = function (options) {
var defaults = {
src: '',
auto_play: false,
buying: false,
liking: false,
download: false,
sharing: false,
show_artwork: true,
show_playcount: false,
show_user: true,
start_track: 0,
show_teaser: false
},
config = $.extend(defaults, options || {});
return this.each(function (i, v) {
var data = $(v).data(),
param = '',
$contents = '';
config = $.extend(config, data || {});
config.src = data.src || data.id;
param = $.param(config).replace(/^src\=/, '');
$contents = $('
');
if (utils.browser.msie && parseInt(utils.browser.version, 10) < 9) {
//$contents = '
지원하지 않습니다.
';
$(v).browserNotice();
}
$(v).replaceWith($contents);
utils.resetArticleSubWidget && utils.resetArticleSubWidget();
});
};
$.fn.articleJtbcLink = function () {
function setHtml($target, data) {
var linkHtml = '';
if ($target.length == 0) { return; }
linkHtml = getLinkHtml(data);
function getLinkHtml(data) {
var html = '';
if (data.href) {
html = '
보러가기';
}
return html;
}
$(".docs_upper .jch_link").replaceWith(linkHtml);
}
return this.each(function (i, v) {
var $c = $(v), data = $c.data();
setHtml($c, data);
});
};
/**
* 챠트
* @param options
*/
$.fn.articleCharts = function () {
var chtItemHeight = 30,
chtAreaCss = { top: 50, right: 50, bottom: 70, left: 50, width: "100%" };
return this.each(function (i, v) {
var $ChartsWrap = $(v),
jsonChartData = { "title": $ChartsWrap.attr("data-cht-title"), "copyright": $ChartsWrap.attr("data-cht-copy"), "max_value": 0, "wrap_height": 0, "wrap_width": "100%", "vote": [] },
tmpChtMaxVal = 0;
jsonChartData.vote.push(["지역", "투표율", { role: "style" }, { role: "annotation" }]);
$("div[data-cht-text]", $ChartsWrap).each(function (idx) {
var chtItemText = $(this).attr("data-cht-text");
var chtItemValue = parseFloat($(this).attr("data-cht-value"), 10);
var chtItemValueType = $ChartsWrap.attr("data-cht-vaue-type") || "";
var chtItemBarColor = $(this).attr("data-cht-color") || "#4285F4";
jsonChartData.vote.push([chtItemText, chtItemValue, chtItemBarColor, chtItemValue.toString() + chtItemValueType]);
if (jsonChartData.max_value < chtItemValue) {
jsonChartData.max_value = chtItemValue;
}
});
jsonChartData.wrap_height = chtAreaCss.top + chtAreaCss.bottom + ($ChartsWrap.children().length * chtItemHeight);
google.charts.load("current", { "packages": ["corechart"] });
google.charts.setOnLoadCallback(function () {
var cht_data = new google.visualization.arrayToDataTable(jsonChartData.vote);
var cht_options = {
title: jsonChartData.title,
//chart: { title: jsonChartData.title, subtitle: jsonChartData.copyright },
fontSize: 14, //차트내 모든 텍스트의 크기
//width: "130%",
//height: "100%",
/*animation: {
duration: 100,
easing: "in",
startup: true
},*/
dataOpacity: 0.8, //막대 투명도 (기본1)
//enableInteractivity: true, //막대셀렉트 (기본true)
legend: { position: "none" },
titlePosition: "out", //제목 그래프 안에 넣기 in, out
bars: "horizontal",
//axes: { x: { 0: { side: "bottom", label: "투표율" } } },
bar: { groupWidth: "70%" },
isStacked: false, // 그래프 쌓기(스택), 기본값은 false, "percent"
chartArea: chtAreaCss,
titleTextStyle: {
color: "#050505",
fontSize: 18,
bold: true,
italic: false
},
hAxis: {
//title: "투표율",
title: jsonChartData.copyright,
textPosition: "out", //가로축 none, out
//scaleType: true,
viewWindowMode: "min",
viewWindow: {
max: jsonChartData.max_value
}
},
vAxis: {
//title: "지역",
textPosition: "out", //세로축 none, out
scaleType: true
}
};
var chart = new google.visualization.BarChart($ChartsWrap[0]);
chart.draw(cht_data, cht_options);
});
$ChartsWrap.css({ width: jsonChartData.wrap_width, height: jsonChartData.wrap_height });
$ChartsWrap.children().remove();
$ChartsWrap.show();
});
};
/**
* 서울학교지도
*/
$.fn.seoulSchoolMap = function () {
var SchoolMapHtml = "
" +
"
" +
"" +
"
";
this.replaceWith("
" + SchoolMapHtml);
};
})(jQuery, window, document);
" + "