1if(!window.App) { 2 App = {}; 3} 4if(!App.board){ 5 App.board = {}; 6} 7 8$(function() { 9 10 var boardApp = new App.board.SNS(); 11 12 boardApp.init(); 13 14}); 15 16App.board.SNS = function() { 17 18 var self; 19 var sns = { 20 "facebook" : "https://www.facebook.com/sharer/sharer.php?u=", 21 "twitter" : "https://twitter.com/intent/tweet?url=", 22 "google" : "https://plus.google.com/share?url=", 23 "naverblog" : "http://blog.naver.com/openapi/share?url=", 24 "navershare" : "http://share.naver.com/web/shareView.nhn?url=", 25 "naverband" : "http://www.band.us/plugin/share?route=", 26 "linkedin" : "https://www.linkedin.com/shareArticle?url=" 27 }; 28 29 var _thisHost = location.protocol+'//'+location.host; 30 var shortUrl = window.location.href; 31 32 return { 33 init: function() { 34 self = this; 35 36 // SNS ê³µì 37 self.snsShare(); 38 39 // ë§í¬ ë³µì¬ 40 self.copyUrl(); 41 42 // ì¹´ì¹´ì¤í¡ ê³µì 43 self.kakaoShare(); 44 45 //sns í´ë¦ ë¡ê·¸ ì ì¥ 46 self.snsClickLog(); 47 48 //ë³µì¬ í ì¶ì² ì¶ê° 49 self.addSourceOnCopy(); 50 51 52 }, 53 snsShare : function(){ 54 55 $('.sns').click( function(e) { 56 57 var shortUrl; 58 e.preventDefault(); 59 60 var $this = $(this), id = $this.attr('id') 61 //, url = sns[$this.attr('class')] 62 , url 63 , title; 64 var className = $this.attr('class').replace(/\s{2,20}/g,' ') 65 , classes = className.split(' '); // í´ëì¤ ë¶ë¦¬ 66 67 if (classes.length > 1) { 68 69 url = sns[classes[1]]; 70 } 71 72 73 if ( typeof(url) != 'undefined' ) { 74 75 /* 76 ì§§ì 주ìë íì´ì¤ë¶ìì 미리보기 ìë¨ 77 // ì§§ì 주ì 구í기 78 $.ajax({
79 url: '/cms/util/getShortUrl.do', 80 data: { 81 url: location.pathname + location.search 82 }, 83 success: function(json) { 84 if(json.success) { 85 shortUrl = _thisHost+'/s.do?'+ json.shortUrl; 86 } 87 }, 88 async: false, 89 dataType: 'json' 90 }); 91 */ 92 if($this.attr('data-title')) { 93 title = $this.attr('data-title'); 94 } 95 96 // íì¬ URL ê°ì ¸ì¤ê¸° 97 var currentUrl = window.location.href; 98 99 // # ì ê±° 100 if(currentUrl.lastIndexOf('#') > -1) { 101 currentUrl = currentUrl.substring(0,currentUrl.lastIndexOf('#')); 102 } 103 104 // URLìì '?' 문ì를 기ì¤ì¼ë¡ íë¼ë¯¸í° ë¶ë¶ì ì¶ì¶ 105 var queryString = currentUrl.split('?')[1]; 106 107 108 // íë¼ë¯¸í°ê° ìë 기본 주ì를 ë§ë¦ 109 var baseUrl = currentUrl.split('?')[0]; 110 111 // ì¶ì¶ë íë¼ë¯¸í°ë¥¼ '&' 문ì를 기ì¤ì¼ë¡ ë¶ë¦¬íì¬ ë°°ì´ë¡ ë§ë¦ 112 var paramsArray = queryString.split('&'); 113 114 // íìí íë¼ë¯¸í°ë¥¼ ì ì¸í 쿼리ì¤í¸ë§ì ë§ë¤ê¸° ìí ë³ì 115 var newQueryString = ''; 116 117 // ê° íë¼ë¯¸í°ë¥¼ ìííë©° 'article.offset'ì 'articleLimit'를 ì ì¸í íë¼ë¯¸í°ë¤ì newQueryStringì ì¶ê° 118 119 var excludes = ['article.offset','articleLimit','pager.offset','pagerLimit']; 120 121 for (var i = 0; i < paramsArray.length; i++) { 122 var param = paramsArray[i].split('='); 123 var paramName = param[0]; 124 if( paramName == '' ) continue; 125 if (excludes.indexOf(paramName) == -1 && !paramName.startsWith('sr') ) { 126 if (newQueryString !== '') { 127 newQueryString += '&'; 128 } 129 newQueryString += paramName + '=' + param[1]; 130 } 131 } 132 133 // ìë¡ì´ 주ì를 ë§ë¤ì´ ë¦¬í´ 134 if (newQueryString !== '') { 135 baseUrl += '?' ; 136 } 137 138 139 140 //$this.attr('href', '#' + id ); 141 var docTitle = encodeURIComponent(document.title); 142 143 if(classes[1] == 'facebook') url += encodeURIComponent( baseUrl + newQueryString ); 144 if(classes[1] == 'twitter') url += encodeURIComponent( baseUrl + newQueryString ) + '&text='+docTitle; 145 if(classes[1] == 'google') url += encodeURIComponent( newUrl ); 146 if(classes[1] == 'naverblog' || $this.attr('class') == 'navershare') url += encodeURIComponent( baseUrl + newQueryString ) + '&title=' + docTitle ; 147 if(classes[1] == 'naverband') url += encodeURIComponent( baseUrl + newQueryString ) + '?body=' + docTitle ; 148 if(classes[1] == 'linkedin') url += encodeURIComponent( _thisHost + '&mini=true'); 149 150 151 window.open(url,'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=680,width=830'); 152 153 } 154 155 156 //jwxe_popupWindow( url , "830", "680", true, true); 157 }); 158 159 }, 160 copyUrl : function(){ 161 162 if( $('.copy-url').length > 0 ){ 163 var btns = document.getElementsByClassName('copy-url'); 164 // ì§§ì 주ì 구í기 165 if(shortUrl == window.location.href ){ 166 $.ajax({
167 url: '/cms/util/getShortUrl.do', 168 data: { 169 url: location.pathname + location.search 170 }, 171 success: function(json) { 172 if(json.success) { 173 shortUrl = _thisHost+'/s.do?'+ json.shortUrl; 174 } 175 }, 176 dataType: 'json' 177 }) 178 .always(function() { 179 //ë§í¬ë³µì¬ ë²í¼ì´ 1ê° ì´ìì¡´ì¬í¨, 기존 idë¡ ì ì´íë ë°©ììì classë¡ ì ì´íë ì½ëë¡ ë³ê²½ 180 for(var i = 0; i < btns.length; i++){ 181 var btn = btns[i]; 182 183 //btn.setAttribute('data-clipboard-text', currentUrl); //ì¼ë° ë§í¬ ë³µì¬ 184 btn.setAttribute('data-clipboard-text', shortUrl); //ì§§ì ë§í¬ ë³µì¬ 185 186 var clipboard = new ClipboardJS(btn); 187 188 clipboard.on('success', function(e) { 189 alert('ë³µì¬ëììµëë¤.'); 190 }); 191 clipboard.on('error', function(e) { 192 console.log('fail...'); 193 }); 194 195 } 196 }); 197 } 198 199 return shortUrl; 200 201 } 202 203 }, 204 kakaoShare : function(){ 205 if($('.b-share-list a.kakao').length > 0 || $('.b-share-box a.kakao').length > 0 || $('.b-share-mini-list a.kakao').length > 0){ 206 207 var kakaoKey = '02e2a869e52ab895486ac318c411b9a1'; 208 var currentUrl = window.location.href; 209 210 if(currentUrl.startsWith("https://www.ibric.org")) { 211 kakaoKey = '7da2d1b688f02ef01af2779b8b245a67'; 212 } 213 214 Kakao.init(kakaoKey); 215 216 $('.kakao').click( function(e) { 217 218 const title = document.title; 219 let content = document.title; 220 221 if( document.querySelector('meta[itemprop="description"]')!= null ){ 222 content = document.querySelector('meta[itemprop="description"]').getAttribute('content'); 223 } 224 let img = window.location.hostname + '/_res/bric/_share/img/BRIC_LOGO.jpg'; 225 if( document.querySelector('meta[itemprop="image"]') != null ){ 226 img = document.querySelector('meta[itemprop="image"]').getAttribute('content'); 227 } 228 229 const url = window.location.href; 230 231 Kakao.Share.sendDefault({ 232 objectType: 'feed', 233 content: { 234 title: title, 235 description: content, 236 imageUrl: img, 237 link: { 238 mobileWebUrl: url, 239 webUrl: url, 240 }, 241 } 242 }); 243 }); 244 } 245 246 }, 247 248 snsClickLog : function(){ 249 250 $('a.sns').on('click', function() { 251 252 $this = $(this); 253 254 menuCd = CMS.menuCd; 255 snsType = ''; 256 257 let articleNo = ''; 258 if(CMS.boardNo != ''){ 259 const url = new URL(window.location.href); 260 const params = new URLSearchParams(url.search); 261 262 boardMode = params.get('mode'); 263 articleNo = params.get('articleNo'); 264 265 if( boardMode == 'series_view'){ 266 menuCd = 574; // ê°ë³ì°ì¬ììììì ì°ì¬ 모ëì¼ëë ì°ì¬ë¡ í´ë¦ì 267 } 268 269 270 if(articleNo == ''){ 271 articleNo = $('[name=articleNo]').val(); 272 } 273 if(boardTy == 'series_author' && boardMode != 'series_list' ){ 274 articleNo = $('[name=newsArticleNo]').val(); 275 276 if( !articleNo) { 277 articleNo = params.get('newsArticleNo'); 278 } 279 280 } 281 282 if( boardMode == 'series_view' ){ 283 articleNo = $('[name=newsArticleNo]').val(); 284 285 if( !articleNo) { 286 articleNo = params.get('newsArticleNo'); 287 } 288 289 } 290 291 292 }else{ 293 appKey = CMS.appKey; 294 const urlParams = new URLSearchParams(window.location.search); 295 296 297 298 if( appKey == "hbs_treatise" 299 || appKey == "tr_interview" //íë¹ì¬ ë ¼ë¬¸, ììí¼ì¸ì©, íë¹ì¬ ì¸í°ë·° 300 || appKey == "webinar-user" 301 || appKey == "webinar-user-coming" 302 || appKey == "webinar-user-held" 303 || appKey == "webinar-user-enterprise" 304 || appKey == "webinar-user-enterprise-coming" 305 || appKey == "webinar-user-enterprise-held" 306 || appKey == "webinar-plan-user" 307 || appKey == "webinar-plan-user-new" 308 || appKey == "webinar-plan-user-held" 309 || appKey == "hbs_researcher" // íë¹ì¬ì°êµ¬ì 310 311 312 ){ //íì , 기ì 기ì , 기í ì¨ë¹ë 313 314 if(urlParams.get('id') != null){
315 articleNo = urlParams.get('id'); 316 317 if(appKey == "hbs_treatise" || appKey == "tr_interview" ){//íë¹ì¬ ë ¼ë¬¸, ììí¼ì¸ì©, íë¹ì¬ ì¸í°ë·°ì ê²½ì° ì ì idë í¬í¨ 318 if(urlParams.get('authorId') != null){ 319 articleNo += '|' + urlParams.get('authorId'); 320 } 321 } 322 } 323 324 if( appKey == "hbs_researcher" ){ 325 // íë¹ì¬ì°êµ¬ì 326 if(urlParams.get('srAuthorId') != null){ 327 328 articleNo = urlParams.get('srAuthorId'); 329 330 articleNo += '|' + urlParams.get('srAuthorId'); 331 } 332 } 333 334 335 } 336 } 337 338 if($this.hasClass('kakao')){ 339 snsType = 'kakao'; 340 }else if($this.hasClass('twitter')){ 341 snsType = 'twitter'; 342 }else if($this.hasClass('facebook')){ 343 snsType = 'facebook'; 344 } 345 346 $.ajax({ 347 url: '/app/sns/log/insert.do', 348 data: { 349 menuCd : menuCd, 350 snsType : snsType, 351 articleNo : articleNo 352 }, 353 success: function(json) { 354 355 }, 356 error: function() { 357 console.log('error'); 358 }, 359 async: false, 360 dataType: 'json' 361 }); 362 }); 363 }, 364 addSourceOnCopy : function(){ 365 $(document).on('copy', '[data-copy-source]', function(event) { 366 367 var clipboardData = event.originalEvent.clipboardData || window.clipboardData; 368 var selectedText = window.getSelection().toString(); 369 var shortUrl = self.copyUrl(); 370 var type = boardTy == 'report' ? ' [BRIC Bio리í¬í¸]' : ' [BRIC Bioíµì ì]'; 371 var writer = $('[data-writer]').attr('data-writer'); 372 writer = writer ? writer + ', ' : ''; 373 var sourceText = `\n\nì¶ì²:${type} ${writer}${$('[data-title]').text().trim()},\n${shortUrl}`; 374 375 clipboardData.setData('text', selectedText + sourceText); 376 event.preventDefault(); 377 }); 378 379 } 380 381 } 382} 383
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.