/** * Article 에서 사용되는 Component 기능을 정의한다. */ (function ($, window, document) { var $leftSns = $('.sns_wrap > .bd'), ARTICLE_SIZE = { body: '100%', topDuplicationMargin: 40 }, apiPath = utils.config('apiPath'), pdsPath = utils.config('pdsPath'), nowDate = new Date(), ARTICLE_FLOATINGBENNER_URL = '//adddn.adotsolution.com/contents/sdk/js/tad.min.js', ARTICLE_FLOATINGBENNER_OPTIONS = { targetId: '', clientId: 'MX0004B99', test: false, slotNo: 103, adType: 'floating', position: { 'baseline': 'left-bottom', 'offsetX': 20, 'offsetY': 60 } }; function getLeftSnsPosition() { var o = $leftSns.offset(), h = $leftSns.height(); return o.top + h; } function getPdsFullPath(p) { if (p.indexOf('http') < 0) { p = pdsPath + p; } return p; } function setPictorialHtml(obj /*$t, src, count*/) { var $t = obj.parent, src = obj.src, count = obj.count, type = obj.type, description = obj.description, $html = $('
화보 뷰' + count + '' + (description !== undefined ? '

' + description + '

' : '') + '
'); $html .data('items', obj.items) .find('.btn_all').on('click', function (e) { var type = $(this).closest('.ab_photo').data('type'); if (type === 'photo') { $html.photoViewer({ id: obj.id, title: obj.title, content: obj.items }); } else { $html.imageViewer({ content: obj.items }); } return false; }); $t.replaceWith($html.css('width', ARTICLE_SIZE.body)); } function setPictorialGalleryHtml(obj) { /*parent, src, count, type, items*/ var html = ''; obj.items.forEach(function (v) { html += '
'; }); $("#tempContent").remove(); $("#star_gallery").append(html); $("#content").show(); } function setPicEnlargeHtml() { var $photoCenterContainer = $('div.ab_photo.photo_center', $('#article_body')), $photoLeftContainer = $('div.ab_photo.photo_left', $('#article_body')), $photoRightContainer = $('div.ab_photo.photo_right', $('#article_body')); $photoCenterContainer.find('.mask').remove(); $photoCenterContainer.each(function () { var $photoWrap = $(this); var imageSize = $photoWrap.width(); if ($photoWrap.find("a[target]").length == 0 && imageSize >= 320) { $photoWrap.attr('data-type', 'image'); $photoWrap.find('.image').append('사진 크게보기'); if (location.hostname.indexOf("dcnewsj.joins.com") > -1) { $photoWrap.find('.image').wrapInner(''); } else { $photoWrap.find('.image').wrapInner('img").attr("src") || $photoWrap.find(".image>img").data("src")) + ' ">'); } } }); $photoCenterContainer.css({ 'width': '100%' }); $photoLeftContainer.each(photoResize); $photoRightContainer.each(photoResize); function photoResize() { var $wraper = $(this); if (!$wraper.parent().hasClass('live_box')) { var $wrap = $(this), resizeWidth = $wrap.width() / 2; $wrap.css('width', resizeWidth); } } $(".ab_box_article").find(".enlarge").remove(); $(".ab_box_article").find("a").has("img").css({ 'pointer-events': 'none' }); $(".ab_box_article").find("a").has("img").click(function () { return false; }); } var imageCallFlag = 'N'; function imageCallEvent(i) { if (imageCallFlag == 'N') { if (i > 0) { var $imgIndex = $('img[data-src]', '#article_body').eq(i); $imgIndex.attr('src', utils.getPdsFullPath($imgIndex.data('src'))); } else { $('img[data-src]', '#article_body').each(function () { if (!$(this).attr('src')) $(this).attr('src', utils.getPdsFullPath($(this).data('src'))); }); imageCallFlag = 'Y'; } } } $.fn.articleComponent = function (options) { var $article = this; $article.articleGallery(); if (utils.config('articleType') == ARTICLE_TYPE.spGallery) { $('div.tag_photobundle', $article).articlePhotoBundleGallery(); $('div.ab_photo.photo_center', $article).articlePhotoBundleGallery(); } else { $('div.ab_bundle', $article).articlePhotoBundle(); } $('div[data-type=sns], div.tag_sns', $article).articleSns(); $('.jtbc_vod, .tag_vod', $article).articleVod(); $('div.tag_pictorial', $article).articlePictorial(); $('div.tag_poll', $article).articlePoll(); $('div.tag_audio', $article).audioPlayer(); $('div.tag_jplus_link', $article).articleJplusLink(); $('div.jch_link', $article).articleJtbcLink(); if ($('div.tag_chart', $article).length > 0) { $.getScript("https://www.gstatic.com/charts/loader.js").done(function () { $('div.tag_chart', $article).articleCharts(); }); } //특정기사 예외처리 서울 학교 지도 if ($("#total_id").val() == "23410238" || $("#total_id").val() == "23409734" || $("#total_id").val() == "23411619") { var setBrPosi = 0; $article.html($article.html().replace(/
(\s+)?( )?(\s+)?
/g, "

")); //$("br + br", $article).eq(Math.floor(($("br + br", $article).length / 3) * 2)).seoulSchoolMap(); if ($("#total_id").val() == "23410238") { setBrPosi = 21; } else if ($("#total_id").val() == "23409734") { setBrPosi = 32; } else if ($("#total_id").val() == "23411619") { setBrPosi = 12; } $("br + br", $article).eq(setBrPosi).seoulSchoolMap(); } // 와이드 모바일용 이미지 속성 변경. var $articlePhotofixr = $('#article_body').find('.ab_photofix'); $articlePhotofixr.each(function (i, v) { var $c = $(v); var $photofixrImagebox = $c.find('.image'); var imgUrl = $photofixrImagebox.css('background-image').replace('url(', '').replace(')', '').replace(/'/g, '').replace(/"/g, ''); if (imgUrl !== "" && imgUrl !== undefined && imgUrl !== null) { $photofixrImagebox.removeAttr("style"); $articlePhotofixr.removeClass(); $articlePhotofixr.addClass("ab_photo photo_center photo_cover"); var html = ""; $photofixrImagebox.html(html); } }); // 모바일용 이미지 속성 변경. setPicEnlargeHtml(); //탐사하다 기사 더보기버튼 if ($(".ab_more_view", $("#article_body")).length > 0) { $(".ab_more_view", $("#article_body")).click(function () { try { $(".ab_more_content", $("#article_body")).show(); $(".ab_more_button", $("#article_body")).hide(); // 모바일용 이미지 속성 변경. setPicEnlargeHtml(); setADLogData("탐사하다 기사 더보기 버튼 클릭 Mo - " + $("#total_id").val()); } catch (ex) { //alert(ex.description); } }); } //이미지 호출 if ($(document).scrollTop() > 0) { imageCallEvent(0); } else { if ($('img[data-src]', $article).length > 1) { if ($('img[data-src]', $article).eq(1).offset().top < $(window).height()) { imageCallEvent(1); } } $(window).one('scroll resize touchstart', function () { imageCallEvent(0); }); } }; /** * 아티클 기자 리스트 */ $.fn.articleReporter = function () { var totalId = $('#totalId').val(), template = '', directive = ''; //url : /reporters/?totalid=123 return this.each(function (i, v) { }); }; /** * 속보 * @param options */ $.fn.articleNewsflash = function (options) { var $articleBody = this; if ($articleBody.find('.ab_topnews').length == 0) { utils.getJsonp({ url: utils.config('apiPath') + '/static/breakingnews', success: render }); } function render(d) { var html = '', template = '', freshTitle = '속보', exculusiveTitle = '단독', data = {}, directives = { link: utils.decorators.link }, $target = getRenderTarget($articleBody, 4); var $etcPhoto = $articleBody.find('div.html_photo_left, div.photo_left, div.html_photo_right, #criteo_network'), $children = $articleBody.children(), etcIndex = $children.index($etcPhoto), brIndex = $children.index($target); if ($etcPhoto.length > 0 && etcIndex == -1) { if (brIndex < 0) { $target = $etcPhoto; } } else { if ($etcPhoto.length > 0) { if (brIndex < 0) { $target = $etcPhoto; } else if (etcIndex < brIndex) { $target = etcIndex == 0 ? $articleBody : $etcPhoto; } } } if (d && d.item && d.item.Title) { var link = d.item.Link.replace(utils.config('webPcPath'), utils.config('webMobilePath')); data = { link: { href: link, html: (d.item.IsFresh ? freshTitle + ' ' + d.item.Title : (d.item.IsExclusive ? exculusiveTitle + ' ' + d.item.Title : d.item.Title)) } }; html = $.renderTemplate({ template: template, data: data, directives: directives }); if ($target == $articleBody) { $target.append(html); } else { $target.before(html); } } } }; function getRenderTarget($container, pos) { return $container.find('>br').length > pos - 1 ? $container.find('>br').eq(pos - 1) : $container; } /* ​ */ /** * 링크 (JPlus) */ $.fn.articleJplusLink = function () { function setHtml($target, data) { var $link = $('
'), imageHtml = '', textHtml = ''; if ($target.length == 0) { return; } imageHtml = getImageHtml(data); textHtml = getTextHtml(data); function getImageHtml(data) { var html = ''; if (data.imageSrc) { html = '' + data.title + ''; } return html; } function getTextHtml(data) { return '' + '
' + '
' + '' + data.title + '' + '' + data.addLink + '' + '
' + '
'; } $link.html('' + imageHtml + textHtml + ''); $target.replaceWith($link); } return this.each(function (i, v) { var $c = $(v), data = $c.data(); data.imageSrc = $c.find('img').length > 0 ? $c.find('img').attr('src') : ''; data.title = $c.find('.tag_title').text() || ''; data.read = $c.find('.tag_read').text() || ''; setHtml($c, data); }); }; /** * 투표 * @param options */ $.fn.articlePoll = function (options) { var defaults = {}, config = $.extend(true, defaults, options), POLL_LAYOUT_TYPE = { horizontal: 'horizontal', vertical: 'vertical' }, POLL_CLASS = { horizontal: 'answer_type1', vertical: 'answer_type2' }, POLL_ING_CLASS = { ing: 'poll_ing', end: 'poll_end' }, POLL_CONTENT_TYPE = { img: 'ad_poll_img', imgtext: 'ab_poll_imgtxt' }, ANSWER_CLASS = { horizontal: ['yes', 'no'], vertical: ['yes', 'etc'] }, LINK_URL = utils.config('pdsPath'), isLogin = userInfo.isLogin(); function setPollHtml($t, pConfig) { var cardCss = { 'width': ARTICLE_SIZE.body, 'margin-left': 0 }, data = pConfig.data, pCls = POLL_CLASS[pConfig.layoutType], pType = getContentType(data.PollItems), totalCount = getTotalCount(data.PollItems), //data.VotedCount, getTotalCount(data.PollItems), startDate = data.StartedDateTime.format('yyyy.MM.dd'), endDate = data.EndedDateTime.format('yyyy.MM.dd'), $poll = $('

투표

'), $pollList = $('
' + data.Title + '' + startDate + ' ~ ' + endDate + ' ' + totalCount + '명 참여
'), $pollGraph = $('
'), $bd = $('
'), ranking = []; // add body if (pCls === 'answer_type1') { $poll.append($bd.append($pollList).append($pollGraph)); } else { $poll.append($bd.append($pollList)); } // add items (answer) data.PollItems.forEach(function (v, i) { var itemCondition = { list: $bd.find('.poll_lst'), graph: $bd.find('.poll_graph'), data: v, index: i, cls: (i > 0 ? 'rt' : 'lt') }, aClsList = ANSWER_CLASS[pConfig.layoutType], aCls = (i < 2 ? aClsList[i] : aClsList[aClsList.length - 1]); if (pConfig.layoutType == POLL_LAYOUT_TYPE.horizontal) { itemCondition.cls = (i > 0 ? 'rt' : 'lt'); } itemCondition.cls = aCls; setItem(itemCondition); }); //클래스 주기 var pollArray = []; if (pCls === 'answer_type1') { var $yes = $poll.find('.poll_graph > dl.yes'), $no = $poll.find('.poll_graph > dl.no'), width = $yes.find('.bg').width(); if (width >= 50) { $yes.addClass('answer01'); $no.addClass('answer02'); } else { $yes.addClass('answer02'); $no.addClass('answer01'); } } else { $poll.find('.poll_lst > dd').each(function () { var $graph = $(this).find('.poll_graph'); if ($graph.length > 0) { pollArray.push({ el: $graph, percent: $graph.find('.bg').width() }); } }); pollArray.sort(function (a, b) { return a.percent - b.percent; }); var high = pollArray[pollArray.length - 1].percent, second = pollArray[pollArray.length - 2].percent; $.each(pollArray, function (i, v) { if (v.percent === high) { v.el.addClass('answer01'); } else if (v.percent === second) { v.el.addClass('answer02'); } else { v.el.addClass('etc'); } }); } // 투표하기 $poll.find('button').on('click', function () { var $btn = $(this), pollItemId = $btn.data('pollitemid'); if (pConfig.data.IsNeedToLogin == true && !isLogin) { return alert('로그인 후 투표가 가능합니다.'); } if ($btn.hasClass('not') === false) { utils.ajaxPost({ url: apiPath + '/poll/' + pConfig.pollId + '/vote', data: { ItemIds: pollItemId }, success: callback }); } function callback(res) { var code = res.Code, msg = ''; if (res.IsSuccess == true) { alert('투표에 참여하셨습니다.'); $btn.addClass('on'); $poll.find('button').attr('disabled', 'disabled').addClass('not').css('pointer-events', 'none'); } else { switch (code) { case 'Duplicated': msg = '중복된 참여입니다.'; break; case 'NotPeriod': msg = '투표 참여기간이 아닙니다.'; break; default: msg = '데이타 처리에 문제가 발생하였습니다.'; break; } alert(msg); } } return false; }); // add poll $t.before($poll).remove(); function getPercent(c) { return Math.round(c / totalCount * 100); } function getTotalCount(list) { var count = 0; list.forEach(function (v) { count += v.VotedCount; }); return count; } function setItem(condition) { var percent = getPercent(condition.data.VotedCount), selectionName = condition.cls === 'yes' ? '찬성' : (condition.cls === 'no' ? '반대' : '기타'), $select = null, $item = null, question = ''; question = condition.data.ImageName !== '' ? '' : ''; question = condition.data.Title !== '' ? question + condition.data.Title : ''; if (pCls === 'answer_type1') { $select = $('
' + question + '
'); if (condition.cls === 'yes') { $item = $('
' + percent + '% (' + condition.data.VotedCount + '명)
' + selectionName + '
'); } else { $item = $('
' + percent + '% (' + condition.data.VotedCount + '명)
' + selectionName + '
'); } condition.list.append($select); condition.graph.append($item); } else { $item = $('
' + question + '
' + 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 += " "; 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 = $('
' + capDiv + '
'); $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('
'); $(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('추천'); //szHtml.push('' + res[0].art_title + ''); 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(''); } 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(' '); 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 = "" + "
" + "
" + "
" + "
*자료: 교육부 학교알리미·학구도안내서비스, 한국감정원 부동산테크, 종로학원하늘교육
" + "
" + "
" + "
" + "
1) 평당가는 3.3m²(1평)당 매매가
*자료: 교육부 학교알리미·학구도안내서비스, 한국감정원 부동산테크, 종로학원하늘교육
" + "
" + "
" + "
" + "
2)
" + "
학종이 본격 도입된 건 2015학년도
" + "
" + "
" + "
" + "
3)
" + "
2010학년도 이후 졸업생 배출한 고교는 세종과학고(2010학년도), 서울국제고(2011학년도), 하나고(2013학년도)
" + "
" + "
" + "
" + "
4)
" + "
저학년은 1~3학년, 고학년은 4~6학년. 고학년·저학년 학생 수 차이가 클수록 중학교 진학을 앞둔 고학년 전입생 수가 많다는 뜻
" + "
" + "
" + "
" + "
5)
" + "
‘졸업생 중 재수생 비율’은 교육부 학교알리미의 고교별 졸업생 진로 중 '기타 비율'
" + "
" + "
" + "
" + ""; this.replaceWith("

" + SchoolMapHtml); }; })(jQuery, window, document);