PageSourceSearch

https://www.ibric.org/_custom/bric/resource/js/board.sns.share.js?18003

js ibric.org collected 2026-10-01 11:39:41 UTC 11,373 bytes, 383 lines download raw bytes

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.