' + percent + '% (' + condition.data.VotedCount + '명)
');
condition.list.append($item);
}
}
function getContentType(list) {
var name = '';
list.forEach(function (v) {
if (v.ImageName !== '') {
name = POLL_CONTENT_TYPE['img'];
if (v.Title !== '') {
name = POLL_CONTENT_TYPE['imgtext'];
}
}
});
return name;
}
}
function getTimeStamp(d) {
return typeof d == 'string' ? d.toDateISO8061() : d;
}
function getPollUse(d) {
// 일시중지 상태 조건 추가.
var ts = nowDate.getTime(),
isUse = true;
if (d.Status == 'Pause') {
isUse = false;
} else {
if (ts < d.StartedDateTime || ts > d.EndedDateTime) {
isUse = false;
}
}
return isUse;
}
return this.each(function (i, v) {
var $p = $(v),
id = $p.data('id');
utils.getJsonp({
url: apiPath + '/poll/' + id,
success: callback
});
function callback(resData) {
resData = resData.poll;
resData.StartedDateTime = getTimeStamp(resData.StartedDateTime);
resData.EndedDateTime = getTimeStamp(resData.EndedDateTime);
if (resData.Status == 'Delete') {
return;
}
var pollConfig = {
pollId: id,
data: resData,
layoutType: (resData.PollItems.length > 2 ? POLL_LAYOUT_TYPE.vertical : POLL_LAYOUT_TYPE.horizontal),
isPoll: getPollUse(resData) // 진행중 여부.
};
setPollHtml($p, pollConfig);
}
});
};
/**
* 화보
* @param options
*/
$.fn.articlePictorial = function (options) {
return this.each(function (i, v) {
var $p = $(v),
id = $p.data('id');
if (!id) {
return;
}
utils.getJsonp({
url: apiPath + '/gallery/' + id,
success: callback
});
function callback(resData) {
var objPictorial = {
id: id,
parent: null,
src: '',
count: 0,
type: 'photo',
items: []
};
try {
$.each(resData.List, function (i, v) {
v.FileUrl = getPdsFullPath(v.Image);
});
objPictorial.title = resData.Photo.Title;
objPictorial.parent = $p;
objPictorial.src = resData.List[0].FileUrl;
objPictorial.count = resData.Photo.Count;
objPictorial.items = resData.List;
} catch (e) {
};
setPictorialHtml(objPictorial);
}
});
};
$.fn.articlePhotoBundle = function () {
return this.each(function (i, v) {
var $bundle = $(v), $img = $bundle.find('img');
if (!$img.length) return;
var items = [];
$img.each(function (i) {
var $this = $(this), item = {};
item.Image = $this.data('src') || $this.attr('src');
item.Description = $this.attr('alt');
items.push(item);
});
$bundle
.data('items', items)
.find('.btn_all').on('click', function (e) {
$bundle.imageViewer();
return false;
});
if (!$('body').hasClass('jstyle')) {
$bundle.attr('class', 'ab_photo').css('width', ARTICLE_SIZE.body);
}
});
};
$.fn.articlePhotoBundleGallery = function () {
return this.each(function (i, v) {
var $p = $(v),
$items = $p.find('img'),
data = [];
if (!$items.length) { return; }
$items.each(function () {
var $this = $(this),
obj = {};
obj.Image = $this.data('src') || $this.attr('src');
obj.Description = $this.data('desc') || $this.attr('caption');
obj.Caption = $this.attr('caption') || $this.attr('alt');
data.push(obj);
});
//utils.log(data);
//utils.log('## articlePhotoBundle');
setPictorialGalleryHtml({
parent: $p,
src: data[0].Image,
title: data[0].Description,
leadCaption: data[0].Caption,
count: $items.length,
type: 'image',
items: data
});
});
};
/**
* 갤러리 Tag
* @param options
*/
$.fn.articleGallery = function (options) {
var defaults = {},
config = $.extend(true, defaults, options),
$articleBody = this,
oldTextFilter = '',
$imgItems = $("> div > .html_photo_center > img", $articleBody),
$oldImgItems = $("img[src^='/component/htmlphoto_mmdata/']", $articleBody),
imageList = [];
// 기사내 화보 관련 함수들 시작
var gallery_in_article_logging_type = 0;
var images_index_in_gallery = 0;
var images_count_in_article = 0;
var images_in_article = new Array();
function migration_to_gallery() {
try {
var _check_str = $("#article_content").html();
if (_check_str.indexOf("") != -1 && $("#article_content > div div img").length >= 2) {
// 작업으로 인한 br 제거
var nMaxRemoveCount = $("#article_content > div > .html_photo_center > img").length;
var PVCount = $("img[orgImg]", $("#article_content")).length;
if (PVCount > 0) {
fnGetPhotoViewer("g", 0);
}
var bDeletable = false;
for (var x = 0; x < 3; x++) {
var sPrevTag = "";
var nContinuousTag = 0;
$("#article_content").children().each(function (idx, item) {
if (this.tagName.toLowerCase() == "div" && sPrevTag != "div") {
bDeletable = true;
}
if (this.tagName.toLowerCase() == "div" && sPrevTag == "div") {
nContinuousTag++;
}
if (this.tagName.toLowerCase() == "div" && this.className == "article_msn_ad") {
return false;
} // 본문내 광고 영역을 만나면 탈출
if (nContinuousTag >= (nMaxRemoveCount - 1)) {
return false;
} // 화보용 이미지 개수보다 많은 div가 연속되서 나와도 탈출 (-1은 최초 div가 연속이 아니라서)
if (bDeletable == true && this.tagName.toLowerCase() == "br") {
$(item).remove();
bDeletable = false;
}
sPrevTag = this.tagName.toLowerCase();
});
bDeletable = false;
}
$("#article_content > div").each(function (idx, item) {
var x = $(item).children(".html_photo_center").children("img").attr("src");
if (typeof (x) != "undefined") {
images_in_article[images_count_in_article++] = x;
$(item).remove();
}
});
var rq_url = document.location.href.toString().toLowerCase();
if (rq_url.indexOf("/article/aid/") >= 0) {
gallery_in_article_logging_type = 1;
}
// 이제 이미지 노출 시작
var codes_for_gallery_in_article = "
";
codes_for_gallery_in_article += "
";
codes_for_gallery_in_article += " prev ";
codes_for_gallery_in_article += " ";
codes_for_gallery_in_article += " ";
codes_for_gallery_in_article += " ";
codes_for_gallery_in_article += " ";
codes_for_gallery_in_article += " ";
codes_for_gallery_in_article += " next ";
codes_for_gallery_in_article += "
";
codes_for_gallery_in_article += "
";
codes_for_gallery_in_article += "
";
for (var x = 0; x < images_in_article.length && x < 6; x++) {
codes_for_gallery_in_article += " ";
}
codes_for_gallery_in_article += " ";
codes_for_gallery_in_article += "
";
codes_for_gallery_in_article += "
";
//$("#articlebody").prepend(codes_for_gallery_in_article);
$("#article_content").prepend(codes_for_gallery_in_article);
gallery_in_article_show(0, PVCount); // 최초 호출시에는 카운트 로그 안되도록 조정, 썸네일을 찍거나 좌우 버튼을 이용할때 로깅
}
} catch (ex) {
}
}
//관련포토/관련화보
function getRelateGallery(type, cid, areaName) {
var sCompPath,
sCompHtml,
sGalleryLinkUrl;
if (type.toString().length <= 0 || cid.toString() == "0" || cid.toString().length <= 0) {
if (areaName && areaName.length > 0) {
$("#" + areaName).css({ "display": "none" });
}
return;
}
type = type.toUpperCase();
if (type == "P") {
//콤포넌트에서 관리하는 내용들은 콤포넌트에서 관리하므로 콤포넌트 아이디로 js를 생성하지만
//이건 포토기사 아이디가 넘어오므로 기사아이디로 파일을 생성한다.
//다만 겹칠수 있기때문에.. 앞에 "P_" or "G"를 붙여준다.
//중간 경로는 sourcecode로 생성하지 않고 comptype("P" or "G")로 생성한다.
sCompPath = sStaticCompDomain + "component/" + type + "/" + cid.substring(cid.length - 3) + "/P_" + cid + ".js";
$.getScript(sCompPath, function () {
try {
if (typeof (P_JSON) != "undefined") {
sCompHtml = "";
/*
P_JSON.data[nIdx].num
P_JSON.data[nIdx].total_id
P_JSON.data[nIdx].title
P_JSON.data[nIdx].path
P_JSON.data[nIdx].title
*/
for (var nIdx = 0; nIdx < P_JSON.data.length; nIdx++) {
if (P_JSON.data[nIdx].path.indexOf(".jpg") > 0 || P_JSON.data[nIdx].path.indexOf(".JPG") > 0) {
sCompHtml += "
";
sCompHtml += " ";
sCompHtml += " ";
sCompHtml += " ";
sCompHtml += "
" + P_JSON.data[nIdx].title + " ";
}
}
if (areaName && areaName.length > 0) {
$("#" + areaName).html(sCompHtml).css({ "display": "" });
displayArticleArea("PHOTO");
} else {
return sCompHtml;
}
} else {
fnCallMakeJson(cid, type, "getRelateGallery('" + type + "', '" + cid + "', '" + areaName + "')");
}
} catch (e) {
if (areaName && areaName.length > 0) {
$("#" + areaName).css({ "display": "none" });
}
alertErrorMsg(e);
}
});
} else if (type == "G") {
//콤포넌트에서 관리하는 내용들은 콤포넌트에서 관리하므로 콤포넌트 아이디로 js를 생성하지만
//이건 포토기사 아이디가 넘어오므로 기사아이디로 파일을 생성한다.
//다만 겹칠수 있기때문에.. 앞에 "P_" or "G"를 붙여준다.
//중간 경로는 sourcecode로 생성하지 않고 comptype("P" or "G")로 생성한다.
sCompPath = sStaticCompDomain + "component/" + type + "/" + cid.substring(cid.length - 3) + "/G_" + cid + ".js";
$.getScript(sCompPath, function () {
try {
if (typeof (G_JSON) != "undefined") {
sCompHtml = "";
/*
G_JSON.data[nIdx].m_id
G_JSON.data[nIdx].title
G_JSON.data[nIdx].path
G_JSON.data[nIdx].desc
*/
for (var nIdx = 0; nIdx < G_JSON.data.length; nIdx++) {
sGalleryLinkUrl = "window.open('" + sGallaryPageUrl + "m_id=" + G_JSON.data[nIdx].m_id + "&g_type=first', 'photo_gallery','toolbar=no,location=no,directory=no,status=no,menubar=no,scrollbars=no,resizable=no,top=0,left=0,width=960,height=715');";
sCompHtml += "
";
sCompHtml += " ";
sCompHtml += " ";
sCompHtml += " ";
sCompHtml += "
" + G_JSON.data[nIdx].title + " ";
}
if (areaName && areaName.length > 0) {
$("#" + areaName).html(sCompHtml).css({ "display": "" });
displayArticleArea("GALLERY");
} else {
return sCompHtml;
}
} else {
fnCallMakeJson(cid, type, "getRelateGallery('" + type + "', '" + cid + "', '" + areaName + "')");
}
} catch (e) {
if (areaName && areaName.length > 0) {
$("#" + areaName).css({ "display": "none" });
}
alertErrorMsg(e);
}
});
} else {
if (areaName && areaName.length > 0) {
$("#" + areaName).css({ "display": "none" });
}
}
}
function setGalleryForOld() {
var src = $imgItems.first().data('src') || $imgItems.first().attr('src'),
data = [];
$imgItems.each(function (i) {
var $this = $(this),
obj = {};
obj.Id = i;
obj.Image = $this.data('src') || $this.attr('src');
obj.Name = $this.data('name') || $this.attr('name');
obj.Description = $this.data('desc') || $this.attr('alt');
data.push(obj);
});
setPictorialHtml({
parent: $imgItems.first().parent().parent(),
src: src,
count: $imgItems.length,
id: $('#total_id').val(),
type: 'image',
items: data
});
removeItem();
function removeItem() {
$imgItems.each(function (idx, item) {
var $imageWrap = $(item).parent().parent();
removeBr($imageWrap);
$imageWrap.remove();
});
function removeBr($d) {
var $next = $d.next();
if ($next.length > 0 && $next[0].tagName.toLowerCase() == 'br') {
$next.remove();
removeBr($d);
}
}
}
}
//2010년도 이전 이미지 수정 (경로가 "/component/htmlphoto_mmdata"로 시작하는 이미지에 도메인 붙여넣기)
$oldImgItems.each(function () {
var pdsPath = utils.config('pdsPath');
$(this).attr("src", pdsPath + "/news" + $(this).attr("src"));
});
return this.each(function () {
var bodyHtml = $articleBody.html();
// old version check
if (bodyHtml.indexOf(oldTextFilter) != -1 && $imgItems.length > 1) {
setGalleryForOld();
}
// TODO : new version check.
});
};
/**
*
* @param options
*
*/
//http://news.jtbc.joins.com/vod/getvod.aspx?vod_id=NV10010001
//http://home.jtbc.joins.com/vod/getvod.aspx?vod_id=VO10010109
$.fn.articleVod = function (options) {
//utils.log('## articleVod');
var defaults = {
body: '#article_body',
vodIds: []
},
refType = { joongang: '1', ilgan: '2' },
cRefType = refType.joongang, // 중앙
config = $.extend(true, defaults, options);
var VodPlayList = {},
deviceWidth = $(window).width();
// 일간 (http://isplus.joins.com, http://isplus.live.joins.com)
if (location.host.indexOf('isplus') > -1) {
cRefType = refType.ilgan;
}
//동영상 플레이어 테그 삽입
function fnVodPlay(vod_id, ref, options) {
}
function fnGetParamValue(searchStr, getKey) {
try {
var aParams = fnGetParamArray(searchStr)
if (aParams[getKey]) { return aParams[getKey]; } else { return ""; }
} catch (e) { return ""; }
}
function fnGetParamArray(searchStr) {
try {
var aParams = new Array(), sParams = searchStr.split("?")[1].toString().replace(/&/ig, "&");
for (var nIdx = 0; nIdx < sParams.split("&").length; nIdx++) {
if (sParams.split("&")[nIdx].toString().indexOf("=") > -1) {
aParams[sParams.split("&")[nIdx].split("=")[0].toString()] = sParams.split("&")[nIdx].split("=")[1].toString();
} else {
aParams[sParams.split("&")[nIdx].toString()] = true;
}
}
return aParams;
} catch (e) { return new Array(); }
}
function mobile_device_detect() {
var UserAgent = navigator.userAgent,
rtn = "W";
if (UserAgent.match(/iPod|Android|Windows CE|BlackBerry|Symbian|Windows Phone|webOS|Opera Mini|Opera Mobi|POLARIS|IEMobile|lgtelecom|nokia|SonyEricsson/i) != null) {
rtn = "M";
} else if (UserAgent.match(/iPad|iphone/i) != null) {
rtn = "P";
}
return rtn;
}
function fnVodPlayForJtbc(vodConfig, ref, options, $ele) {
$.when(
$.getScript("https://nstatic.jtbc.joins.com/jtbcplayer/1.0.0/js/jtbcplayer.min.js"),
$.Deferred(function (deferred) {
$(deferred.resolve);
})
).done(function () {
// 기본 옵션
var type = vodConfig.service;
var vod_id = vodConfig.id;
var default_width = $ele.parent().width();
var default_height = parseInt(default_width * 0.6);
var default_options = { width: default_width, height: default_height, image: "", userid: "", ad_presn: "", ad_postsn: "", ad_vt: "N" };
// param으로 들어온 옵션을 기본 옵션과 병합
var opts = $.extend({}, default_options, options);
var _vod_memid = "";
try {
_vod_memid = getCookieA("MemArray", "MemID");
} catch (e) {
}
var device_info = mobile_device_detect();
var url = utils.config('jtbcNewsPath') + '/vod/getvod.aspx?vod_id=' + vod_id + "&m=" + device_info;
if (type == SERVICE_TYPE.jtbc) url = utils.config('jtbcNewsPath') + '/vod/getvod3.aspx?vod_id=' + vod_id + "&m=" + device_info;
utils.getJsonp({
url: url,
success: function (res) {
if (res != null && res != {}) {
var vodInfo = res;
var params = {};
var _width = opts.width;
var _ratioHeight = (9 / 16) * _width;
params.width = _width;
params.height = _ratioHeight;
/* option으로 이미지정보가 들어오는 경우 동영상 썸네일 이미지를 그것으로 대체, 기본은 동영상에 연결된 섬네일로 보임 */
if (opts.image != "") {
params.image = opts.image;
} else {
params.image = vodInfo.img_url;
}
if (!vodInfo.mobile_file_url) {
return; /* 동영상 파일정보 없음 */
}
if (typeof (vodInfo.mobile_file_url) != "undefined" && vodInfo.mobile_file_url.indexOf("rtmp://") > -1) {
var arr_file_url = vodInfo.mobile_file_url.split("&file=");
params.provider = "http";
params.streamer = escape(arr_file_url[0]);
params.file = escape(arr_file_url[1]);
} else {
params.file = vodInfo.mobile_file_url;
params.provider = vodInfo.mobile_file_url.substring(0, 4);
}
var _vod_packcode = "",
_vod_pay = "N",
_vod_paydiv = "00",
_vod_payamount = "0";
//utils.log(params);
//utils.log('## vod_id : ' + vod_id);
var capDiv = vodConfig.caption.trim().length > 0 ? '
' + vodConfig.caption + '
' : '';
var $newDiv = $('
');
$ele.replaceWith($newDiv);
if ($ele.length > 0) {
jtbcplayer('div_' + vod_id).setup({
'width': '100%',
'image': params.image,
'height': params.height,
'file': vodInfo.mobile_file_url
});
} // end of check "div_"+ vod_id area
//console.log(vodInfo.mobile_file_url);
if ($("#div_" + vod_id).length > 0) {
VodPlayList[vod_id] = "false";
// Play Log
if (jtbcplayer && jtbcplayer('div_' + vod_id)) {
jtbcplayer('div_' + vod_id).onPlay(function () {
if (VodPlayList[vod_id] == "false") {
VodPlayList[vod_id] = "true"; // 최초 1회만 로그카운트 기록 수행
var vod_logger = utils.config('jtbcCounterPath') + "/bin/ArticleCounterLogger.dll?Total_ID=" + vod_id + "&Ctg_ID=00&Master_Code=&comm1=" + _vod_pay + "&comm2=" + _vod_paydiv + "&comm3=" + _vod_payamount + "&memid=" + opts.userid + "&gubun=" + device_info + "&cloc=&ref=" + ((typeof (ref) != "undefined") ? ref : "") + "&svc=T";
$("body").append("
");
}
});
}
}
utils.resetArticleSubWidget && utils.resetArticleSubWidget();
}
}
});
});
}
var SERVICE_TYPE = {
jtbc: 'jtbc',
news: 'news',
youtube: 'youtube',
wsj: 'wsj', // wallstreet journal.
ovp: 'ovp',
ovplive: 'ovplive',
navercast: 'navercast', // 타입추가 (네이버 캐스트)
fblive: 'facebooklive', // 타입추가 (페이스북 라이브)
kakaotv: 'kakaotv', // 타입추가 (카카오TV)
ooyala: 'ooyala', // 타입추가 (신규ovp)
ooyalalive: 'ooyalalive' // 타입추가 (신규ovplive)
};
function setVodPlayerForIFrame($target, config) {
var $iframeWrap = $('
'),
width = ARTICLE_SIZE.body,
height = '100%',
url = (config.service === "youtube" ? 'https://www.youtube.com/embed/' + getYouTubId(config.id) : config.id),
iframeAttr = { allowfullscreen: true, webkitallowfullscreen: true, mozallowfullscreen: true, frameborder: 0, scrolling: 'no', width: width, height: height, src: url };
$("iframe", $iframeWrap).attr(iframeAttr);
if ($.trim(config.caption).length > 0) {
$iframeWrap.append($('
').text(config.caption));
}
$target.replaceWith($iframeWrap);
function getYouTubId(url) { var id = '', arrUrl = url.split('/'); id = arrUrl[arrUrl.length - 1]; return id; }
}
function setVodPlayerForOvp($target, config, options) {
var params = config.id.slice(config.id.indexOf('?') + 1).split('&');
var type;
var ovpRecommendType = 0;
for (var j = 0; j < params.length; j++) {
if (params[j].indexOf("ro=") >= 0) {
type = params[j].slice(params[j].indexOf('=') + 1);
break;
}
}
for (var i = 0; i < params.length; i++) {
if (params[i].indexOf("rc=") >= 0) {
ovpRecommendType = params[i].slice(params[i].indexOf('=') + 1);
break;
}
}
var szHtml = [];
var url = config.id.replace("mute", "");
url = url.substring(0, url.indexOf('?wmode'));
var ua = navigator.userAgent;
var IsLowerAndVer = false;
if (ua.indexOf("Android") >= 0) {
try {
var androidversion = parseFloat(ua.slice(ua.indexOf("Android") + 8));
if (androidversion < 4.3) { //안드로이드 구 버전에 대해 기존처럼 iframe으로 처리.
IsLowerAndVer = true;
}
} catch (e) { }
}
if (IsLowerAndVer == true) {
var
$iframe = $('
'),
iframeAttr = { allowfullscreen: true, webkitallowfullscreen: true, mozallowfullscreen: true, frameborder: 0, scrolling: 'no', width: ARTICLE_SIZE.body, height: '100%', width: '100%' };
iframeAttr.src = url;
//사이즈에 따라 class 변경
if (type == 2) {
$iframe.attr('class', "ovp_player ovp_player1-1");
}
else if (type == 3) { //세로영상
$iframe.attr('class', "ovp_player ovp_player9-16");
}
$iframe.find('#kollus_ovp').attr(iframeAttr);
$target.replaceWith($iframe);
if (this.ro != 3 && ovpRecommendType > 0) setOvpRecommend($iframe, type, ovpRecommendType); //추천동영상
} else {
jQuery.ajax({
type: 'GET',
url: utils.config('apiPath') + '/Video/getOvpUrlInfo?mediaKey=' + url.substring(url.lastIndexOf('/') + 1, url.length) + "&ro=" + type,
dataType: 'json',
ro: type,
target: $target,
success: function (res) {
szHtml.push('
'); }
else if (this.ro == 3) { szHtml.push(' ovp_player9-16">'); }
else { szHtml.push(' ovp_player16-9">'); }
szHtml.push('
');
if (!navigator.userAgent.match(/(iphone)|(ipod)|(ipad)/i)) {
szHtml.push('동영상 재생 ');
}
else {
szHtml.push(' '); //아이폰인 경우 Native Play버튼 노출
}
szHtml.push('');
szHtml.push('
');
szHtml.push('
');
$(this.target).removeAttr('class');
$(this.target).removeAttr('data-id');
$(this.target).html(szHtml.join(''));
$(this.target).find('button').on('click', function () {
try {
event.stopPropagation();
event.preventDefault();
} catch (e) { }
$(this).parent().find('source').attr('src', $(this).parent().find('source').attr('data-id'));
$(this).parent().find('source').removeAttr('data-id');
$(this).parent().find('video').attr('controls', 'true');
$(this).parent().find('video').load();
video = $(this).parent().find('video')[0].play();
$(this).remove();
});
if (this.ro != 3 && ovpRecommendType > 0) setOvpRecommend(this.target, this.ro, ovpRecommendType); //추천동영상
},
error: function (request, status, error) {
utils.log("code:" + request.status + "\n" + "message:" + request.responseText + "\n" + "error:" + error);
}
});
}
}
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('pcid=' + utils.getCookie("PCID"));
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');
}
jQuery.ajax({
type: 'GET',
url: cruzUrl.join(''),
dataType: 'json',
success: function (res) {
if (res.length > 0) {
szHtml.push('
');
szHtml.push('
');
szHtml.push('
');
if ($('body').hasClass('jstyle') === true) {
szHtml.push('
');
szHtml.push('
');
$.each(res, function (i, r) {
szHtml.push('
');
});
szHtml.push('
');
szHtml.push('
');
szHtml.push('
');
} else {
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('
');
$player.find(".player_area").after(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
}
}
}
});
}
function setVodPlayerForOvpLive($target, config, options) {
var params = config.id.slice(config.id.indexOf('?') + 1).split('&');
var type;
for (var j = 0; j < params.length; j++) {
if (params[j].indexOf("ro=") >= 0) {
type = params[j].slice(params[j].indexOf('=') + 1);
break;
}
}
var
url = config.id.replace("mute", ""),
$iframe = $('
'),
iframeAttr = { allowfullscreen: true, webkitallowfullscreen: true, mozallowfullscreen: true, frameborder: 0, scrolling: 'no', width: ARTICLE_SIZE.body, height: '100%', width: '100%' };
iframeAttr.src = url;
$iframe.find('#kollus_ovp').attr(iframeAttr);
$target.replaceWith($iframe);
}
function serviceCheck(serv) {
var servicecode = "";
switch (serv) {
case "10": case "28": case "24":
servicecode = "10";
break;
case "11": case "16":
servicecode = "11";
break;
case "12": case "22":
servicecode = "12";
break;
case "13":
servicecode = "13";
break;
case "14":
servicecode = "14";
break;
case "15": case "36":
servicecode = "15";
break;
case "17":
servicecode = "17";
break;
case "20": case "27":
servicecode = "20";
break;
case "35":
servicecode = "35";
break;
default:
servicecode = "00";
}
return servicecode;
}
function setVodPlayerForOoyala($target, config, options) {
var params = config.id.slice(config.id.indexOf('?') + 1).split('&');
var rotype;
var type = "";
var ovpRecommendType = 0;
var target = $target;
var autoplay = false;
var loop = false;
var mute = false;
var upjam = false;
if ($.trim(config.ro).length > 0) {
rotype = config.ro;
}
if ($.trim(config.rc).length > 0) {
ovpRecommendType = config.rc;
}
if ($.trim(config.loop).length > 0) {
loop = config.loop;
}
if ($.trim(config.mute).length > 0) {
if (config.mute == true) {
mute = true;
}
}
if (rotype == 2) {
type = "a";
} else if (rotype == 3) {
type = "b";
}
if ($.trim(config.up).length > 0) {
if (config.up.toUpperCase() == "JAM") {
type = "b";
}
}
var szHtml = [];
var url = config.id;
var servcode = serviceCheck($("#servcode").val());
var rq_url = document.location.href.toString().toLowerCase().replace("#home", "");
var adinfo = "id=" + utils.getCookie("PCID") + "&name=joongangnews§ion=" + servcode;
if (url.indexOf('?') >= 0) {
url = config.id.substring(0, url.indexOf('?'));
}
url = "https://oya.joins.com/iframe.html?ec=" + url + "&options[autoplay]=" + autoplay + "&options[loop]=" + loop + "&options[muteFirstPlay]=" + mute;
url += "&docUrl=" + encodeURIComponent(rq_url);
url += "&adinfo=" + encodeURIComponent(adinfo);
if (type.length > 0) {
url += "&type=" + type;
}
var width = 580; height = 326;
$(target).removeAttr('data-service');
$(target).removeAttr('data-src');
$(target).removeAttr('class');
if (rotype == 2) {
szHtml.push('
');
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 (rotype != 3 && ovpRecommendType > 0) setOvpOoyalaRecommend($target, rotype, ovpRecommendType); //추천동영상
utils.resetArticleSubWidget && utils.resetArticleSubWidget();
}
function setVodPlayerForOoyalaLive($target, config, options) {
var params = config.id.slice(config.id.indexOf('?') + 1).split('&');
var target = $target;
var autoplay = false;
var mute = 1;
if ($.trim(config.mute).length > 0) {
if (config.mute == true) {
mute = 0;
}
}
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();
url = "https://oya.joins.com/iframe.html?ec=" + url + "&options[autoplay]=" + autoplay + "&options[initialVolume]=" + 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 setOvpOoyalaRecommend($player, ro, type) {
var PDS_DOMAIN = utils.config('pdsPath'); //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('
');
if ($('body').hasClass('jstyle') === true) {
szHtml.push('
');
szHtml.push('
');
$.each(res, function (i, r) {
szHtml.push('
');
});
szHtml.push('
');
szHtml.push('
');
szHtml.push('
');
szHtml.push('
');
szHtml.push('
');
} else {
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('
');
}
$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
}
}
}
});
}
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: '' };
// 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") || "";
if (!vodConfig.id) {
return;
}
// ovp 추가
if (vodConfig.service == SERVICE_TYPE.ooyala || vodConfig.service == SERVICE_TYPE.ooyalalive) {
var aVodOpt = fnGetParamArray(vodConfig.id);
for (var key in aVodOpt) { vodConfig[key] = aVodOpt[key]; }
}
//utils.log('#### vodConfig.service : ' + vodConfig.service);
var options = { "ad_presn": 309, "ad_postsn": 324 };
// 뉴스용 플레이어입니다. 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) {
setVodPlayerForOvp($ele, vodConfig, options);
} else if (vodConfig.service == SERVICE_TYPE.ovplive) {
//setVodPlayerForOvpLive($ele, vodConfig, options);
} else if (vodConfig.service == SERVICE_TYPE.ooyala) {
setVodPlayerForOoyala($ele, vodConfig, options);
} else if (vodConfig.service == SERVICE_TYPE.ooyalalive) {
setVodPlayerForOoyalaLive($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);
} else {
utils.error('ARTICLE COMPONENT ERROR : not defined vod service.', true);
}
});
};
/**
* articleSns
*/
$.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.4');
}
},
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: '
',
//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];
if (html !== undefined && html.length > 0) {
var windowSize = utils.windowSize();
var minWidth = 280;
var defaultWidth = 0;
if (articleType == ARTICLE_TYPE.live) minWidth = 260;
defaultWidth = windowSize.height < windowSize.width ? windowSize.height : windowSize.width;
width = (defaultWidth < 320) ? minWidth : $('#article_body').width();
html = $(html.replace('{{data.url}}', url).replace('{{WIDTH}}', width));
$dom.replaceWith(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(options || {}, defaults);
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, false).replace(/^src\=/, '');
$contents = $('
');
$(v).replaceWith($contents);
});
};
//기사면 중간 배너 -
두 단락뒤에 삽입, 없을 시에는 마지막에 삽입 혹은 중간에들어간다.
$.fn.articleInnerBigBanner = function () {
var $articleBody = this;
var html = '';
// 아웃스트림 광고
if ($(".photo_left").length <= 0) //utils.getTotalId().toString() != "22456089" && utils.getTotalId().toString() != "22449172"
{
// 중앙일보앱, 평창 기사면에선 광고코드 적용 안함
if (utils.getMetaValue("news_keywords").indexOf('2018평창') === -1 && utils.isJoongangAppCheck() === '') {
if (utils.menu.getPageMenuKey().toLowerCase().indexOf('money') !== -1) {
html = '';
}
else {
html = "";
html += "";
html += "";
html += "
";
html += "";
html += "
";
}
var $target = getRenderTarget($articleBody, 5);
//pos = Math.floor($articleBody.find('>br').length / 2),
//$target = $articleBody.find('>br').length > pos - 1 ? $articleBody.find('>br').eq(pos - 1) : $articleBody;
$target.after(html);
}
}
};
$.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: 70, 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: "65%" },
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);
" + "