PageSourceSearch

https://srhr.kr/js/channel_plugin.js?1743386991

js srhr.kr collected 2026-09-24 10:31:13 UTC 8,093 bytes, 281 lines download raw bytes

1/*---------------------------------------------------
2#	Channel Plugin
3---------------------------------------------------*/
4var CHANNEL_PLUGIN = function(){
5	var user_profile = {};
6	var init = function(pluginSetting, sub_data){
7		loadScript(sub_data.test);
8		var updateProfile = pluginSetting['updateUserProfile'];
9		delete pluginSetting['updateUserProfile'];
10		if(updateProfile){
11			$.extend(pluginSetting,{"profile" : getUserProfile()});
12		}
13		// 채널 부팅
14		window.ChannelIO("boot", pluginSetting, function (error, user) {
15			if (error) {
16				//console.error(error);
17			} else {
18				if ( typeof user.profile !== "undefined" ) {
19					$.extend(user_profile, user.profile);
20				}
21				const channelTalkJoinFlag = localStorage.getItem('channelTalkJoinFlag');
22				if(sub_data.join || channelTalkJoinFlag === 'true') {
23					addMarketingTrace("SignUp");
24					localStorage.removeItem('channelTalkJoinFlag');
25				}
26			}
27		});
28
29	};
30
31	var loadScript = function(test){
32		test = typeof test == 'undefined' ? false : test;
33		var w = window;
34		if (w.ChannelIO) {
35			return (window.console.error || window.console.log || function(){})('ChannelIO script included twice.');
36		}
37		var d = window.document;
38		var ch = function() {
39			ch.c(arguments);
40		};
41		ch.q = [];
42		ch.c = function(args) {
43			ch.q.push(args);
44		};
45		w.ChannelIO = ch;
46		function l() {
47			if (w.ChannelIOInitialized) {
48				return;
49			}
50			w.ChannelIOInitialized = true;
51			var s = document.createElement('script');
52			s.type = 'text/javascript';
53			s.defer = true;
54			s.src = test ? 'https://cdn.exp.channel.io/plugin/ch-plugin-web-exp.js':'https://cdn.channel.io/plugin/ch-plugin-web.js';
55			s.charset = 'UTF-8';
56			var x = document.getElementsByTagName('script')[0];
57			x.parentNode.insertBefore(s, x);
58		}
59		if (document.readyState === 'complete') {
60			l();
61		} else {
62			window.addEventListener('load', l, false);
63		}
64	};
65	/*---------------------------------------------------
66		#	유저 프로필 정보 가져오기
67	---------------------------------------------------*/
68	var requestUserProfile = function(type,result){
69		$.ajax({
70			"type": "GET",
71			"url": "/ajax/get_user_profile.cm",
72			"data": { "type": type, "__" : MEMBER_HASH },
73			"dataType": "json",
74			"async": false,
75			"success": function(res) {
76				if ( res.msg === "SUCCESS" ) {
77					if( typeof res.profile === "undefined"){
78						result({});
79					}else{
80						result(res.profile);
81					}
82				}
83			}
84		});
85	};
86	/**
87	 * boot
88	 * @returns {{}|boolean}
89	 */
90	var getUserProfile = function(){
91		if ( typeof window.ChannelIO === "undefined" ) { return false; }
92		var data = {};
93		requestUserProfile("ALL", function(result){
94			$.extend(data, result);
95		});
96		return data;
97	};
98
99	var updateUserProfile = function(type, update_data){
100		if ( typeof window.ChannelIO === "undefined" ) { return false; }
101		requestUserProfile(type, function(result){
102			if( typeof update_data === "undefined" ){
103				updateChannelProfile(result);
104			}else{
105				updateChannelProfile(update_data);
106			}
107		});
108
109	};
110
111	// var updateCachingDate = function(type){
112	// 	if ( typeof window.ChannelIO === "undefined" ) { return false; }
113	// 	requestUserProfile(type, function(result){
114	// 		console.log(result);
115	// 	});
116	// };
117
118	var updateChannelProfile = function(update_data){
119		if ( typeof window.ChannelIO === "undefined" ) { return false; }
120		if ( Object.keys(update_data).length <= 0 ) { return false; }
121		ChannelIO("updateUser", {"profile": update_data}, function (error, user) {
122			if (error) {
123				console.error(error);
124			} else {
125				console.log('updateUser success', update_data);
126				$.extend(user_profile, user.profile);
127			}
128		});
129	};
130
131	var addCountUserProfileAttr = function(key, count) {
132		if ( typeof user_profile[key] === "undefined" ) { return; }
133		if ( typeof count === "undefined") count = 1;
134
135		var update_profile = {};
136		user_profile[key] = parseInt(user_profile[key]);
137		if ( isNaN(user_profile[key]) ) user_profile[key] = 0;
138
139		update_profile[key] = user_profile[key] + (count);
140		if ( update_profile[key] <= 0 ) update_profile[key] = 0;
141		updateUserProfile("shopping", update_profile);
142	};
143
144
145	//// 마케팅 관련 기능 ////
146
147
148	/*---------------------------------------------------
149	#	Channel 넛지 기능
150	#	https://developers.channel.io/docs/web-chplugin
151	# 	채널측 수정으로 인해 위 링크 동작하지 않음....... (개발 가이드페이지 있는지 확인 후에 제공해주신다고함)
152	#	-------------------------------------------------
153	# 	채널 마케팅 설정 가이드
154	#	https://www.notion.so/bdd5395257204bbfa80dc43be21ff5c7
155	# 	channel_trace.js 에서 옮김..
156	---------------------------------------------------*/
157
158	// 회원가입 완료시
159	var CompleteJoin = function(){
160		addMarketingTrace("SignUp");
161	};
162
163	// 입력폼 응답시
164	var CompleteSubmit = function(){
165		addMarketingTrace("SurveySubmit");
166	};
167
168	// 상품 상세페이지
169	var ViewContent = function(id){
170		addMarketingTrace("ProductView", {"id": id});
171	};
172
173	// 장바구니에 추가
174	var AddToCart = function(id, count, price, currency){
175		addMarketingTrace("AddToCart", {"id": id, "currency": currency, "itemCount": count, "itemPrice": price});
176
177		// 채널 유저 데이터 업데이트 (스크립트로 해야할지..ê
177³ ë¯¼ë¨)
178		user_profile["cartCount"] 	= (typeof user_profile["cartCount"] === "undefined") ? 0 : parseInt(user_profile["cartCount"]);
179		user_profile["cartAmount"] 	= (typeof user_profile["cartAmount"] === "undefined") ? 0 : parseInt(user_profile["cartAmount"]);
180
181		var updatedProfile = {};
182		updatedProfile["cartCount"] 	= user_profile["cartCount"] + count;
183		updatedProfile["cartAmount"] 	= user_profile["cartAmount"] + price;
184		updateUserProfile("cart", updatedProfile);
185	};
186	//위시리스트
187	var AddToWishlist = function(){
188		addMarketingTrace("AddToWish");
189		addCountUserProfileAttr("wishCount");
190	};
191	// 리뷰 작성 완료
192	var CompleteReview = function(){
193		addMarketingTrace("ReviewSubmit");
194		addCountUserProfileAttr("reviewCount");
195	};
196
197	//// 마케팅 - 새로운 주문 관련 기능 ////
198
199
200	var order = {};
201	// 주문서 작성 페이지 진입
202	var AddOrder = function(order_code){
203		if( typeof order_code != "undefined"){
204			addMarketingTrace("CheckoutBegin", {"order_no": order_code});
205		} else {
206			addMarketingTrace("CheckoutBegin");
207		}
208	};
209
210	// 주문정보 추가
211	var AddOrderInfo        = function(name,qty,price){
212		if ( typeof order["products"] == "undefined" ) { order = {"totalQuantity": 0, "products": []}; }
213		order["products"].push({"name": name, "quantity": parseInt(qty), "price": parseInt(price)});
214		order["totalQuantity"]++;
215	};
216
217	// 주문 완료 (결제완료)
218	var CompletePayment = function(price,currency){
219		order["totalPrice"]       = parseInt(price);
220		order["currency"]          = currency;
221		addMarketingTrace("CheckoutComplete", order);
222		updateUserProfile("order");
223
224		order = {};
225	};
226
227
228
229	var addMarketingTrace = function(type, obj){
230		if ( typeof window.ChannelIO === "undefined" ) { return false; }
231		if(obj != undefined){
232			window.ChannelIO("track", type, obj);
233		}else{
234			window.ChannelIO("track", type);
235		}
236	};
237
238	return {
239		"init": function(pluginSetting, sub_data){
240			init(pluginSetting, sub_data);
241		},
242		"updateChannelProfileAttr": function(type){
243			updateUserProfile(type);
244		},
245		"updateChannelProfile": function(profile){
246			updateChannelProfile(profile);
247		},
248		"addCountUserProfileAttr": function(key, count){
249			addCountUserProfileAttr(key, count);
250		},
251		"CompleteJoin": function(){
252			CompleteJoin();
253		},
254		"CompleteSubmit": function(){
255			CompleteSubmit();
256		},
257		"ViewContent": function(id){
258			ViewContent(id);
259		},
260		"AddToCart": function(id, count, price, currency){
261			AddToCart(id, count, price, currency);
262		},
263		"AddToWishlist": function(){
264			AddToWishlist();
265		},
266		"AddOrder": function(order_code){
267			AddOrder(order_code);
268		},
269		"AddOrderInfo": function(name,qty,price){
270			AddOrderInfo(name,qty,price);
271		},
272		"CompleteReview": function(){
273			CompleteReview();
274		},
275		"CompletePayment": function(price,currency){
276			CompletePayment(price,currency);
277		}
278
279	};
280}();
281

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.