PageSourceSearch

https://skinbanobagi.com/app/public/js/common.js?v=1791171901

js skinbanobagi.com collected 2026-10-05 03:46:37 UTC 18,818 bytes, 643 lines download raw bytes

1/*
2 * 공통 응답코드, 로케일 메시지, 환경설정 옵션 데이터를 저장하는 객체
3 */
4var _RESP_CODE = {};
5var _MESSAGES = {};
6var _CFG = {};
7
8/*
9 * app object definition
10 */
11var app = {};
12
13app.loginSession = {};
14app.onAppInit = function () {};
15app.onPageInit = function () {};
16
17/*
18 * date range picker locale settings.
19 */
20var dateRangePickerLocale = {
21	format : "Y-MM-DD",
22	separator: '~',
23	applyLabel: '적용',
24	cancelLabel: '취소',
25	fromLabel: 'From',
26	toLabel: 'To',
27	customRangeLabel: 'Custom',
28	daysOfWeek: ['일', '월', '화', '수', '목', '금','토'],
29	monthNames: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'],
30	firstDay: 0
31};
32
33/*
34 * 공통데이터를 모두 로딩 (개별적으로 로딩하려면 아래 함수 사용)
35 */
36app.loadCommonData = function() {
37	var ajaxReq = new AjaxRequest();
38	ajaxReq.setUrl("/commonApi/commonData");
39	ajaxReq.setType("get");
40	ajaxReq.setSuccess(function(data, status){
41		_RESP_CODE = data.extra.responseCode;
42		_MESSAGES = data.extra.messages;
43		_CFG = data.extra.configurations;
44	});
45	ajaxReq.setError(function(request, status, err){
46		notify("Failed to load common data.");
47	});
48	return ajaxReq.request();
49};
50
51/*
52 * 공통 응답코드 데이터를 로딩
53 */
54app.loadResponseCode = function() {
55	var ajaxReq = new AjaxRequest();
56	ajaxReq.setUrl("/commonApi/commonData/responseCode");
57	ajaxReq.setType("get");
58	ajaxReq.setSuccess(function(data, status){
59		_RESP_CODE = data.extra.responseCode;
60	});
61	ajaxReq.setError(function(request, status, err){
62		notify("Failed to load response code.");
63	});
64	return ajaxReq.request();
65};
66
67/*
68 * 로케일 메시지 데이터를 로딩
69 */
70app.loadMessages = function () {
71	var ajaxReq = new AjaxRequest();
72	ajaxReq.setUrl("/commonApi/commonData/messages");
73	ajaxReq.setType("get");
74	ajaxReq.setSuccess(function(data, status){
75		_MESSAGES = data.extra.messages;
76	});
77	ajaxReq.setError(function(request, status, err){
78		notify("Failed to load message data.");
79	});
80	return ajaxReq.request();
81};
82
83/*
84 * 메시지 데이터를 불러와서 객체에 저장하는 함수
85 */
86app.loadConfigurations = function () {
87	var ajaxReq = new AjaxRequest();
88	ajaxReq.setUrl("/commonApi/commonData/configurations");
89	ajaxReq.setType("get");
90	ajaxReq.setSuccess(function(data, status){
91		_CFG = data.extra.configurations;
92	});
93	ajaxReq.setError(function(request, status, err){
94		notify("Failed to load configurations data.");
95	});
96	return ajaxReq.request();
97};
98
99/*
100 * 로그인세션정보를 로딩
101 */
102app.loadLoginSession = function() {
103	var ajaxReq = new AjaxRequest();
104	ajaxReq.setUrl("/commonApi/users/loginSession");
105	ajaxReq.setType("get");
106	ajaxReq.setHeaders({
107		loginToken : $.cookie("loginToken")
108	});
109	ajaxReq.setSuccess(function(data, status){
110		app.loginSession.userId = data.extra.user_id;
111		app.loginSession.name = data.extra.name;
112		app.loginSession.loginId = data.extra.login_id;
113		app.loginSession.userGroupId = data.extra.user_group_id;
114		app.loginSession.userGroupName = data.extra.user_group_name;
115		app.loginSession.userGroupCode = data.extra.user_group_code;
116		app.loginSession.autoLogin = data.extra.auto_login;
117		app.loginSession.remoteIp = data.extra.remote_ip;
118		app.loginSession.createdAt = data.extra.created_at;
119		app.loginSession.expireAt = data.extra.expire_at;
120	});
121	ajaxReq.setError(function(request, status, err){
122		notify("Failed to load common data.");
123	});
124	return ajaxReq.request();
125};
126
127/*
128 * 로그인 되어 있는지 여부를 리턴
129 */
130app.isLogin = function() {
131	if (app.loginSession.userId == null) return false;
132	else return true;
133};
134
135/*
136 * 로그인 처리
137 */
138app.loginProcess = function(loginId, passwd, options, successCallback, failCallback) {
139	if (typeof(options.autoLogin) == "undefined") options.autoLogin = false;
140	
141	var ajaxReq = new AjaxRequest();
142	ajaxReq.setUrl("/commonApi/users/login");
143	ajaxReq.setType("post");
144	ajaxReq.setDataType("json");
145	ajaxReq.setData({
146		loginId : loginId,
147		passwd : passwd,
148		autoLogin : (options.autoLogin == true) ? "Y" : "N"
149	});
150	ajaxReq.setSuccess(function(data, status){
151		if (data.returnCode == _RESP_CODE.OK.code) {
152			var loginToken = data.extra.loginToken;
153			
154			// loginToken을 쿠키에 저장
155			if (options.autoLogin == true)
156				$.cookie("loginToken", loginToken, { expires: (_CFG.autoLoginTokenExpirePeriod / 86400), path: '/' });
157			else
158				$.cookie("loginToken", loginToken, { path: '/' });
159			
160			// success callback
161			if (typeof(successCallback) === "function") successCallback(data);
162		} else {
163			// fail callback
164			if (typeof(failCallback) === "function") failCallback(data);
165		}
166	});
167	ajaxReq.setError(function(request, status, err){
168		notify(_MESSAGES.COMM["알수없는오류가발생하였습니다"]);
169		
170		// callback
171		if (typeof(failCallback) === "function") failCallback(data);
172	});
173	ajaxReq.request();
174};
175
176/*
177 * 소셜로그인 처리
178 */
179app.socialLoginProcess = function(userId, successCallback, failCallback) {
180	var ajaxReq = new AjaxRequest();
181	ajaxReq.setUrl("/commonApi/users/socialLogin");
182	ajaxReq.setType("post");
183	ajaxReq.setDataType("json");
184	ajaxReq.setData({
185		userId : userId
186	});
187	ajaxReq.setSuccess(function(data, status){
188		if (data.returnCode == _RESP_CODE.OK.code) {
189			var loginToken = data.extra.loginToken;
190			
191			// loginToken을 쿠키에 저장
192			$.cookie("loginToken", loginToken, { path: '/' });
193			
194			// success callback
195			if (typeof(successCallback) === "function") successCallback(data);
196		} else {
197			// fail callback
198			if (typeof(failCallback) === "function") failCallback(data);
199		}
200	});
201	ajaxReq.setError(function(request, status, err){
202		notify(_MESSAGES.COMM["알수없는오류가발생하였습니다"]);
203		
204		// callback
205		if (typeof(failCallback) === "function") failCallback(data);
206	});
207	ajaxReq.request();
208};
209
210/*
211 * 회원으로 강제 로그인 처리 (관리자만 가능)
212 */
213app.forceLoginProcess = function(loginId, passwd, successCallback, failCallback) {
214	var ajaxReq = new AjaxRequest();
215	ajaxReq.setUrl("/commonApi/users/login");
216	ajaxReq.setType("post");
217	ajaxReq.setDataType("json");
218	ajaxReq.setData({
219		loginId : loginId,
220		passwd : passwd
221	});
222	ajaxReq.setSuccess(function(data, status){
223		if (data.returnCode == _RESP_CODE.OK.code) {
224			var loginToken = data.extra.loginToken;
225			
226			// loginToken을 쿠키에 저장
227			$.cookie("loginToken", loginToken, { path: '/' });
228			
229			// success callback
230			if (typeof(successCallback) === "function") successCallback(data);
231		} else {
232			// fail callback
233			if (typeof(failCallback) === "function") failCallback(data);
234		}
235	});
236	ajaxReq.setError(function(request, status, err){
237		notify(_MESSAGES.COMM["알수없는오류가발생하였습니다"]);
238		
239		// callback
240		if (typeof(failCallback) === "function") failCallback(data);
241	});
242	ajaxReq.request();
243};
244
245/*
246 * 로그아웃 처리
247 */
248app.logoutProcess = function(callback) {
249	var ajaxReq = new AjaxRequest();
250	ajaxReq.setUrl("/commonApi/users/logout");
251	ajaxReq.setType("get");
252	ajaxReq.setDataType("json");
253	ajaxReq.setHeaders({
254		loginToken : $.cookie("loginToken")
255	});
256	ajaxReq.setSuccess(function(data, status){
257		if (data.returnCode == _RESP_CODE.OK.code) {
258			// 로그인토큰 정보 삭제
259			$.removeCookie("loginToken", { path: '/' });
260			
261			// success callback
262			if (typeof(callback) === "function") callback(data);
263		} else {
264			notify(data.returnMsg);
265		}
266	});
267	ajaxReq.setError(function(request, status, err){
268		notify(_MESSAGES.COMM["알수없는오류가발생하였습니다"]);
269	});
270	ajaxReq.request();
271};
272
273/*
274 * 휴대폰 인증번호 발급
275 */
276app.createCertificatedNumber = function(mphone, callback) {
277	var ajaxReq = new AjaxRequest();
278	ajaxReq.setUrl("/commonApi/users/certificatedNumber");
279	ajaxReq.setType("post");
280	ajaxReq.setDataType("json");
281	ajaxReq.setData({
282		mphone : mphone
283	});
284	ajaxReq.setSuccess(function(data, status){
285		if (data.returnCode == _RESP_CODE.OK.code) {
286			// success callback
287			if (typeof(callback) === "function")
288				callback(data.extra.mphone, data.extra.hashKey);
289		} else {
290			notify(data.returnMsg);
291		}
292	});
293	ajaxReq.setError(function(request, status, err){
294		notify(_MESSAGES.COMM["알수없는오류가발생하였습니다"]);
295	});
296	ajaxReq.request();
297};
298
299/*
300 * 메시지 데이터에서 치환해야 할 문자열을 치환한다.
301 * message : 메시지 원본 텍스트
302 * tags[] : 치환할 태그
303 * replacements[] : 치환할 값
304 */
305app.replaceMessageText = function(messageText, tags, replacements) {
306	var returnMessageText = messageText;
307	
308	for(var i=0; i<tags.length; i++)
309	{
310		returnMessageText = returnMessageText.replace(tags[i], replacements[i]);
311	}
312	
313	return returnMessageText;
314};
315
316/*
317 * 템플릿 html에서 치환해야 할 문자열을 치환한다.
318 * template : 메시지 원본 텍스트
319 * tags[] : 치환할 태그
320 * replacements[] : 치환할 값
321 */
322app.replaceTemplate = function(templateId, tags, replacements) {
323	var returnTemplate = $("#"+templateId).html();
324	
325	for(var i=0; i<tags.length; i++)
326	{
327		returnTemplate = replaceAll(returnTemplate, tags[i], replacements[i]);
328	}
329	
330	return returnTemplate;
331};
332
333/*
334 * html소스에서 치환해야 할 문자열을 치환한다.
335 * html : 메시지 원본 텍스트
336 * tags[] : 치환할 태그
337 * replacements[] : 치환할 값
338 */
339app.replaceHtml = function(html, tags, replacements) {
340	var returnHtml = html;
341	
342	for(var i=0; i<tags.length; i++)
343	{
344		returnHtml = replaceAll(returnHtml, tags[i], replacements[i]);
345	}
346	
347	return returnHtml;
348};
349
350/*
351 * 응답코드로 응답데이터를 리턴한다.
352 */
353app.responseByCode = function(code) {
354	var response = false;
355	
356	$.each(_RESP_CODE, function(index, item) {
357		if (item.code === code) response = item;
358	});
359	
360	return response;
361};
362
363/*
364 * 웹에디터 초기화 함수
365 * selector : string
366 */
367app.initEditor = function(editorName, selector, formSession, options) {
368	// 옵션
369	if (typeof(options) == "undefined") options = {};
370	if (typeof(options.toolbarType) == "undefined") options.toolbarType = "full";
371	if (typeof(options.height) == "undefined") options.height = 400;
372	if (typeof(options.maxHeight) == "undefined") options.maxHeight = 400;
373	
374	// 툴바 타입 정의
375	var toolbarDef = {};
376	if (options.toolbarType == "full")
377	{
378		toolbarDef = {
379			toolbarButtons : ['bold', 'fontFamily', 'fontSize', 'italic', 'underline', 'textColor', 'strikeThrough', 'emoticons', '|', 'alignLeft', 'alignCenter', 'alignRight', 'outdent', 'indent', 'insertHR', 'insertLink', 'customImageUpload', 'insertVideo', 'insertTable', 'undo', 'redo', 'selectAll', 'html'],
380			toolbarButtonsMD : ['bold', 'fontFamily', 'fontSize', 'italic', 'underline', 'textColor', 'strikeThrough', 'emoticons', '|', 'align',  'outdent', 'indent', 'insertHR', 'insertLink', 'customImageUpload', 'insertVideo', 'insertTable', 'undo', 'redo', 'selectAll', 'html'],
381			toolbarButtonsSM : ['bold', 'fontFamily', 'fontSize', 'italic', 'underline', 'textColor', 'strikeThrough', 'emoticons', '|', 'align',  'outdent', 'indent', 'insertHR', 'insertLink', 'customImageUpload', 'insertVideo', 'insertTable', 'undo', 'redo', 'selectAll', 'html'],
382			toolbarButtonsXS : ['bold', 'fontFamily', 'fontSize', 'italic', 'underline', 'textColor', 'strikeThrough', 'emoticons', 'align',  'outdent', 'indent', 'insertLink', 'customImageUpload', 'insertVideo', 'insertTable']
383		}
384	}
385	if (options.toolbarType == "small")
386	{
387		toolbarDef = {
388			toolbarButtons : ['bold', 'fontFamily', 'fontSize', 'italic', 'underline', 'textColor', 'strikeThrough', 'emoticons', 'align',  'outdent', 'indent', 'insertLink', 'customImageUpload', 'insertVideo', 'insertTable'],
389			toolbarButtonsMD : ['bold', 'fontFamily', 'fontSize', 'italic', 'underline', 'textColor', 'strikeThrough', 'emoticons', 'align',  'outdent', 'indent', 'insertLink', 'customImageUpload', 'insertVideo', 'insertTable'],
390			toolbarButtonsSM : ['bold', 'fontFamily', 'fontSize', 'italic', 'underline', 'textColor', 'strikeThrough', 'emoticons', 'align',  'outdent', 'indent', 'insertLink', 'customImageUpload', 'insertVideo', 'insertTable'],
391			toolbarButtonsXS : ['bold', 'fontFamily', 'fontSize', 'italic', 'underline', 'textColor', 'strikeThrough', 'emoticons', 'align',  'outdent', 'indent', 'insertLink', 'customImageUpload', 'insertVideo', 'insertTable'],
392		}
393	}
394	
395	// 커스텀 이미지 업로드 버튼 추가
396	FroalaEditor.DefineIcon('customImageUpload', { NAME: 'customImageUpload'});
397	FroalaEditor.RegisterCommand('customImageUpload', {
398		// Button title.
399		title: '이미지 삽입',
400		
401		icon: "<i class='xi-image-o' style='font-size:20px;'></i>",
402		
403		// Save the button action into undo stack.
404		undo: true,
405		
406		// Focus inside the editor before the callback.
407		focus: true,
408		
409		// Show the button on mobile or not.
410		showOnMobile: true,
411		
412		// Refresh the buttons state after the callback.
413		refreshAfterCallback: true,
414		
415		// 버튼클릭시 호출 콜백함수 정의
416		callback: function () {
417			window.open("/commonApi/files/customEditorImageUploader?editorName="+editorName+"&formSession="+formSession, "editorImageUploader", "width=800, height=400, scrolbars=Y");
418		},
419		
420		// Called when the button state might have changed.
421		refresh: function ($btn) {
422			// The current context is the editor instance.
423			console.log (this.selection.element());
424		}
425	});
426	
427	var editor = new FroalaEditor(selector, {
428		key : _CFG.froalaLicenseKey,
429		attribution: false,
430		language : 'ko',
431		imageDefaultDisplay : 'inline',
432		height : options.height,
433		heightMax : options.maxHeight,
434		imageAddNewLine : true,
435		imageSplitHTML : true,
436		imageAllowedTypes : ['jpeg', 'jpg', 'png', 'gif'],
437		imageDefaultWidth : 0,
438		fontFamily : {
439			"맑은 고딕": '맑은 고딕',
440			"굴림": '굴림'
441		},
442		toolbarSticky: false,
443		quickInsertEnabled: false,
444		imagePasteProcess: true,
445		pasteAllowLocalImages: true,
446		pastePlain: false,
447		imageEditButtons : ['imageAlign', 'imageRemove', 'imageLink', 'imageSize'], // imageReplace
448		toolbarButtons : toolbarDef.toolbarButtons,
449		toolbarButtonsMD : toolbarDef.toolbarButtonsMD,
450		toolbarButtonsSM : toolbarDef.toolbarButtonsSD,
451		toolbarButtonsXS : toolbarDef.toolbarButtonsXD,
452		
453		/*
454		 * image upload options
455		 */
456		// Set the image upload parameter.
457		imageUploadParam: 'file',
458		
459		// Set the image upload URL.
460		imageUploadURL: '/commonApi/files/uploadEditorImage',
461		
462		// Additional upload params.
463		imageUploadParams: {},
464		
465		// Set request type.
466		imageUploadMethod: 'POST',
467		
468		// Set max image size to 5MB.
469		imageMaxSize: 5 * 1024 * 1024,
470		
471		// Allow to upload PNG and JPG.
472		imageAllowedTypes: ['jpeg', 'jpg', 'png'],
473		
474		/*
475		 * video upload options
476		 */
477		videoUploadParam: 'file',
478		videoUploadURL: '/commonApi/files/uploadEditorImage',
479		videoUploadMethod: 'POST',
480		videoMaxSize: 1024 * 1024 * 50,
481		videoAllowedTypes: ['mp4'],
482		
483		events: {
484			'image.beforeUpload': function (images) {
485			
486			},
487			'image.uploaded': function (response) {
488			
489			},
490			'image.inserted': function ($img, response) {
491				$img.css("width", "auto");
492				$img.css("max-width", "100%");
493			},
494			'image.replaced': function ($img, response) {
495			
496			},
497			'image.error': function (error, response) {
498				notify("이미지 업로드 오류입니다.");
499			},
500			'video.inserted': function ($video) {
501				$video.find("video").css("width", "100%");
502				$video.find("video").css("max-width", "870px");
503			}
504		}
505	});
506	
507	return editor;
508};
509
510/*
511 * 커스텀 이미지 업로드로 에디터에 이미지를 삽입했을때 콜백 함수
512 */
513app.onInsertEditorImage = function(editorName, imageUrls) {
514	/*
515	 * 이미지를 개별적으로 하나씩 삽입하면 삽입순서가 안 맞으므로 image.insert 메소드를 사용하지 않고
516	 * html을 직접 만들어 여러개의 이미지를 한 번에 삽입한다.
517	 */
518	var html = [];
519	$.each(imageUrls, function(index, imageUrl){
520		html.push("<p style='text-align:center;'><img src='"+imageUrl+"' class='fr-fic fr-dii'></p>");
521	});
522	
523	editors[editorName].html.insert(html.join(""), true);
524}
525
526/*
527 * 객체의 순서를 변경할 때
528 */
529app.changeDOMSeqAjax = function (listObj, requestUrl, callback) {
530	var uidArray = [];
531	
532	listObj.find(".seqControlCell").each(function () {
533		var uid = $(this).attr("data-seq-uid");
534		uidArray.push(uid);
535	});
536	
537	var ajaxReq = new AjaxRequest();
538	ajaxReq.setUrl(requestUrl);
539	ajaxReq.setType("get");
540	ajaxReq.setData({
541		seqTokens : uidArray.join(",")
542	});
543	ajaxReq.setSuccess(function(data, status){
544		if (typeof(callback) == "function")
545			callback(data);
546	});
547	ajaxReq.setError(function(request, status, err){
548		notify("순서를 변경할 수 없습니다. 잠시후에 다시 시도해주세요.");
549	});
550	ajaxReq.request();
551}
552
553/*
554 * 팝업창 닫기
555 */
556app.closePopup = function(popupId, noToday) {
557	$("#popup_"+popupId).remove();
558	
559	// 팝업이 여러개 노출되어 있을 경우 모든 팝업이 닫히면 오버레이 div도 삭제한다.
560	if ($(".mainLayerPopup").length == 0)
561	{
562		$("#popupContainerOverlay").remove();
563	}
564	
565	// 오늘 더 이상 보지 않기를 클릭했을 경우에는 쿠키를 저장한다.
566	if (noToday == true)
567	{
568		var ajaxReq = new AjaxRequest();
569		ajaxReq.setUrl("/web/popup/noToday");
570		ajaxReq.setType("post");
571		ajaxReq.setData({
572			id : popupId
573		});
574		ajaxReq.setSuccess(function(data, status){
575		});
576		ajaxReq.request();
577	}
578}
579
580/*
581 * 페이지 프리로더 아이콘 보이기/감추기
582 * dimmerOpacity : dimmer 불투명도 (default : 0.6)
583 */
584app.showPageLoader = function(dimmerOpacity) {
585	var paramDimmerOpacity = (dimmerOpacity == undefined) ? 0 : dimmerOpacity;
586	
587	var html = "<div class='pageLoader' style='background-color:rgba(0,0,0,"+paramDimmerOpacity+")'>" +
588		"<div><i class='xi-spinner-3 xi-spin'></i></div>" +
589		"</div>";
590	
591	$("body").remove(".pageLoader");
592	$("body").append(html);
593	
594}
595
596app.hidePageLoader = function() {
597	$("body .pageLoader").remove();
598}
599
600/*
601 * dropzone은 dropzone 클래스를 가진 DOM객체를 자동으로 찾아서 초기화 하므로 이를 disabled시킨다.
602 */
603Dropzone.autoDiscover = false;
604
605
606/*
607 * 페이지 초기화
608 */
609$(document).ready(function () {
610	/*
611	 * 공통 데이터 로딩.
612	 * 로딩이 끝나면 onPageInit함수 호출
613	 */
614	var promise1 = app.loadCommonData();
615	var promise2 = app.loadLoginSession();
616	
617	$.when(promise1, promise2).done(function(){
618		if (typeof(app) != "undefined")
619		{
620			if (typeof(app.onAppInit) === "function") app.onAppInit();
621			
622			if (typeof(app.onPageInit) === "function") app.onPageInit();
623		}
624		else
625		{
626			console.error("app object is not defined.");
627		}
628	});
629	
630	
631	//
632	$(window).resize(function(){
633		setVideoHeight()
634	});
635	setVideoHeight();
636});
637
638
639function setVideoHeight(){
640	var videoH = $(".editorStyleWrapper .fr-video iframe").width()*0.5625;
641	$(".editorStyleWrapper .fr-video iframe").css("height", videoH)
642}
643

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.