PageSourceSearch

https://galleryindex.co.kr/js/module/forum.js

js galleryindex.co.kr collected 2026-09-26 05:53:57 UTC 295,175 bytes, 6,521 lines download raw bytes

1(function($) {
2	$doc = $(document);
3	var fmID = 0,
4		files = [],
5		pY = 0,
6		RELOAD = false, isOff = false,
7		upTYPE = 'image';
8	var user = {
9			'name' : '',
10			'pass' : '',
11			'key' : ''
12		},
13		groups = [],
14		select_group = 0;
15
16	var postUser = {
17		'name' : '',
18		'img' : '',
19		'option' : '',
20		'secret_display' : '',
21		'replied' : '',
22		'writeable'	: false,
23		'sid' : false
24	}
25
26	/* ie attach upload */
27	window.onload = function(){
28		setLanguage(LANG);
29
30		if(document.getElementById('uploadForm') != null) {
31		    document.getElementById('uploadForm').onsubmit = function(e) {
32		        document.getElementById('uploadForm').target = 'uploadIFrame';
33		    }
34		    document.getElementById('uploadIFrame').onload = function(e) {
35		        $('#forum-attach').modal('hide');
36		        var res = $.parseJSON($('#uploadIFrame').contents().find('body').text());
37		        if(typeof res.error != 'undefined' || res.error) {
38		            alert(res.error);
39		            $.processOFF();
40		            return;
41		        }
42		    	$.processOFF();
43		        $.forum.setfile(res.file, res.uploaded.file_name, res.uploaded.orig_name);
44		    }
45		    document.getElementById('uploadFile').onchange = function(e) {
46		    	$.processON();
47		        document.getElementById('uploadForm').submit();
48		    }
49		}
50	}
51    $(function () { 
52    	if(typeof LANG == 'undefined') LANG = getLanguage();
53    });
54
55	var resetObject = function(o) {
56		$.each(o,function(k,v) {
57			o[k] = '';
58		});
59		return o;
60	}
61	var uniqID = function() {
62		return Math.round(new Date().getTime() + (Math.random() * 100));
63	}
64
65	var forumSearchRegexp = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+??>@\#$%&\'\"\\\(\=?쒋€?]/i;
66	var getForumPrevStx = function(id, sfl) {
67		var stx = (typeof $.cookie('forum_'+id+'_prev_stx') == 'undefined') ? '' : $.cookie('forum_'+id+'_prev_stx');
68		var search_field = (typeof sfl == 'undefined' || !sfl) ? $.cookie('forum_'+id+'_prev_sfl') : sfl;
69		if(stx && $.inArray(search_field, ['mb_id','nonmem']) < 0 && forumSearchRegexp.test(stx)) {
70			$.removeCookie('forum_'+id+'_stx',{path:'/'});
71			$.removeCookie('forum_'+id+'_prev_stx',{path:'/'});
72			return '';
73		}
74		return stx;
75	}
76
77
78	function decodeUnicode(str) {
79		return str.replace(/\\u([0-9a-fA-F]{4})/g, function(match, grp) {
80			return String.fromCharCode(parseInt(grp, 16));
81		});
82	}
83
84	function insertHtmlAtCursor(html) {
85	    var sel, range, html;
86	    if (window.getSelection) {
87	        sel = window.getSelection();
88	        if (sel.getRangeAt && sel.rangeCount) {
89	            range = sel.getRangeAt(0);
90	            range.deleteContents();
91			    var htmlNode = document.createElement('p');
92			    htmlNode.innerHTML = html
93	            range.insertNode(htmlNode);
94	            sel.removeAllRanges();
95	            range = range.cloneRange();
96	            range.selectNode(htmlNode);
97	            range.collapse(false);
98	            sel.addRange(range);
99	        }
100	    } else if (document.selection && document.selection.createRange) {
101	        range = document.selection.createRange();
102	        range.pasteHTML(htmlNode);
103	        range.select();
104	    }
105	}
106
107	var setWriteUser = function(data, callback) {
108		resetObject(postUser);
109		postUser.name = data.name;
110		postUser.img = data.myimg;
111		postUser.option = data.option;
112		postUser.secret_display = data.settings.secret_display;
113		postUser.mgr = data.mgr;
114		postUser.replied = data.replied;
115		postUser.writeable = data.writeable;
116			
117		$.post('/fm/guest/login', { user : postUser, guest : user }, function(data2) {
118			if(typeof callback == 'function') {
119				callback();
120			}
121		});
122		return false;
123	}
124
125	var forumWriteform = function(id, pid, reply) {
126		var title 			= (id) ? $('.tpl-forum-title').text() : '',
127			content 		= (id) ? $('.tpl-forum-content .fr-view').html() : '<p><br></p>',
128			name 			= postUser.name,
129			date 			= (id) ? $('.tpl-forum-date').text() : 'now',
130			myimage 		= postUser.img,
131			option 			= postUser.option,
132			secret 			= (option == 'S') ? 'S' : '',
133			notice 			= (option == 'N') ? 'N' : '',
134			secret_display 	= postUser.secret_display,
135			mgr 			= postUser.mgr;
136
137		title = title.replace(/'/g,'&#39;');
138		var square_secret = (secret=='S') ? 'fa-check-square-o' : 'fa-square-o',
139			square_notice = (option=='N') ? 'fa-check-square-o' : 'fa-square-o',
140			secretClass = '',
141			noticeClass = '';
142
143		switch(secret_display) {
144			case 'N' : secretClass = 'hide'; break;
145			case 'A' : 
146				secretClass = 'hide';
147				secret = 'S';
148				break;
149			default : secretClass = 'always'; break;
150		}
151		noticeClass = (mgr==true) ? 'always' : 'hide';
152		if(postUser.replied || reply) noticeClass = 'hide';
153		if(secret=='S' && secret_display!='A') secretClass = '';
154		if(option=='N') noticeClass = '';
155
156		var str = '\
157			<div class="forum-write">\
158				<ul class="forum-user-info clearfix">\
159					<li class="user-image tpl-forum-myimage">\
160						<svg viewbox="0 0 40 40">\
161							<pattern id="forum-write-image" patternUnits="userSpaceOnUse" width="40" height="40">\
162								<image xlink:href="' + myimage + '?_' + new Date().getTime() + '" x="-10" width="60" height="40" />\
163							</pattern>\
164							<polygon points="20 0 37 10 37 30 20 40 3 30 3 10" fill="url(#forum-write-image)" />\
165						</svg>\
166					</li>\
167					<li class="user-info">\
168						<div class="tpl-forum-name">' + name + '</div>\
169						<div class="tpl-forum-date date">' + date + '</div>\
170					</li>\
171					<li class="user-ctrl">\
172						<span id="fm-notice" class="' + noticeClass + '" data-notice="' + notice + '"><i class="fa ' + square_notice + '"></i>' + $.lang[LANG]['board.public'] + '</span>\
173						<span id="fm-secret" class="' + secretClass + '" data-secret="' + secret + '"><i class="fa ' + square_secret + '"></i>' + $.lang[LANG]['board.private'] + '</span>\
174						<span id="fm-reserv" class="' + reservClass + '" data-reserv="' + reserv + '"><i class="fa ' + square_reserv + '"></i>' + $.lang[LANG]['board.reserv'] + '</span>\
175					</li>\
176				</ul>\
177				<input type="hidden" id="fm-id" value="' + id + '">\
178				<input type="hidden" id="fm-pid" value="' + pid + '">\
179				<input type="hidden" id="fm-reply" value="' + reply + '">\
180				<input type="hidden" id="hash" value="' + (($.cookie('hash')) ? $.cookie('hash') : '') + '">\
181				<input class="form-control tpl-forum-title" id="fm-title" value="' + title + '" placeholder="' + $.lang[LANG]['board.enter-title'] + '">\
182				<div class="fm-body fm-content fm-editor" id="fm-editor" data-placeholder="' + $.lang[LANG]['board.enter-content'] + '">' + content + '</div>\
183			</div>\
184			<div class="upload-files"></div>\
185		';
186
187		// $.removeCookie('hash', { path: '/' });
188		return str;
189	}
190
191	$doc.on('keypress','.modal[id*=flat-modal] #mb_id', function(e) {
192		if(e.keyCode == 13) {
193			$('.forum-login').click();
194		}
195	});
196
197	$doc.on('keypress','.modal[id*=flat-modal] #mb_password', function(e) {
198		if(e.keyCode == 13) {
199			$('.forum-login').click();
200		}
201	});
202
203	$doc.on('focus','#fm-title',function(e) {
204		$('.note-toolbar > .btn-group > button').addClass('disabled');
205	}).on('focus','.note-editable',function(e) {
206		$('.note-toolbar > .btn-group > button').removeClass('disabled');
207	});
208
209	$doc.on('click','.note-toolbar > .btn-group > button', function(e) {
210		if($(this).hasClass('disabled')) e.preventDefault();
211	});
212
213	$doc.on('click', '.forum-user-info li.user-ctrl .dropdown-menu', function(e){
214		e.stopPropagation();
215	});
216
217	$doc.on('change', '.tpl-forum-comment_display .comment-onoff', function() {
218		var sid = (typeof SID == 'undefined') ? property.SID : SID;
219		var view = (typeof VIEW == 'undefined') ? property.VIEW : VIEW;
220		var value = $(this).val();
221		if($(this).is('input[type="checkbox"]')) value = ($(this).prop('checked')) ? 'OFF' : 'ON';
222		var settings = {};
223		settings['comment_display'] = value; 
224		$.ajax({
225			url: '/fm/fmSettings/update',
226			data: {sid: sid, settings: JSON.stringify(settings), el: view},
227			method: 'POST',
228			dataType: 'json',
229			async: false,
230			success: function(data) {
231				// console.log(data);
232				checkError(data);
233				var settings = data;
234				if(settings.comment_display != 'OFF') {
235					$('.tpl-forum-comment_display').removeClass('on').addClass('off');
236					$.comment.init();
237				} else {
238					$('.tpl-forum-comment_display').removeClass('off').addClass('on');
239					$('.page-comments').remove();
240				}
241			}
242		});
243	});
244
245
246	var forumView = function(id) {
247		var fv_deferred = $.Deferred();
248
249		setViewPageStyle();
250
251		files = [];
252        $.ajax({
253            url: '/fm/view',
254            dataType: 'json',
255            type: 'POST',
256            data:  { id : id, sid : F_SID },
257            async: false,
258            cache: false,
259            success: function (data) {
260				if(typeof data.error != 'undefined' && data.error) {
261					alert(data.error);
262
263					var error_code = data.code || 0;
264					switch(error_code) {
265						case 404:
266							fv_deferred.reject(data.code);
267							break;
268
269						case 401:
270						case 403:
271							var error_msg = (error_code == 403) ? 'Forbidden' : 'Unauthorized';
272							fv_deferred.reject(`Error ${error_msg}`);
273
274							var umemberActivate = (PAGE_MODE == 'c')? Number(UMEMBER_ACTIVATE) : Number(property.UMEMBER_ACTIVATE);
275							var umember = (PAGE_MODE == 'c')? UMEMBER : property.UMEMBER;
276							var checkLogin = (PAGE_MODE == 'c')? true : umember.check_login;
277							if(umemberActivate == 0 && umember.id_type == 'creatorlink') { //creatorlink login
278								checkLogin = (umember.id !== undefined && umember.id)? true : false;
279							}
280							// $.cookie('gallery','.' + F_PARENT.element, { path: '/' });
281							$('.header.el-menu').hide();
282							$('.el-footer').hide();
283							$.processON('', '#fff');
284
285							if(PAGE_MODE != 'c') {
286								var url = (PAGE_MODE=='s') ? '/' : '/render/';
287								if(checkLogin) {
288									alert(data.error);
289									(F_ONE) ? location.replace(url + '#' + F_PARENT.page) : location.replace(url + F_PARENT.page);		
290								} else {
291									var action = (property.VALIDTYPE == 'SM')  ? '/_login' : '/_cllogin';
292									var url = $(location).attr('pathname');
293									var html = '<form name="write_login_form" id="write-login" method="post" action="' + action + '" style="display:none;">\
294													<input type="hidden" name="status" value="forum_view">\
295													<input type="hidden" name="sid" value="'+property.SID+'">\
296													<input type="hidden" name="page_mode" value="'+data.access+'">\
297													<input type="hidden" name="url" value="'+url+'">\
298												</form>';
299									$('body').append(html);
300									document.write_login_form.submit();
301								}
302							} else {
303								(F_ONE) ? location.replace('/'+CONFIG_URL+'config/page/index#' + F_PARENT.page) : location.replace('/'+CONFIG_URL+'config/page/' + F_PARENT.page);
304							}
305							break;
306
307						default:
308							fv_deferred.reject('Error Undefined');
309							break;
310					}
311
312					return false;
313				}
314
315				if($.inArray(data.fm_type, ['qna','faq']) > -1) {
316					var fm_id = (data.fm_reply!='0' && data.own)? data.fm_reply : data.id;
317					
318					$.cookie('forum-item',F_PARENT.pid, { path: '/' });
319					$.cookie('forum_content_view', F_PARENT.pid + '&' + fm_id, { path: '/', expires: 12 * 60 * 60 * 1000 });
320					$.forum.setForumCookie(F_PARENT.pid, data.page_num, '', '', '');
321
322					if(data.fm_type == 'qna') {
323						var str = '<div class="forum-view" data-forum-type="qna"></div>';
324						if($.clnav.check()) {
325							$('.dsgn-body').prepend(str);
326						} else {
327							$('.header.el-menu').last().after(str);
328						}
329						$('.header.el-menu').hide();
330						$('.el-footer').hide();
331						$.processON('', '#fff');
332					}
333
334					if(PAGE_MODE != 'c') {
335						var url = (PAGE_MODE=='s') ? '/' : '/render/';
336						(F_ONE) ? location.replace(url + '#' + F_PARENT.page) : location.replace(url + F_PARENT.page);
337					} else {
338						(F_ONE) ? location.replace('/'+CONFIG_URL+'config/page/index#' + F_PARENT.page) : location.replace('/'+CONFIG_URL+'config/page/' + F_PARENT.page);
339					}
340					
341					fv_deferred.reject('has error 2');
342					return false;
343				}
344				if(typeof data.fonts != 'undefined' && data.fonts && PAGE_MODE!='c') {
345					$.each(data.fonts, function(i,v) {
346						if(property.ELFONTS.indexOf(i) < 0) {
347							property.ELFONTS.push(i);
348							$('#loadfonts').append(v);
349						}
350					});
351				}
352
353				if(typeof data.webfonts != 'undefined' && data.webfonts && PAGE_MODE!='c') {
354					$.each(data.webfonts, function(i2,v2) {
355						if(property.ELFONTS.indexOf(i2) < 0 && v2) {
356							property.ELFONTS.push(i2);
357							WebFont.load({ google : { families : [ v2 ], display:'swap' }});
358						}
359					})
360				}
361
362				// QnA Block:: notice view page, comment_display: off
363				if(data.fm_type == 'qna' && data.option == 'N') $('.page-comments').hide();
364
365				var settings = (typeof data.fm_settings == 'undefined') ? {} : data.fm_settings,
366					p_settings = (typeof F_PARENT.settings == 'undefined' || F_PARENT.settings == '') ? {} : JSON.parse(F_PARENT.settings),
367					comment_display = (typeof settings.comment_display == 'undefined') ? ((data.check_comment)? 'ON' : 'OFF') : settings.comment_display,
368					wrap = (typeof settings.wrap == 'undefined') ? '' : 'w' + settings.wrap,
369					align = (typeof settings.align == 'undefined') ? 'left' : settings.align,
370					category = (typeof data.category_seq == 'undefined') ? '' : '<div class="tpl-forum-category" data-cate="' + data.category_seq + '">' + data.category_name + '</div>',
371					forum_validplan = (typeof VALIDPLAN == 'undefined') ? property.VALIDPLAN : VALIDPLAN;
372				// Category Display none case
373				// if(category && typeof p_settings.field_disable != 'undefined') {
374				// 	if($.inArray('category',p_settings.field_disable) > -1)  category = '';
375				// }
376				if(comment_display == 'OFF') $('.page-comments').remove();
377
378				files = data.files;		
379				p_settings.forum_email = ((typeof forum_validplan == 'undefined') || (!forum_validplan)) ? 
380										((typeof p_settings.forum_email == 'undefined') || (!p_settings.forum_email) ? p_settings.forum_email : p_settings.forum_email.split(',')[0]
381										) : p_settings.forum_email;
382
383				var siteSettings = (PAGE_MODE == 'c') ? SETTINGS : property.SETTINGS,
384					f_parallax = (typeof p_settings.parallax == 'undefined') ? false : p_settings.parallax,
385				 	f_type = (typeof p_settings.forum_type == 'undefined') ? '' : 'data-forum-type="' + p_settings.forum_type + '"',
386					forum_email = ((typeof p_settings.forum_email == 'undefined') || (p_settings.email_display == 'OFF')) ? '' : p_settings.forum_email,
387					forum_content = ($('<div>'+data.content+'</div>').find('img[src^="http://"]').length > 0) ? data.content.replace(/src\=\"http\:\/\//gi,'src\=\"\/\/') : data.content;
388				var f_lang = (typeof p_settings.chlang == 'undefined')? LANG : p_settings.chlang;
389				var del_display = (typeof p_settings.del_display == 'undefined' || PAGE_MODE == 'c')? 'ON' : p_settings.del_display,
390					f_b_title = (typeof p_settings.forum_block_title == 'undefined') ? '' : p_settings.forum_block_title;
391				data.f_lang = (f_lang)? f_lang : LANG;
392
393				var format_time = (data.reserved_format == '') ? data.date : data.reserved_format;
394
395				var fm_fonts = (typeof settings.fonts == 'undefined' || settings.fonts === null) ? {} : settings.fonts;
396				// fm_fonts = JSON.parse(fm_fonts);
397				var inline_style = '';
398
399				if(typeof fm_fonts.fontFamily != 'undefined') inline_style += ` font-family:${fm_fonts.fontFamily}; `;
400				if(typeof fm_fonts.fontSize != 'undefined') inline_style += ` font-size:${fm_fonts.fontSize}; `;
401				if(typeof fm_fonts.color != 'undefined') inline_style += ` color:${fm_fonts.color}; `;
402
403				var modoo_str = `
404					<div class="forum-view ${wrap}"  ${f_type} data-parallax="${f_parallax}">
405					<input type="hidden" id="fm-id" value="${data.id}">
406					<input type="hidden" id="fm-pid" value="${data.pid}">
407					<input type="hidden" id="forum-email" value="${forum_email}">
408					<div class="container">
409						<div class="forum-write ${wrap}">
410							<div class="row">
411								<div class="col-md-12 col-sm-12 col-xs-12">
412									<div class="tpl-forum-view-header">
413										<div class="forum-block-title">${f_b_title}</div>
414										<div class="user-ctrl">
415											${((del_display == 'OFF')? '' : postDropMenu(data))}
416										</div>
417									</div>
418									<div class="tpl-forum-view-info">
419										<div class="tpl-forum-title">${data.title}</div>
420										<div class="tpl-forum-info-detail">
421											<div class="tpl-forum-name">${data.name}</div>
422											<div class="tpl-forum-date date">${format_time}</div>
423											<div class="tpl-forum-hit hit">
424												<svg viewBox="0 0 14 12" width="14" height="12"><circle cx="7" cy="6" r="2"/><path d="M7 2C3.97 2 1.34 3.62 0 6c1.34 2.38 3.97 4 7 4s5.66-1.62 7-4C12.66 3.62 10.03 2 7 2zM7 9C5.34 9 4 7.66 4 6s1.34-3 3-3 3 1.34 3 3S8.66 9 7 9z"/></svg>
425												${data.hit}
426											</div>
427										</div>
428									</div>
429									<div class="tpl-forum-content fm-body fm-content fm-editor fr-box ${align}">
430										<div class="fr-wrapper" dir="auto">
431											<div class="fr-element fr-view" dir="auto" style="${inline_style}">${forum_content}</div>
432										</div>
433									</div>
434									<div class="tpl-forum-list-footer">
435										<div class="tpl-forum-control-wrap">
436											<button type="button" class="btn btn-default btn-list tpl-forum-list">${$.lang[f_lang]['board.button.list']}</button>
437											<div class="tpl-forum-modoo-prev-next tpl-forum-pn-row">
438											`;
439											if (typeof data.prev != 'undefined' && Object.keys(data.next).length > 0) {
440											modoo_str += `
441												<a href="${data.next.url}" data-option="${data.next.option}" data-id="${data.next.seq}">
442													<button type="button" class="btn btn-default">이전글</button>
443												</a>
444											`;
445											}
446											if (typeof data.prev != 'undefined' && Object.keys(data.prev).length > 0) {
447											modoo_str += `
448												<a href="${data.prev.url}" data-option="${data.prev.option}" data-id="${data.prev.seq}">
449													<button type="button" class="btn btn-default">다음글</button>
450												</a>
451											`;
452											}
453					modoo_str += `			</div>
454										</div>`;
455					modoo_str += `		<div class="tpl-forum-modoo-reply">
456												${replyPostbutton(data)}
457										</div>
458									</div><!--.tpl-forum-list-footer-->
459				`;
460
461				var str = '\
462				<div class="forum-view ' + wrap + '" ' + f_type + ' data-parallax="'+f_parallax+'">\
463					<input type="hidden" id="fm-id" value="' + data.id + '">\
464					<input type="hidden" id="fm-pid" value="' + data.pid + '">\
465					<input type="hidden" id="forum-email" value="' + forum_email + '">\
466					<div class="container">\
467						<div class="forum-write ' + wrap + '">\
468							<div class="row">\
469								<div class="col-md-12 col-sm-12 col-xs-12">\
470									<ul class="forum-user-info clearfix">\
471										<li class="user-image tpl-forum-myimage forum-image">\
472											<img src="' + data.myimg + '?_' + new Date().getTime() + '" />\
473										</li>\
474										<li class="user-info">\
475											<div class="tpl-forum-name">' + data.name + '</div>\
476											<div class="tpl-forum-date date">' + format_time + '</div>\
477											<div class="tpl-forum-hit hit">\
478												<svg viewBox="0 0 14 12" width="14" height="12"><circle cx="7" cy="6" r="2"/><path d="M7 2C3.97 2 1.34 3.62 0 6c1.34 2.38 3.97 4 7 4s5.66-1.62 7-4C12.66 3.62 10.03 2 7 2zM7 9C5.34 9 4 7.66 4 6s1.34-3 3-3 3 1.34 3 3S8.66 9 7 9z"/></svg>\
479												' + data.hit + '\
480											</div>\
481										</li>\
482										<li class="user-ctrl">\
483											' + ((del_display == 'OFF')? '' : postDropMenu(data)) + '\
484										</li>\
485									</ul>\
486									' + category + '\
487									<div class="tpl-forum-title">' + data.title + '</div>\
488									<div class="tpl-forum-content fm-body fm-content fm-editor fr-box ' + align + '">\
489										<div class="fr-wrapper" dir="auto">\
490											<div class="fr-element fr-view" dir="auto" style="' + inline_style + '">' + forum_content + '</div>\
491										</div>\
492									</div>\
493									<div class="tpl-forum-list-footer">\
494										<div class="tpl-forum-control-wrap">';
495									if(data.fm_type == 'qna') {
496										if(data.answer !== undefined && data.replied == true) {
497											str += '\
498											<button type="button" class="btn tpl-forum-list">&nbsp;' + $.lang[LANG]['board.button.list'] + '</button>';
499										} else {
500											str += '\
501											<button type="button" class="btn tpl-forum-list">&nbsp;' + $.lang[LANG]['board.button.list'] + '</button>\
502											' + replyPostbutton(data);
503										}	
504									} else {
505										str += '\
506											<button type="button" class="btn tpl-forum-list">&nbsp;' + $.lang[f_lang]['board.button.list'] + '</button>\
507											' + replyPostbutton(data);
508									}
509									str += '\
510										</div>\
511									</div><!--.tpl-forum-list-footer-->\
512									';
513
514								if(p_settings.forum_type == 'modoo') str = modoo_str;
515
516								if (p_settings.prevnext_display !== undefined && p_settings.prevnext_display == 'ON' && !['qna', 'faq', 'guestbook'].includes(data.fm_type)) {
517									var hidden = (Object.keys(data.prev).length == 0 && Object.keys(data.next).length == 0) ? ' hidden' : '';
518									var icon = '';
519									var title_href = '';
520									str += `
521									<div class="tpl-forum-list-prev-next${hidden}">
522									`;
523
524									if (Object.keys(data.next).length > 0) {
525										if (data.next.option == 'N') icon = '<i class="cl-icon notice01" aria-hidden="true"></i>';
526										if (data.next.option == 'S') icon = '<i class="cl-icon lock02" aria-hidden="true"></i>';
527										if (data.next.title == '') {
528										    title_href = `<a href="javascript:;" class="deleted" data-option="${data.next.option}" data-id="${data.next.seq}">${$.lang[LANG]['board.post.deleted']}</a>`;
529										} else {
530										    title_href = `<a href="${data.next.url}" data-option="${data.next.option}" data-id="${data.next.seq}">${data.next.title}</a>`;
531										}
532										str += `
533									    <div class="tpl-forum-pn-row forum-next display-flex space-between align-items-center">
534									    	<div class="tpl-forum-pn-num">${$.lang[LANG]['board.next']}</div>
535									    	<div class="tpl-forum-pn-title">${icon}${title_href}</div>
536									    	<div class="tpl-forum-pn-date">${data.next.date}</div>
537									    </div>
538										`;
539									}
540
541									icon = '';
542									if (Object.keys(data.prev).length > 0) {
543										if (data.prev.option == 'N') icon = '<i class="cl-icon notice01" aria-hidden="true"></i>';
544										if (data.prev.option == 'S') icon = '<i class="cl-icon lock02" aria-hidden="true"></i>';
545										if (data.prev.title == '') {
546										    title_href = `<a href="javascript:;" class="deleted" data-option="${data.prev.option}" data-id="${data.prev.seq}">${$.lang[LANG]['board.post.deleted']}</a>`;
547										} else {
548										    title_href = `<a href="${data.prev.url}" data-option="${data.prev.option}" data-id="${data.prev.seq}">${data.prev.title}</a>`;
549										}
550										str += `
551									    <div class="tpl-forum-pn-row forum-prev display-flex space-between align-items-center">
552									    	<div class="tpl-forum-pn-num">${$.lang[LANG]['board.prev']}</div>
553									    	<div class="tpl-forum-pn-title">${icon}${title_href}</div>
554									    	<div class="tpl-forum-pn-date">${data.prev.date}</div>
555									    </div>
556										`;
557									}
558
559									str += `
560									</div><!--tpl-forum-list-prev-next-->
561									`;
562								}
563								str += '\
564								</div>\
565							</div>\
566						</div>\
567					</div><!--container-->\
568				';
569				if(data.mgr && data.fm_type != 'faq') {
570					str += '\
571					<div class="tpl-forum-comment_display container clear ' + wrap + ((comment_display == 'ON')? ' off':' on') + '" data-id="' + data.id + '" data-pid="' + data.pid + '">\
572						<div class="display-flex align-items-center">\
573							<div class="newcheckbox hand ">\
574			                    <label>\
575			                        <div class="newcheckboxSvg">\
576			                            <input type="checkbox" class="comment-onoff" '+((comment_display == 'ON')? '':'checked')+'/>\
577			                            <svg viewBox="0 0 16 16" width="16" height="16">\
578			                                <path class="st6" d="M3 0h10c1.66 0 3 1.34 3 3v10c0 1.66-1.34 3-3 3H3c-1.66 0-3-1.34-3-3V3C0 1.34 1.34 0 3 0z"/>\
579			                                <path class="st19" d="M13 1c1.1 0 2 0.9 2 2v10c0 1.1-0.9 2-2 2H3c-1.1 0-2-0.9-2-2V3c0-1.1 0.9-2 2-2H13M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0L13 0z"/>\
580			                            </svg>\
581			                            <svg class="active" viewBox="0 0 16 16" width="16" height="16">\
582			                                <rect x="2" y="2" class="st6" width="12" height="12"/>\
583			                                <path  class="st19" d="M13 0H3C1.34 0 0 1.34 0 3v10c0 1.66 1.34 3 3 3h10c1.66 0 3-1.34 3-3V3C16 1.34 14.66 0 13 0zM13.03 6.03l-5.5 5.5C7.38 11.68 7.19 11.75 7 11.75s-0.38-0.07-0.53-0.22l-3.5-3.5c-0.29-0.29-0.29-0.77 0-1.06s0.77-0.29 1.06 0L7 9.94l4.97-4.97c0.29-0.29 0.77-0.29 1.06 0S13.32 5.74 13.03 6.03z"/>\
584			                            </svg>\
585			                        </div>\
586			                        <span class="tpl-forum-comment_display-label">'+ $.lang[LANG]['config.comment.title'] +'</span>\
587			                    </label>\
588			                </div>\
589						</div>\
590					</div>\
591					';
592				}
593				str += '\
594				</div>\
595				';
596
597				if($.clnav.check()) {
598					$('.dsgn-body').prepend(str);
599				} else {
600					$('.header.el-menu').last().after(str);
601				}
602				changeBrokenImages($('.fr-view'));
603
604				if(($('.fr-view').find('img[name^="target_resize_image[]"]').length > 0)) {
605					$.each($('.fr-view').find('p'),function(){
606						$(this).find('img[name^="target_resize_image[]"]').removeAttr('width')
607																		.removeAttr('height');
608					});
609				}
610
611				// 주소 변경 복원
612				$.each($('.fr-view').find('iframe'), function(idx,value) {
613					var src = $(this).attr('src');
614					if(src.indexOf('http://') > -1 && src.indexOf('youtube.com') > -1) {
615						src = src.replace('http://','//');
616						$(this).attr('src',src);
617					}
618				});
619
620				if(p_settings.field_disable) {
621					$.each(p_settings.field_disable, function(i,v) {
622						var tmp_v = (v == 'myimg') ? 'myimage' : v;
623						$('.forum-write .row > div .tpl-forum-'+tmp_v).addClass('hidden');
624					});
625				}
626
627				// if($('.user-info > div.hidden').length > 0) $('.user-info > div').removeClass('mt-8').addClass('mt-8');
628				if($('.tpl-forum-date').next('div').hasClass('hidden')) $('.tpl-forum-date').addClass('afterHide');
629
630				initViewPageToolbar(data.option, p_settings, data).then(function(){
631					if(PAGE_MODE == 'c') setViewPageToolbar();
632				});
633				
634				$.cookie('prev-forum-view',F_PAGE, { path: '/' });
635				fv_deferred.resolve(data);
636				// $.removeCookie('hash', { path: '/' });
637			}
638		},'json');
639
640		return fv_deferred.promise();
641	}
642
643	var replyPostbutton = function(data) {
644		if(data.is_reserved == 'Y') return '';
645		var str = '\
646					<button type="button" class="btn tpl-forum-write" data-pid="' + data.pid + '" data-reply="' + data.id + '">\
647						&nbsp;' + $.lang[data.f_lang]['board.button.reply'] + '\
648					</button>\
649		';
650
651		var reply_hidden_case = ['faq'],
652			reply_hidden =  (reply_hidden_case.indexOf(data.fm_type) > -1) ? true : false;
653
654		return (data.reply && data.option != 'N' && !reply_hidden) ? str : '';
655	}
656
657	var postDropMenu = function(data) {
658		var drop = false;
659		var str_li = '';
660		
661		if((data.own || (data.sign == false && data.fmid == false)) && data.writeable == true || data.mgr_edit) {
662			drop = true;
663			str_li += '\
664				<li><a href="#" class="tpl-forum-write" data-id="' + data.id + '" data-pid="' + data.pid + '">' + $.lang[data.f_lang]['board.button.modify'] + '</a></li>\
665			';
666		}
667		// console.log('data', data);
668		if(data.own || (data.sign == false && data.fmid == false) || data.mgr) {
669			drop = true;
670			str_li += '\
671				<li><a href="#" class="tpl-forum-delete" data-id="' + data.id + '" data-pid="' + data.pid + '">' + $.lang[data.f_lang]['board.button.delete'] + '</a></li>\
672			';
673		}
674
675		var str = '\
676		<ul class="tpl-forum-edit-menu">\
677			' + str_li + '\
678		</ul>\
679		';
680		return str;
681	}
682
683
684	var signForm = function(id,pid,access,token) {
685		var mode = (access=='NM') ? 'nonmem' : 'default',
686			F_VALIDPLAN = (typeof VALIDPLAN == 'undefined') ? property.VALIDPLAN : VALIDPLAN,
687			F_VALIDTYPE = (typeof VALIDTYPE == 'undefined') ? property.VALIDTYPE : VALIDTYPE,
688			F_SITEUM = (typeof SITEUM == 'undefined') ? property.SITEUM : SITEUM,
689			F_SERVICE = (typeof SERVICE == 'undefined') ? property.SERVICE : SERVICE,
690			isGabia = (F_SERVICE.indexOf('gabia') > -1) ? true : false,
691			host_url = (isGabia) ? 'http://creatorlink-gabia.com' : 'http://creatorlink.net',
692			classSet = {
693				'default': ['default-mode','active', '', '', '', ''],
694				'sitemember': ['sitemember-mode', '', 'active', '', '', 'hidden'],
695				'nonmem' : ['nonmember-mode', '', '', 'active', '.nonmem', 'hidden'],
696			},
697			joinUrl = (LANG != 'ko') ? '//creatorlink.net/en/member/join' : '//creatorlink.net/member/join' ;
698
699		var signForm_str_nonmember = '',
700			signForm_str_defult  = '';
701
702		if(F_VALIDTYPE != 'SM' && (F_VALIDTYPE != 'BN' && F_SITEUM > -1)) F_SITEUM = -1;
703
704		if((F_VALIDTYPE == 'SM' || (F_VALIDTYPE == 'BN' && F_SITEUM > 0)) && access != 'NM') {
705			mode = 'sitemember';
706		}
707
708
709		if(isGabia) {
710			if(access == 'ADM') {
711				mode = 'sitemember';
712			} else if(access == 'NM') {
713				//
714			} else {
715				if((F_VALIDTYPE != 'BN' && F_VALIDTYPE != 'SM') || (F_VALIDTYPE == 'BN' && F_SITEUM < 1)) {
716					mode = 'nonmem';
717					access = 'NM';
718				}
719			}
720		}
721
722		if (access=='NM') {
723			signForm_str_nonmember = '' + 
724			'<ul class="comment-signForm nav ' + classSet[mode][0] + '" role="tablist">';
725
726				if(isGabia || (!isGabia && F_SITEUM > 0)) {
727					signForm_str_nonmember += '' + 
728					'<li class="signType ' + classSet[mode][2] + '" role="presentation"><a href="#sitemember" aria-controls="sitemember" role="tab" data-toggle="tab">' + $.lang[LANG]['config.creatorlink.text-adm'] + '</a></li>';
729					
730				} else {
731					signForm_str_nonmember += '' +
732					'<li class="signType ' + classSet[mode][1] + '" role="presentation"><a href="#creatorlink" aria-controls="creatorlink" role="tab" data-toggle="tab">' + $.lang[LANG]['config.creatorlink.text-adm'] + '</a></li>';
733				}
734				signForm_str_nonmember += '' + 
735				'<li class="signType ' + classSet[mode][3] + '" role="presentation"><a href="#anonymous" aria-controls="anonymous" role="tab" data-toggle="tab">' +  $.lang[LANG]['config.anonymous'] + '<svg viewBox=\"0 0 6 8\" width=\"6\" height=\"8\"><polygon points=\"2 0 0 0 4 4 0 8 2 8 6 4 \"/></svg></a></li>' +
736			'</ul>';
737		} else {
738			signForm_str_defult = '' + 
739				'<ul class="comment-signForm nav ' + classSet[mode][0] + '" role="tablist">';
740			if(mode == 'sitemember') {
741				signForm_str_defult += '' + 
742				'<li class="signType ' + classSet[mode][2] + '" role="presentation"><a href="#sitemember" aria-controls="sitemember" role="tab" data-toggle="tab">' + $.lang[LANG]['siteum.login.member'] + '</a></li>';
743			} else {
744				var tab_str = (isGabia) ? $.lang[LANG]['siteum.login.member'] : $.lang[LANG]['config.creatorlink'];
745				if((F_VALIDTYPE == 'BN' || F_VALIDTYPE == 'SM') && access == 'ADM' ) {
746					tab_str = '<br>' + $.lang[LANG]['config.creatorlink.text-adm2'];
747					classSet[mode][5] = 'hidden';
748				}
749				signForm_str_defult += '' + 
750					'<li class="signType ' + classSet[mode][1] + '" role="presentation"><a href="#creatorlink" aria-controls="creatorlink" role="tab" data-toggle="tab">' + tab_str + '</a></li>';
751			}
752			if(access=='A') {
753				var icon_str = (mode == 'sitemember') ? '' : '<img src="//storage.googleapis.com/i.addblock.net/icon/icon-sign-anonymous.png"><br><br>';
754				signForm_str_defult += '' + 
755				'<li class="signType ' + classSet[mode][3] + '" role="presentation"><a href="#anonymous" aria-controls="anonymous" role="tab" data-toggle="tab">' +  $.lang[LANG]['config.anonymous'] + '</a></li>';
756			}
757			signForm_str_defult += '' + 
758			'</ul>';
759		}
760
761
762
763
764		var str = signForm_str_defult +  signForm_str_nonmember +
765			'<div class="tab-content">' +
766				'<div role="tabpanel" class="tab-pane ' + classSet[mode][1] + '" id="creatorlink">' +
767			        '<div class="form-inline comment-addform input-text">' +
768			        	'<div class="cl-s-form-wrap">' +
769							'<div class="cl-s-form-group">' +
770								'<input type="text" class="cl-s-form-control" id="mb_forum_id" name="mb_id" required="required" value="">' +
771								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['config.modal.emailaddress'] + '</label>' +
772							'</div>' +
773						'</div>' +
774			        	'<div class="cl-s-form-wrap mt-10">' +
775							'<div class="cl-s-form-group">' +
776								'<input type="password" class="cl-s-form-control" id="mb_forum_password" name="mb_password" required="required" value="">' +
777								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['config.modal.password'] + '</label>' +
778							'</div>' +
779						'</div>' +
780			        '</div>' +
781			        '<div class="bottom-box text-right ' + LANG + ' ' + classSet[mode][5] + '">' +
782						'<span>' +  $.lang[LANG]['page.member.login-modal.jointext'] + '</span>&nbsp;&nbsp;&nbsp;<a href="' + joinUrl + '" target="_blank"><b>' +  $.lang[LANG]['page.member.login-modal.join2'] + '<svg viewBox=\"0 0 6 8\" width=\"6\" height=\"8\"><polygon points=\"2 0 0 0 4 4 0 8 2 8 6 4 \"/></svg></b></a>' +
783					'</div>' +
784			        '<div class="btn-wrap comment-addform mt-30">' +
785			        	'<a href="#" class="btn btn-primary btn-lg btn-block forum-login" data-id="' + id + '" data-pid="' + pid + '">' +  $.lang[LANG]['config.modal.login'] + '</a>' +
786			        	'<button type="button" class="btn-modal-cancel" data-dismiss="modal">' +  $.lang[LANG]['config.cancel'] + '</button>' +
787			        '</div>' +
788				'</div>' +
789				'<div role="tabpanel" class="tab-pane ' + classSet[mode][2] + '" id="sitemember">' +
790			        '<div class="form-inline comment-addform input-text">' +
791			        	'<div class="cl-s-form-wrap">' +
792							'<div class="cl-s-form-group">' +
793								'<input type="text" class="cl-s-form-control" id="um_forum_id" name="um_id" required="required" value="">' +
794								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['siteum.login.id'] + '</label>' +
795							'</div>' +
796						'</div>' +
797			        	'<div class="cl-s-form-wrap mt-10">' +
798							'<div class="cl-s-form-group">' +
799								'<input type="password" class="cl-s-form-control" id="um_forum_password" name="um_password" required="required" value="">' +
800								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['siteum.login.password'] + '</label>' +
801							'</div>' +
802						'</div>' +
803			        '</div>' +
804			        '<div class="bottom-box text-right ' + LANG + ' ' + classSet[mode][5] + '">' +
805						'<span>' +  $.lang[LANG]['page.member.login-modal.jointext'] + '</span>&nbsp;&nbsp;&nbsp;<a href="' + joinUrl + '" target="_blank"><b>' +  $.lang[LANG]['page.member.login-modal.join2'] + '<svg viewBox=\"0 0 6 8\" width=\"6\" height=\"8\"><polygon points=\"2 0 0 0 4 4 0 8 2 8 6 4 \"/></svg></b></a>' +
806					'</div>' +
807			        '<div class="btn-wrap comment-addform mt-30">' +
808			        	'<a href="#" class="btn btn-primary btn-lg btn-block forum-login" data-id="' + id + '" data-pid="' + pid + '">' +  $.lang[LANG]['config.modal.login'] + '</a>' +
809			        	'<button type="button" class="btn-modal-cancel" data-dismiss="modal">' +  $.lang[LANG]['config.cancel'] + '</button>' +
810			        '</div>' +
811					'<br>' +
812				'</div>' +
813				'<div role="tabpanel" class="tab-pane ' + classSet[mode][3] + '" id="anonymous">' +
814					'<div class="form-inline comment-addform input-text">' +
815			        	'<div class="cl-s-form-wrap">' +
816							'<div class="cl-s-form-group">' +
817								'<input type="text" class="cl-s-form-control" id="comm-name" required="required" value="">' +
818								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['config.modal.name'+classSet[mode][4]] + '</label>' +
819							'</div>' +
820						'</div>' +
821			        	'<div class="cl-s-form-wrap mt-10">' +
822							'<div class="cl-s-form-group">' +
823								'<input type="password" class="cl-s-form-control" id="comm-pass" required="required" value="">' +
824								'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['config.modal.password'+classSet[mode][4]] + '</label>' +
825							'</div>' +
826						'</div>' +
827					'</div>' +
828					'<div class="kcaptcha-box comment-addform input-text mt-30">' +
829						'<div class="col-xs-12 col-sm-5 col-md-5 no-padding text-left kcaptcha-img">' +
830							'<p id="write_option">' +
831								'<img src="" id="kcaptcha" alt="' +  $.lang[LANG]['config.captcha-alt'] + '"/>' +
832							'</p>' +
833						'</div>' +
834						'<div class="col-xs-12 col-sm-7 col-md-7 no-padding text-left kcaptcha-text">' +
835							'<input type="text" id="wr_key" name="wr_key" class="col-sm-12 form-control" placeholder="' +  $.lang[LANG]['config.enter-captcha'] + '"/>' +
836							'<a class="kcaptcha-change hand"><svg viewBox="0 0 24 24" width="24" height="24">
836<path d="M12 5c-3.64 0-6.63 2.78-6.97 6.33L3.35 9.65l-0.71 0.71 2.85 2.85 2.85-2.85L7.65 9.65l-1.59 1.59C6.43 8.29 8.95 6 12 6c3.31 0 6 2.69 6 6s-2.69 6-6 6c-1.66 0-3.17-0.68-4.26-1.78l-0.71 0.71C8.3 18.21 10.06 19 12 19c3.87 0 7-3.13 7-7S15.87 5 12 5z"/></svg><span>' +  $.lang[LANG]['config.change-captcha'] + '</span></a>' +
837						'</div>' +
838					'</div>' +
839				'</div>' +
840			'</div>';
841
842
843		return str;
844	}
845	var forumWrite = function(id,pid,reply) {
846		reply = (typeof reply == 'undefined') ? '' : reply;
847	}
848
849
850	$(document).on('click','.tb-attach-file',function(e) {
851		// $('#forum-attach').modal('show');
852      	isReplace = false;
853		upTYPE = 'image';
854		$('#file_type').val(upTYPE);
855	    $('#file_multiple').val(false);
856		$('#uploadFile').val('').removeAttr('multiple').attr('accept','image/gif,image/jpg,image/jpeg,image/png,image/ico');
857		$('#uploadFile').trigger('click');
858		// $('.modal-backdrop').last().removeClass('fade');
859	});
860	$(document).on('click','.tb-file-insert', function(e) {
861		// $('#forum-attach').modal('show');
862		upTYPE = 'file';
863		$('#file_type').val(upTYPE);
864	    $('#file_multiple').val(false);
865		$('#uploadFile').val('').removeAttr('multiple').removeAttr('accept');
866		$('#uploadFile').trigger('click');
867		// $('.modal-backdrop').last().removeClass('fade');
868	});
869	$(document).on('click','.tb-video-insert', function(e) {
870		$('#fm-editor').froalaEditor('selection.save');
871		var modal = $(this).showModalFlat('INSERT VIDEO',videoForm(),true,true,function() {
872			$('.error').remove();
873			var url = $('#video-url').val();
874			if(!url) {
875				$('#video-url').after('<label class="error">' +  $.lang[LANG]['config.link-to-go'] + '</label>').focus();
876				return;
877			}
878			var video = insertVideo(url,'src'),
879				frVideo = '<span class="fr-video fr-dvb fr-draggable" contenteditable="false" draggable="true">' +
880						'<iframe width="720" height="405" src="' + video + '" frameborder="0" allowfullscreen="true"></iframe>' +
881						'</span>';
882
883			$('#fm-editor').froalaEditor('selection.restore');
884			$('#fm-editor').froalaEditor('html.insert', frVideo , true);
885			modal.modal('hide');
886
887		},'cancel','','w480 video-modal');
888		$('.flat-modal').css({
889			'position' : 'absolute',
890			'z-index' : '1051'
891		});
892		$('.flat-modal').next().css('z-index','1050');
893	});
894
895	$doc.on('click','#insert-forum-attach', function(e) {
896		var file = $('#uploadFile').val();
897		if(file=='') {
898			alert('파일을 입력/선택하세요');
899			$.processOFF();
900			return false;
901		}
902		$('#forum-attach').modal('hide');
903	});
904	
905	$doc.on('click','#fm-secret', function(e) {
906		$target = $(this).find('.fa');
907		if($target.hasClass('fa-square-o')) {
908			$target.removeClass('fa-square-o').addClass('fa-check-square-o');
909			$(this).attr('data-secret','S');
910
911			$('#fm-notice').find('.fa').removeClass('fa-check-square-o').addClass('fa-square-o');
912			$('#fm-notice').attr('data-notice','');
913		} else {
914			$target.removeClass('fa-check-square-o').addClass('fa-square-o');
915			$(this).attr('data-secret','');
916		}
917	});
918
919	$doc.on('click','#fm-notice', function(e) {
920		$target = $(this).find('.fa');
921		if($target.hasClass('fa-square-o')) {
922			$target.removeClass('fa-square-o').addClass('fa-check-square-o');
923			$(this).attr('data-notice','N');
924
925			$('#fm-secret').find('.fa').removeClass('fa-check-square-o').addClass('fa-square-o');
926			$('#fm-secret').attr('data-secret','');
927		} else {
928			$target.removeClass('fa-check-square-o').addClass('fa-square-o');
929			$(this).attr('data-notice','');
930		}
931	});
932
933	$doc.on('click',`
934		.tpl-forum-list-arrow, .tpl-forum-list-toggle,
935		[data-ver="1"][data-type2="faq"] .tpl-forum-list-icon
936	`, function(e) {
937		$(this).closest('tr').find('.tpl-forum-list-title').click();
938	});
939
940	$doc.on('click','*[class*=tpl-forum-list-] a.deleted', function(e) {
941		e.preventDefault();
942		$(this).showModalFlat('', $.lang[LANG]['board.post.deleted'], true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title cl-close-btn');
943		return false;
944	});
945
946	$doc.on('click','.tpl-toolbar-question-del, .tpl-toolbar-answer-del', function(e) {
947		e.preventDefault();
948		var option = $(this).attr('data-option'),
949			id = $(this).attr('data-id'),
950			target_type = $(this).closest('.tpl-qna-toolbar').attr('data-list-option');
951
952		var question_del_modal = $(this).showModalFlat($.lang[LANG]['board.ask-permanent-delete.title'], $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
953				question_del_modal.modal('hide');
954				$.forum.delete(id);
955				if(target_type == 'a') {
956					location.reload();
957				}
958			}, 'cancel', $.lang[LANG]['config.delete'],'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-t80 cl-modal cl-none-title cl-close-btn');
959		// if(target_type == 'q') {
960		// 	var question_del_modal = $(this).showModalFlat('POST DELETE', $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
961		// 		question_del_modal.modal('hide');
962		// 		$.forum.delete(id);
963		// 	}, 'cancel');
964		// }
965		// else if(target_type == 'a') {
966		// 	$.comment.delete(id);
967		// }
968	});
969
970	$doc.on('click', '.tpl-forum-pn-row a', function(e){
971		e.preventDefault();
972		if ($(this).hasClass('deleted')) {
973		    return false;
974		}
975
976		var fmViewUrl = $(this).attr('href');
977		var option = $(this).attr('data-option');
978		var id = $(this).attr('data-id');
979
980		var url = forumUrl();
981		var href = url + fmViewUrl;
982		
983		if (option == 'S') {
984		    $.ajax({
985		        url: '/fm/access',
986		        type: 'POST',
987		        data: {id: id, sid: F_SID},
988		        dataType: 'json',
989		        success: function(data) {
990		            if (data.access == false) {
991		                if ((data.sign == false && data.fmid == true) || (data.sign == true && data.fmid == true) || (data.sign == true && data.fmid == false)) {
992		                    $(this).showModalFlat('INFORMATION', $.lang[LANG]['board.read-not-allowed'], true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title');
993		                } else {
994		                	$(this).showModalFlat($.lang[LANG]['board.secret-password'],passwdForm(),true,true,function() {
995								var $pass = $('#comm-pass'),
996									isSubmit = true,
997									userInput = $pass.val();
998								$('label.error').remove();
999								if($pass.val().length<4) {
1000									$pass.closest('.cl-s-form-wrap').addClass('error');
1001									$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
1002									$pass.focus();
1003									isSubmit = false;
1004								}
1005
1006								if(isSubmit) {
1007									$('.comment-addform.password').removeClass('error');
1008									$.ajax({
1009									    type: 'POST',
1010									    url: '/fm/password',
1011									    data: {
1012									        id: id,
1013									        passwd: hex_md5($pass.val())
1014									    },
1015									    dataType: 'json',
1016									    success: function(data) {
1017									        if(typeof data.error != 'undefined' && data.error) {
1018									            $pass.closest('.cl-s-form-wrap').addClass('error');
1019									            $pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+data.error+'</label>');
1020									            return false;
1021									        }
1022
1023									        var date = new Date(),
1024											cookietime = 20 * 60 * 1000;
1025								            date.setTime(date.getTime() + cookietime);
1026								            
1027											$.removeCookie('checkPostHighWriter',{path:'/'});
1028								            $.cookie('checkPostWriter', id, { path: '/' , expires: date});
1029											$.cookie('hash', data.hash, { path: '/' , expires: date});
1030											$('.modal[id*=flat-modal]').modal('hide');
1031											
1032									        if(typeof MODE == 'undefined') {
1033								                RENDER.history.pushState(null, property.TITLE, href);
1034								            } else {
1035								                location.href = href;
1036								            }
1037									    },
1038									    error: function(xhr, textStatus, errorThrown) {
1039									        console.log('Error: ' + errorThrown);
1040									    }
1041									});
1042
1043								}
1044								modalEmptyCheck();
1045							},'cancel','','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', false, '', function() {
1046								$('.board-password .board-secret-info').remove();
1047								$('.comment-addform.password').before('<div class="board-secret-info">' + $.lang[LANG]['board.writer.password.title'] + '</div>');
1048            				});
1049		                }
1050		            } else {
1051		                if (typeof MODE == 'undefined') {
1052		                    RENDER.history.pushState(null, property.TITLE, href);
1053		                } else {
1054		                    location.href = href;
1055		                }
1056		            }
1057		            return false;
1058		        }
1059		    });
1060		} else {
1061		    if (typeof MODE == 'undefined') {
1062		        RENDER.history.pushState(null, property.TITLE, href);
1063		    } else {
1064		        location.href = href;
1065		    }
1066		}
1067		
1068		return false;
1069	});
1070	
1071	$doc.off('click','.tpl-forum-list-title, .tpl-forum-list-cont, .tpl-forum-list-thumb, .tpl-forum-list-more, .tpl-toolbar-question-answer, .tpl-forum-list-content');
1072	$doc.on('click','.tpl-forum-list-title, .tpl-forum-list-cont, .tpl-forum-list-thumb, .tpl-forum-list-more, .tpl-toolbar-question-answer, .tpl-forum-list-content', function(e) {
1073
1074		var click_this = $(this),
1075			click_tr = ($(this).closest('tr').length > 0) ? $(this).closest('tr') : $(this).closest('.item'),
1076			option = $(this).attr('data-option'),
1077			id = $(this).attr('data-id'),
1078			forum_el = $(this).closest('.element'),
1079			type = $(forum_el).attr('data-forum-type'),
1080			pid = $(forum_el).attr('data-id'),
1081			page_num = $(forum_el).find('.tpl-forum-page.active').attr('data-page-num'),
1082			stx = getForumPrevStx(pid),
1083			sfl = ($(forum_el).find('#sfl').length > 0) ? $(forum_el).find('#sfl').val() : '',
1084			scate = ($(forum_el).find('#scate').length > 0) ? $(forum_el).find('#scate').val() : '';
1085		
1086		var checkOldVerForum = (forum_el.is('[data-ver="1"]')) ? true : false;
1087
1088		if($.inArray(type, ['faq','guestbook']) > -1
1089			|| click_this.find('.tpl-forum-list-title').length > 0
1090			|| (type=='qna' && !click_this.is('.tpl-forum-list-title'))
1091			|| ($(e.target).hasClass('tpl-forum-list-title') && $(e.target).find('a.deleted').length)
1092		) {
1093			if($.inArray(type, ['faq', 'qna']) > -1 && click_this.is('.tpl-forum-list-cont:has(a[rel])')) return true;
1094			else return false;
1095		}
1096
1097		if($(e.target).hasClass('tpl-forum-list-reply-name') ){
1098			var del_chk = $(e.target).next();
1099			if(del_chk.is('a.deleted')) {
1100				$(e.target).next().click();
1101				return false;
1102			}
1103		}
1104
1105		e.preventDefault();
1106
1107		if($(forum_el).find('input[name="user_stx"]').length > 0 && $(forum_el).find('input[name="user_sfl"]').length > 0) {
1108			stx = $(forum_el).find('input[name="user_stx"]').val();
1109			sfl = $(forum_el).find('input[name="user_sfl"]').val();
1110		}
1111		
1112		if($(this).closest('#element-display').length > 0) return false;
1113		if($(this).closest('[data-loop="true"]').hasClass('sample-loop')) return false;
1114		if($(this).closest('tr.active').length > 0 && $(this).closest('.element.page-bottomlist').length > 0) return false;
1115		
1116		F_SID = (typeof SID == 'undefined') ? property.SID : SID;
1117
1118		var checkQnAForum = (type=='qna' && !$(this).hasClass('tpl-qna-toolbar-button')) ? true : false,
1119			click_el = $(this).closest('.item');
1120
1121		if(checkOldVerForum) click_el = (checkQnAForum) ? $(this).closest('.qna-item') : $(this);
1122
1123		if(option=='S') {
1124			e.preventDefault();
1125			var checkhigh_onoff = (typeof click_tr.attr('data-checkhigh') != 'undefined' && click_tr.attr('data-checkhigh')) ? true : false,
1126				checkhigh_mode = (checkhigh_onoff) ? click_tr.attr('data-checkhigh') : '';
1127
1128			$.post('/fm/access',{id:id, sid : F_SID}, function(data) {
1129				if(data.access == false) {
1130					if(((data.sign == false && data.fmid == true) || (data.sign == true && data.fmid == true) || (data.sign == true && data.fmid == false)) && !checkhigh_onoff) {
1131						
1132						if(data.sign == false && data.checkhigh != '') {
1133							var checkhigh_v = (data.checkhigh == 'onlyparent') ? 'parent' : data.checkhigh,
1134								checkhigh_str = '<span class="btn-fm-change-checkhigh" data-checkhigh="'+checkhigh_v+'">' + $.lang[LANG]['board.goto-checkhigh.'+checkhigh_v] + '</span>';
1135							if(data.checkhigh == 'parent') checkhigh_str += '<span class="btn-fm-change-checkhigh" data-checkhigh="reply">' + $.lang[LANG]['board.goto-checkhigh.reply'] + '</span>';
1136
1137							var fmAcc_str = $.lang[LANG]['board.read-not-allowed'] + '<div class="clearfix"></div><div class="wrap-fm-change-checkhigh">' + checkhigh_str + '</div>';
1138							var fmAccModal = $(this).showModalFlat('INFORMATION',fmAcc_str,true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title','','',function() {
1139								fmAccModal.find('.btn-fm-change-checkhigh').on('click', function() {
1140									var tmp_v = $(this).attr('data-checkhigh');
1141									click_tr.attr('data-checkhigh',tmp_v);
1142									click_this.click();
1143									fmAccModal.modal('hide');
1144								});
1145							});
1146						} else {
1147							$(this).showModalFlat('INFORMATION',$.lang[LANG]['board.read-not-allowed'],true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title');
1148						}
1149
1150					} else {
1151						var fmAccModal_title = $.lang[LANG]['board.secret-password'];
1152						if(checkhigh_onoff) {
1153							click_tr.removeAttr('data-checkhigh');
1154							fmAccModal_title = $.lang[LANG]['board.goto-checkhigh.'+checkhigh_mode+'.title'];
1155						}
1156						var fmAccModal2 = $(this).showModalFlat(fmAccModal_title,passwdForm(checkhigh_mode),true,true,function() {
1157							var $pass = $('#comm-pass'),
1158								isSubmit = true,
1159								userInput = $pass.val();
1160							$('label.error').remove();
1161							if($pass.val().length<4) {
1162								//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
1163								$pass.closest('.cl-s-form-wrap').addClass('error');
1164								$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13">
1164<path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
1165								$pass.focus();
1166								isSubmit = false;
1167							}
1168
1169							if(isSubmit) {
1170								//$('.comment-addform.password').parent().find('.error').remove();
1171								$('.comment-addform.password').removeClass('error');
1172								$.post('/fm/password', { id: id, passwd : hex_md5($pass.val()), checkhigh: $pass.attr('data-checkhigh')  }, function(pwdata) {
1173									if(typeof pwdata.error != 'undefined' && pwdata.error) {
1174										//$('.comment-addform.password').before('<label class="error">' + pwdata.error + '</label>');
1175										$pass.closest('.cl-s-form-wrap').addClass('error');
1176										$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+pwdata.error+'</label>');
1177										return false;
1178									}
1179									var date = new Date(),
1180										cookietime = 20 * 60 * 1000;
1181									date.setTime(date.getTime() + cookietime);
1182									
1183									$.removeCookie('checkPostHighWriter',{path:'/'});
1184									$.cookie('checkPostWriter', id, { path: '/' , expires: date});
1185									$.cookie('hash', pwdata.hash, { path: '/' , expires: date});
1186
1187									var tmp_v = $pass.attr('data-checkhigh');
1188									if($pass.is('[data-checkhigh]') && typeof tmp_v != 'undefined' && tmp_v) {
1189										$.cookie('checkPostHighWriter'+id, tmp_v+','+pwdata.checkhigh_val, { path: '/' , expires: date});
1190									} else {
1191										$.removeCookie('checkPostHighWriter',{path:'/'});
1192									}
1193									$('.modal[id*=flat-modal]').modal('hide');
1194
1195									$.forum.setForumCookie(pid,page_num,stx,sfl,scate);
1196									if(checkQnAForum) showQnAForumAnswer(F_SID,id,option,$(click_el),checkOldVerForum);
1197									else {
1198										var url = forumUrl(),
1199											href = url + '/forum/view/' + id;
1200
1201										if(typeof MODE == 'undefined') RENDER.history.pushState(null,property.TITLE,href);											
1202										else location.href = href;
1203									}
1204								},'json');
1205							}
1206							modalEmptyCheck();
1207						},'cancel','','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', false, '', function() {
1208							$('.board-password .board-secret-info').remove();
1209							$('.comment-addform.password').before('<div class="board-secret-info">' + $.lang[LANG]['board.writer.password.title'] + '</div>');
1210
1211							if(!checkhigh_onoff) {
1212								if(data.checkhigh != '') {
1213									var checkhigh_v = (data.checkhigh == 'onlyparent') ? 'parent' : data.checkhigh,
1214										checkhigh_str = '<span class="btn-fm-change-checkhigh" data-checkhigh="'+checkhigh_v+'">' + $.lang[LANG]['board.goto-checkhigh.'+checkhigh_v] + '</span>';
1215									if(data.checkhigh == 'parent') checkhigh_str += '<span class="btn-fm-change-checkhigh" data-checkhigh="reply">' + $.lang[LANG]['board.goto-checkhigh.reply'] + '</span>';
1216									
1217									$('.comment-addform.password').after('<div class="clearfix"></div><div class="wrap-fm-change-checkhigh">' + checkhigh_str + '</div>');
1218								}
1219							}
1220
1221							fmAccModal2.find('.btn-fm-change-checkhigh').on('click', function() {
1222								var tmp_v = $(this).attr('data-checkhigh');
1223								click_tr.attr('data-checkhigh',tmp_v);
1224								click_this.click();
1225								fmAccModal2.modal('hide');
1226							});
1227						});
1228					}
1229				} else {
1230					$.forum.setForumCookie(pid,page_num,stx,sfl,scate);
1231
1232					var cookie_date = new Date();
1233					cookie_date.setTime(cookie_date.getTime() + (60*60*1000));
1234					$.cookie('checkPostWriter',id,{ expires: cookie_date, path:'/'});
1235					$.removeCookie('checkPostHighWriter',{path:'/'});
1236
1237					if(checkQnAForum) showQnAForumAnswer(F_SID,id,option,$(click_el),checkOldVerForum);
1238					else {
1239						var url = forumUrl();
1240						var href = url + '/forum/view/' + id;
1241						if(typeof MODE == 'undefined') RENDER.history.pushState(null,property.TITLE,href);
1242						else location.href = href;
1243					}
1244				}
1245			}, 'json');
1246		} else {
1247			$.forum.setForumCookie(pid,page_num,stx,sfl,scate);
1248			if(checkQnAForum) showQnAForumAnswer(F_SID,id,option,$(click_el),checkOldVerForum);
1249			else {
1250				var url = forumUrl();
1251				var href = url + '/forum/view/' + id;
1252				if(typeof MODE == 'undefined') RENDER.history.pushState(null,property.TITLE,href);
1253				else location.href = href;
1254			}
1255		}
1256
1257	});
1258
1259	var showQnAForumAnswer = function(sid,id,option,qnaitem,isOldVer) {
1260
1261		var checkNotice = $(qnaitem).hasClass('n'),
1262			checkOpen = !$(qnaitem).hasClass('open'),
1263			state = $(qnaitem).find('.tpl-forum-list-state').hasClass('active');
1264
1265		if(isOldVer) {
1266			checkNotice = ($(qnaitem).find('.tpl-forum-list-title').hasClass('n')) ? true : false;
1267			checkOpen = ($(qnaitem).hasClass('qna-item') && $(qnaitem).next('.qna-details').css('display') == 'none') ? true : false;
1268			state = $(qnaitem).find('.tpl-forum-list-state[data-state="true"]').length > 0 ? true : false;
1269		}
1270
1271		if(checkOpen) {
1272
1273			$.ajax({
1274				url: '/fm/view',
1275				dataType: 'json',
1276				type: 'POST',
1277				data: { id : id, sid : sid },
1278				async: false,
1279				cache: false,
1280				success: function(data) {
1281					var umemberActivate = (PAGE_MODE == 'c')? Number(UMEMBER_ACTIVATE) : Number(property.UMEMBER_ACTIVATE);
1282					var umember = (PAGE_MODE == 'c')? UMEMBER : property.UMEMBER;
1283					var checkLogin = (PAGE_MODE == 'c')? true : umember.check_login;
1284					if(umemberActivate == 0 && umember.id_type == 'creatorlink') { //creatorlink login
1285						checkLogin = (umember.id !== undefined && umember.id)? true : false;
1286					}
1287
1288					if(typeof data.error != 'undefined' && data.error) {
1289						var url = (PAGE_MODE=='s') ? '/' : '/render/';
1290						if(checkLogin) {
1291							alert(data.error);
1292							(F_ONE) ? location.replace(url + '#' + F_PARENT.page) : location.replace(url + F_PARENT.page);		
1293						} else {
1294							var action = (property.VALIDTYPE == 'SM')  ? '/_login' : '/_cllogin';
1295							var url = forumUrl() + '/forum/view/'+ id;
1296							var html = '<form name="write_login_form" id="write-login" method="post" action="' + action + '" style="display:none;">\
1297											<input type="hidden" name="status" value="forum_view">\
1298											<input type="hidden" name="sid" value="'+property.SID+'">\
1299											<input type="hidden" name="page_mode" value="'+data.access+'">\
1300											<input type="hidden" name="url" value="'+url+'">\
1301										</form>';
1302							$('body').append(html);
1303							document.write_login_form.submit();
1304						}
1305						// alert(data.error);
1306						// location.reload();
1307						return false;
1308					}
1309				
1310					if(typeof data.fonts != 'undefined' && data.fonts && PAGE_MODE!='c') {
1311						$.each(data.fonts, function(i,v) {
1312							if(property.ELFONTS.indexOf(i) < 0) {
1313								property.ELFONTS.push(i);
1314								$('#loadfonts').append(v);
1315							}
1316						});
1317					}
1318
1319					if(typeof data.webfonts != 'undefined' && data.webfonts && PAGE_MODE!='c') {
1320						$.each(data.webfonts, function(i2,v2) {
1321							if(property.ELFONTS.indexOf(i2) < 0 && v2) {
1322								property.ELFONTS.push(i2);
1323								WebFont.load({ google : { families : [ v2 ], display:'swap' }});
1324							}
1325						})
1326					}
1327
1328					var checkState = data.replied ? true : false;
1329					var answer = {
1330						...data.answer || {},
1331						secret: (checkState && data.answer.fm_option == 'S') ? true : false,
1332						title: checkState ? decodeUnicode(data.answer.fm_title) : '',
1333						cont: checkState ? decodeUnicode(data.answer.fm_content) : '',
1334					};
1335
1336					if(data.own && !checkLogin && data.fmid) data.own = false;
1337
1338					var btns = {
1339						q: {
1340							del: (!checkState && (data.own || (data.sign == false && data.fmid == false) || data.mgr)) ? `
1341									<li class="tpl-qna-toolbar-button tpl-toolbar-question-del" data-id="${id}" data-option="${option}">
1342										<button type="button" class="btn btn-default"><span>${$.lang[LANG]['board.button.delete']}</span></button>
1343									</li>
1344								` : '',
1345							edit: (!checkState && ((data.own || (data.sign == false && data.fmid == false)) && data.writeable == true || data.mgr_edit)) ? `
1346									<li class="tpl-qna-toolbar-button tpl-toolbar-question-edit" data-id="${id}" data-option="${option}" data-pid="${data.pid}">
1347										<button type="button" class="btn btn-default"><span>${$.lang[LANG]['board.button.modify']}</span></button>
1348									</li>
1349								` : '',
1350							answer: (!checkState && data.mgr && option!= 'N') ? `
1351									<li class="tpl-qna-toolbar-button tpl-toolbar-question-edit" data-id="${id}" data-option="${option}" data-reply="${id}" data-pid="${data.pid}">
1352										<button type="button" class="btn btn-default"><span>${$.lang[LANG]['forum.qna.answer.write.btn']}</span></button>
1353									</li>
1354								` : '',
1355						},
1356						a: {
1357							del: (checkState && (answer.own || data.mgr)) ? `
1358									<li class="tpl-qna-toolbar-button tpl-toolbar-answer-del" data-id="${answer.seq}" data-option="${option}" >
1359										<button type="button" class="btn btn-default"><span>${$.lang[LANG]['board.button.delete']}</span></button>
1360									</li>
1361								` : '',
1362							edit: (checkState && answer.own) ? `
1363									<li class="tpl-qna-toolbar-button tpl-toolbar-question-edit" data-id="${answer.seq}" data-option="${option}" data-pid="${data.pid}">
1364										<button type="button" class="btn btn-default"><span>${$.lang[LANG]['board.button.modify']}</span></button>
1365									</li>
1366								` : '',
1367						}
1368					};
1369					var question_toolbar = `
1370							<ul class="tpl-qna-toolbar clearfix" data-list-option="q">
1371								${btns.q.answer} ${btns.q.edit} ${btns.q.del}
1372							</ul>
1373						`,
1374						answer_toolbar = `
1375							<ul class="tpl-qna-toolbar clearfix" data-list-option="a">
1376								${btns.a.edit} ${btns.a.del}
1377							</ul>
1378					`;
1379
1380
1381					if(answer.secret) {
1382						var icon_secret = '<i class="tpl-forum-list-secret-icon cl-icon lock02" aria-hidden="true"></i>&nbsp;';
1383						answer.title = icon_secret + ((btns.a.del != '' || checkState) ? answer.title : $.lang[LANG]['forum.qna.content.secret']);
1384						answer.cont = (btns.a.del != '' || checkState) ? answer.cont : '';
1385					}
1386
1387					if($(question_toolbar).html().trim() == '') question_toolbar = '';
1388					if($(answer_toolbar).html().trim() == '') answer_toolbar = '';
1389
1390					if(isOldVer) {
1391						var hasAnswer = $(qnaitem).next().hasClass('qna-details');
1392						if(!hasAnswer) {
1393							var qna_container_default = '\
1394										<div class="tpl-qna-question">\
1395											<div class="tpl-qna-question-content"></div>\
1396										</div>\
1397										<div class="tpl-qna-answer">\
1398											<div class="tpl-qna-answer-title-wrap display-flex space-between">\
1399												<div class="tpl-qna-answer-title"></div>\
1400												<div class="tpl-qna-answer-name"></div>\
1401												<div class="tpl-qna-answer-date"></div>\
1402											</div>\
1403											<div class="tpl-qna-answer-content"></div>\
1404										</div>\
1405								',
1406								detail_html = $(qnaitem).clone(),
1407								detail = document.createElement('div');
1408							$(detail).html(detail_html);
1409							
1410							if($(detail).children().first().is('tr')) {
1411								$(detail).find('.qna-details *[class*=tpl-forum-list-]:not(.tpl-forum-list-content)').html('');
1412								$(detail).find('.qna-details .tpl-forum-list-content').addClass('tpl-qna-container').html(qna_container_default);
1413								$(detail).find('.qna-details').hide();
1414							} else {
1415								$(detail).children().first().addClass('tpl-qna-container').html(qna_container_default);
1416							}
1417
1418							$(qnaitem).after($(detail).html()).hide();
1419							$(detail).remove();
1420						}
1421
1422						$(qnaitem).next('.qna-details').find('.tpl-qna-question-content').html(data.content);
1423						if($(qnaitem).next('.qna-details').find('.tpl-qna-toolbar[data-list-option="q"]').length == 0 ) $(qnaitem).next('.qna-details').find('.tpl-qna-question').append(question_toolbar);
1424						else $(qnaitem).next('.qna-details').find('.tpl-qna-question .tpl-qna-toolbar').replaceWith(question_toolbar);
1425
1426						if(data.replied) {
1427							$(qnaitem).next('.qna-details').find('.tpl-qna-answer-title').html(answer.title);
1428							$(qnaitem).next('.qna-details').find('.tpl-qna-answer-content').html(answer.cont);
1429							$(qnaitem).next('.qna-details').find('.tpl-qna-answer-name').html(answer.fm_name);
1430							$(qnaitem).next('.qna-details').find('.tpl-qna-answer-date').html(answer.fm_re_datetime);
1431							if($(qnaitem).parents().hasClass('newqna')) {
1432								if($(qnaitem).next('.qna-details').find('.tpl-qna-toolbar[data-list-option="a"]').length == 0 ) $(qnaitem).next('.qna-details').find('.tpl-qna-answer-content').append(answer_toolbar);
1433								else $(qnaitem).next('.qna-details').find('.tpl-qna-answer .tpl-qna-toolbar').replaceWith(answer_toolbar);
1434							} else {
1435								if($(qnaitem).next('.qna-details').find('.tpl-qna-toolbar[data-list-option="a"]').length == 0 ) $(qnaitem).next('.qna-details').find('.tpl-qna-answer').after(answer_toolbar);
1436								else $(qnaitem).next('.qna-details').find('.tpl-qna-answer .tpl-qna-toolbar').replaceWith(answer_toolbar);
1437							}
1438						} else {
1439							$(qnaitem).next('.qna-details').find('.tpl-qna-answer').hide();
1440						}
1441
1442						var colspan = $(qnaitem).parents('.table').find('th.tpl-forum-header-row:not(.hide)').length;
1443						if($(qnaitem).next('.qna-details').find('td').length > 1) {
1444							$(qnaitem).next('.qna-details').find('td').each(function() {
1445								if($(this).text().trim() === '') $(this).remove();
1446							});
1447						}
1448						$(qnaitem).next('.qna-details').find('td').attr('colspan', colspan);
1449						$(qnaitem).next('.qna-details').show().siblings('.qna-details').hide();
1450
1451					} else {
1452						var qnaQuestion = $(qnaitem).find(`.tpl-forum-qna-row.question`),
1453							qnaAnswer = $(qnaitem).find(`.tpl-forum-qna-row.answer`);
1454
1455						qnaQuestion.find('.tpl-forum-list-cont').html(data.content);
1456						qnaQuestion.find('.tpl-qna-toolbar').remove();
1457						qnaQuestion.find('.tpl-forum-qna-details').append(question_toolbar);
1458
1459						if(data.replied) {
1460							qnaAnswer.find('.tpl-forum-list-title').html(answer.title);
1461							qnaAnswer.find('.tpl-forum-list-cont').html(answer.cont);
1462							qnaAnswer.find('.tpl-forum-list-name').html(answer.fm_name);
1463							qnaAnswer.find('.tpl-forum-list-date').html(answer.fm_re_datetime);
1464							qnaAnswer.find('.tpl-qna-toolbar').remove();
1465							qnaAnswer.find('.tpl-forum-qna-details').append(`<div class="tpl-forum-qna-row toolbar">${answer_toolbar}</div>`);
1466							$(qnaitem).removeClass('w');
1467						} else {
1468							$(qnaitem).addClass('w');
1469						}
1470
1471						$(qnaitem).addClass('open').siblings().removeClass('open');
1472					}
1473				}
1474			});
1475
1476		} else {
1477			if(isOldVer) $(qnaitem).next('.qna-details').hide();
1478			else $(qnaitem).removeClass('open');
1479		}
1480
1481	}
1482
1483
1484    $(document).on('paste','.note-editable',function(event) {
1485        event.preventDefault();
1486        if(window.clipboardData) {
1487            var text = window.clipboardData.getData('Text');
1488            if (window.getSelection) { // IE11
1489                window.getSelection().getRangeAt(0).insertNode(document.createTextNode(text));
1490            } else if (document.selection && document.selection.createRange) { // old IE
1491                text = text.replace(/\n/g, "<br />");
1492                document.selection.createRange().pasteHTML(text);
1493            }
1494        } else {
1495            var text = (event.originalEvent || event).clipboardData.getData('text/plain') || prompt('Paste something..');
1496            text = text.replace(/\n/g, '<br />');
1497            window.document.execCommand('insertHtml', false, text);
1498        }
1499    });
1500
1501	$(document).on('mousedown mouseup keydown keyup','.fr-view',function(e) {
1502		selRange = saveSelection();
1503	});
1504	
1505	$(document).on('click','button[data-event="showLinkDialog"]', function(e) {
1506		restoreSelection(selRange);
1507	});
1508
1509	$(document).on('click','.set-image', function(e) {
1510		var src = $(this).closest('.result-file').attr('data-file');
1511		$('.fr-view').focus();
1512		if(!$('.fr-view').is(':focus')) {
1513			// placeCaretAtEnd($('.fr-view').get(0));
1514		}
1515
1516		if(upTYPE == 'image') $('#fm-editor').froalaEditor('image.insert', 'http:' + file, true);
1517		else $('#fm-editor').froalaEditor('file.insert', 'http:' + file, orig_name, { 'link' : 'http:' + file, 'target': '_blank' });
1518	});
1519
1520	$(document).on('click','.file-delete', function(e){
1521		var select_file = $(this).parent().attr('data-file-name'),
1522			click_file = $(this).parent().attr('data-file'),
1523			user_file = $('.result-file').map(function() {
1524							return $(this).attr('data-file-name');
1525						}).get().join(',');
1526			$file = $(this).parent();
1527
1528		var modal = $(this).showModalFlat('INFORMATION',$.lang[LANG]['board.ask-delete-attached-file'], true, true, function() {
1529			$.post('/fm/attach_delete',{ select_file : select_file, user_file : user_file, sid : SID }, function(data){
1530				$('.flat-modal').next().remove();
1531				$('.flat-modal').remove();
1532				$file.fadeOut().remove();
1533				$('img[src="' + click_file + '"]').fadeOut('fast',function() { $(this).remove(); });
1534			}, 'json');
1535		}, 'cancel');
1536	});
1537
1538	$(document).on('focus','#fm-editor',function(e) {
1539		$(this).removeClass('content-empty');
1540		// placeCaretAtEnd($('.fr-view').get(0));
1541	}).on('focusout','#fm-editor', function(e) {
1542		setPlaceholder($(this));
1543	});
1544
1545	var setPlaceholder = function($editor) {
1546		var empty = ($editor.find('.fr-view').html()=="<p><br></p>") ? true : false;
1547		(empty) ? $editor.addClass('content-empty') : $editor.removeClass('content-empty');
1548	}
1549
1550	var updateForumPost = function(id,pid) {
1551
1552		var idstr = (id) ? '/m/u/id/' + id : '';
1553		$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
1554			if(typeof data.error != 'undefined' && data.error) {
1555				$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
1556				return false;
1557			}
1558			var post_data = data;
1559			if(data.fmid && data.sign == false) {
1560				userLogin();
1561				return false;
1562			}
1563
1564			if(data.sign == false) {
1565				$(this).showModalFlat($.lang[LANG]['board.button.modify.password'],passwdForm(),true,true,function() {
1566					var $pass = $('#comm-pass'),
1567						isSubmit = true,
1568						userInput = $pass.val();
1569					$('label.error').remove();
1570					if($pass.val().length<4) {
1571						//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
1572						$pass.closest('.cl-s-form-wrap').addClass('error');
1573						$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
1574						$pass.focus();
1575						isSubmit = false;
1576					}
1577
1578					if(isSubmit) {
1579						//$('.comment-addform.password').parent().find('.error').remove();
1580						$.post('/fm/password',{ id: id, passwd : hex_md5($pass.val()) }, function(data) {
1581							if(typeof data.error != 'undefined' && data.error) {
1582								//$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
1583								//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
1584								$pass.closest('.cl-s-form-wrap').addClass('error');
1585								$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+data.error+'</label>');
1586								return false;
1587							}
1588							var date = new Date(),
1589								cookietime = 20 * 60 * 1000;
1590				            date.setTime(date.getTime() + cookietime);
1591
1592							$.cookie('hash', data.hash, { path: '/' , expires: date});
1593							$('.modal[id*=flat-modal]').modal('hide');
1594							setWriteUser(post_data, function() {
1595								location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid;
1596								// forumWrite(id,pid);
1597							});
1598						},'json');
1599					}
1600					modalEmptyCheck();
1601				},'cancel','','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password');
1602			} else if(data.own == true || data.mgr_edit == true) {
1603				setWriteUser(data, function() {
1604					location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid;
1605					// forumWrite(id,pid);
1606				});
1607			} else alert($.lang[LANG]['board.not-own-no-edit']);
1608
1609		}, 'json');
1610	}
1611
1612	var userLogin = function() {
1613		var id = $('#fm-id').val(),
1614			pid = $('#fm-pid').val(),
1615			info = $.lang[LANG]['re-login.info'];
1616
1617		$.post('/fm/checkUser', { pid : pid }, function(data) {
1618			if(!data.user || typeof data.user == 'undefined') {
1619				if(typeof data.error != 'undefined' && data.error) {
1620					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
1621					return false;
1622				}
1623				var modal = $(this).showModalFlat($.lang[LANG]['config.postforum'], info + signForm(id,pid,data.access,data.stoken),true,true,function() {
1624					var isSubmit = true;
1625					$('.error').remove();
1626
1627					var $name = $('#comm-name'),
1628						$pass = $('#comm-pass'),
1629						$key = $('#wr_key'),
1630						nameLength = getBytes( $name.val() );
1631
1632					if( nameLength==0) {
1633						$name.after('<label class="error">' +  $.lang[LANG]['config.enter-name'] + '</label>').focus();
1634						isSubmit = false;
1635					}
1636					else if ( nameLength > 20 ) {
1637						$name.after('<label class="error">' +  $.lang[LANG]['config.guest-id-max-length'] + '</label>').focus();
1638						isSubmit = false;
1639					}
1640					if($pass.val().length<4) {
1641						$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
1642						isSubmit = false;
1643					}
1644
1645					if($key.val().length==0) {
1646						$key.after('<label class="error">' +  $.lang[LANG]['config.enter-captcha'] + '</label>').focus();
1647						isSubmit = false;
1648					}
1649
1650					if($key.val() && (Base64.encode($key.val().trim()) != md5_norobot_key)) {
1651						$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
1652						isSubmit = false;
1653					}
1654
1655					// var key = '';
1656					// if(isSubmit == true) {
1657					// 	key = checkCaptcha();
1658					// 	if(!key.success) {
1659					// 		$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
1660					// 		isSubmit = false;
1661					// 	}
1662					// }
1663
1664					resetObject(user);
1665					if(isSubmit==true) {
1666						modal.modal('hide');
1667						user.name = data.name = $name.val();
1668						user.nameLength = nameLength;
1669						user.pass = hex_md5( $pass.val() );
1670						user.key = $key.val().trim();
1671						setWriteUser(data);
1672					}
1673				},'cancel','','w450',true,'',function() {
1674					// loadCaptcha();
1675					load_kcaptcha();
1676				});
1677				$('.flat-modal .modal-body').addClass('comment');
1678				$('.flat-modal .modal-footer').hide();
1679				$('.modal[id*=flat-modal]').css('z-index','1040');
1680				$('.flat-modal').next('.modal-backdrop').css('z-index','1039');
1681				if(!user.pass) $('.flat-modal .signType').last().hide();
1682				// $('#kcaptcha').click();
1683			} else {
1684				// resetObject(user);
1685				setWriteUser(data);
1686			}
1687		},'json');
1688	}
1689
1690	var passwdForm = function(checkhigh) {
1691		if(typeof checkhigh == 'undefined') checkhigh = '';
1692		return '' +
1693			'<div class="cl-s-form-wrap comment-addform password">' +
1694				'<div class="cl-s-form-group">' +
1695					'<input type="password" class="cl-s-form-control" id="comm-pass" name="comm-pass" required="required" value="" data-checkhigh="' + checkhigh + '">' +
1696					'<label for="input" class="cl-s-control-label">' + $.lang[LANG]['config.modal.password'] + '</label>' +
1697				'</div>' +
1698			'</div>';
1699	}
1700	var videoForm = function() {
1701		return '' +
1702			'<div class="form-inline comment-addform video">' + 
1703			  	'<div class="form-group">' +
1704			  		'<p><b>Video URL?</b> (YouTube, Vimeo, SoundCloud, Metacafe or DailyMotion)</p>' + 
1705			    	'<label class="sr-only" for="label-video">' +  $.lang[LANG]['config.modal.password'] + '</label>' +
1706			    	'<input type="text" class="form-control" id="video-url" placeholder="http(s)://">' +
1707			  	'</div>' +
1708			'</div>';
1709	}
1710
1711
1712	var modalEmptyCheck = function() {
1713		$('.cl-s-form-control').off().on({
1714			keyup: function(e) {
1715				if(e.keyCode === 13) {
1716					if($(this).closest('.cl-s-form-wrap').next('.cl-s-form-wrap').length > 0) {
1717						$(this).closest('.cl-s-form-wrap').next('.cl-s-form-wrap').find('.cl-s-form-control').focus();
1718					} else if($(this).closest('.cl-s-form-wrap').next('#captcha:not(:empty)').length > 0) {
1719						$('#wr_key').focus();
1720					}
1721				}
1722			},
1723			focus: function(e) {
1724				$(this).closest('.cl-s-form-wrap').addClass('active');
1725			},
1726			blur: function(e) {
1727				var inputEL = $(this),
1728					type = $(this).attr('id'),
1729					val = $(this).val().trim(),
1730					error_str = '';
1731
1732				inputEL.closest('.cl-s-form-wrap').removeClass('active');
1733				if(val.length == 0) {
1734					inputEL.closest('.cl-s-form-wrap').removeClass('error').addClass('empty');
1735					inputEL.closest('.cl-s-form-wrap').find('.cl-s-control-label.error').remove();
1736					return false;
1737				} else {
1738					inputEL.closest('.cl-s-form-wrap').removeClass('empty');
1739					var error_str = '';
1740					if(type == 'comm-pass') {
1741						if(val.length<4) {
1742							error_str = '<svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>
1742' + $.lang[LANG]['config.pass-min-length'];
1743						}
1744					}
1745					if(error_str.length > 0) {
1746						inputEL.closest('.cl-s-form-wrap').addClass('error');
1747						if(inputEL.parent().parent().find('.cl-s-control-label.error').length > 0) {
1748							inputEL.parent().parent().find('.cl-s-control-label.error').html(error_str);
1749						} else {
1750							inputEL.parent().parent().next('.cl-s-control-label.error').remove();
1751							inputEL.parent().parent().after('<label for="input" class="cl-s-control-label error">'+error_str+'</label>');
1752						}
1753						return false;
1754					}
1755				}
1756				inputEL.closest('.cl-s-form-wrap').removeClass('error').removeClass('empty');
1757				inputEL.parent().parent().next('.cl-s-control-label.error').remove();
1758				if($('.error_login').length > 0) $('.error_login').remove();
1759			}
1760		});
1761		$('#wr_key').off().on({
1762			keyup: function(e) {
1763				$(this).closest('.kcaptcha-box').removeClass('empty').removeClass('error');
1764			},
1765			focus: function(e) {
1766				$(this).closest('.kcaptcha-box').addClass('active');
1767			},
1768			blur: function(e) {
1769				if($(this).val().trim().length == 0) {
1770					$(this).closest('.kcaptcha-box').removeClass('active');
1771				} else {
1772					$(this).closest('.kcaptcha-box').removeClass('empty').removeClass('error').removeClass('active');
1773				}
1774				$(this).closest('.kcaptcha-box').parent().find('.kcaptcha-error').remove();
1775			}
1776		});
1777	}
1778
1779	$(document).on('click', '.tpl-guestbook-write', function(e) {
1780		if(PAGE_MODE == 'r') return false;
1781		var id = '';
1782		var element = $(this).parents('.element');
1783		var sid = (typeof property == 'undefined') ? SID : property.SID,
1784			pid = element.attr('data-id');
1785		
1786		var content = '', passwd = '', captcha = '', secret = 'N', writer = '';
1787
1788			
1789		var validation_flag = true;
1790		element.find('.error-box').remove();
1791		if($(this).attr('data-id')) {//if는 수정창 등록 버튼
1792			id = $(this).attr('data-id');
1793			var edit_box = element.find('.guestbook-edit');
1794			content = edit_box.find('.input-content').val();
1795			secret = edit_box.find('.secret-check input[type="checkbox"]').prop('checked') ? 'S' : 'N';
1796			if($.trim(content) == '' || $.trim(content).length < 2) {
1797				edit_box.find('.input-content').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.content'] + '</div>');
1798				validation_flag = false;
1799			}
1800		} else {
1801			
1802			//element.find('.list-area').find('.editing,.hide').removeClass('editing hide');			
1803			element.find('.guestbook-edit').parents('.list-item').find('.editing.hide').removeClass('editing hide');			
1804			$('.guestbook-edit').remove();
1805			
1806			
1807			
1808			writer = element.find('.input-name').val();
1809			content = element.find('.input-content').val();
1810			passwd = element.find('.input-pw').val();
1811			captcha = element.find('input[name="wr_key"]').val();
1812			secret = element.find('.secret-check input[type="checkbox"]').prop('checked') ? 'S' : 'N';
1813			
1814			if(PAGE_MODE != 'c' ) {
1815				if((!RENDER.b.UMEMBER.id || (RENDER.b.UMEMBER.id_type == 'creatorlink' && !RENDER.b.UMEMBER.check_adm && !RENDER.b.UMEMBER.check_adm)) && $.trim(writer) == '') {
1816					element.find('.input-name').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.name'] + '</div>');
1817					validation_flag = false;
1818				}
1819				if((!RENDER.b.UMEMBER.id || (RENDER.b.UMEMBER.id_type == 'creatorlink' && !RENDER.b.UMEMBER.check_adm && !RENDER.b.UMEMBER.check_adm)) && $.trim(passwd) == '') {
1820					element.find('.input-pw').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.passwd'] + '</div>');
1821					validation_flag = false;
1822				} else if((!RENDER.b.UMEMBER.id || (RENDER.b.UMEMBER.id_type == 'creatorlink' && !RENDER.b.UMEMBER.check_adm && !RENDER.b.UMEMBER.check_adm)) && $.trim(passwd).length < 4) {
1823					element.find('.input-pw').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.passwd.length'] + '</div>');
1824					validation_flag = false;
1825				}
1826				if(element.find('.kcaptcha-key-wrap:visible').length > 0 && $.trim(captcha) == '') {
1827					element.find('.captcha').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.captcha'] + '</div>');
1828					validation_flag = false;
1829				}
1830			}
1831			if($.trim(content) == '' || $.trim(content).length < 2) {
1832				//방명록 블럭 디자인 5,6번
1833				if (element.find('.guestbook-design5-bgcolor').is('.guestbook-design5-bgcolor') || element.hasClass('guestbook-fr-35')) {				
1834					element.find('.input-content').parent().after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.content'] + '</div>');
1835					validation_flag = false;
1836				}
1837				else{
1838					element.find('.input-content').after('<div class="error-box">! ' + $.lang[LANG]['forum.guestbook.validation.content'] + '</div>');
1839					validation_flag = false;
1840				}
1841			}
1842		}
1843
1844
1845		if(!validation_flag) return false;
1846
1847		$.ajax({
1848			url:'/fm/guestbook',
1849			type:'post',
1850			dataType:'json',
1851			data:{
1852				'id' : id,
1853				'sid' : sid,
1854				'pid' : pid,
1855				'writer' : writer,
1856				'content' : content,
1857				'passwd' : hex_md5(passwd),
1858				'captcha' : captcha,
1859				'secret' : secret,
1860				'mode' : PAGE_MODE,
1861			},
1862			success:function(data) {		
1863				if(data.error) {
1864					alert(data.error);
1865				} else {	
1866					page = 1,
1867					page_num = 1,
1868					view = element.find('[data-view]').attr('data-view'),
1869					sfl = "",
1870					stx = "",
1871					scate = "";
1872
1873					$.forum.setForumCookie(pid,page_num,stx,sfl,scate);
1874					cookie_page_num = $.cookie('forum_'+pid);
1875					$.forum.init(pid,page,view,cookie_page_num,sfl,stx,scate);
1876				}
1877			}
1878		});
1879	});
1880
1881	$(document).on('click', '.tpl-guestbook-more-menu', function(e) {
1882		if($(this).next('.tpl-guestbook-more-menu-area').length) {
1883			$('.tpl-guestbook-more-menu-area').remove();
1884			return false;
1885		}
1886		$('.tpl-guestbook-more-menu-area').remove();
1887		var html = '';
1888		html += '\
1889		<div class="tpl-guestbook-more-menu-area">\
1890		';
1891		var fm_mb_id = $(this).parents('.list-item').find('.tpl-forum-list-cont').attr('data-fm_mb_id');
1892		if((PAGE_MODE != 'c' && (RENDER.b.UMEMBER.check_adm != true && RENDER.b.UMEMBER.check_uadm != true)) || 
1893				(PAGE_MODE != 'c' && (RENDER.b.UMEMBER.check_adm == true || RENDER.b.UMEMBER.check_uadm == true) && fm_mb_id == RENDER.b.UMEMBER.id)
1894			|| (PAGE_MODE == 'c' && fm_mb_id == MB_ID)) {
1895			html += '<div data-oper="U">' + $.lang[LANG]['forum.guestbook.btn.modify'] + '</div>';
1896		}
1897		html += '\
1898			<div data-oper="D">' + $.lang[LANG]['forum.guestbook.btn.delete'] + '</div>\
1899		</div>\
1900		';
1901		var $box = $(html);
1902		$(this).after($box);
1903		var top = $(this).position().top + $(this).outerHeight();
1904		var left = $(this).position().left + $(this).outerWidth() / 2;
1905		left -= $box.outerWidth() / 2;
1906		$box.css('top', top);
1907		$box.css('left', left);
1908	});
1909
1910	$(document).on('click', '.tpl-guestbook-cancel', function(e) {
1911		$(this).parents('.list-item').find('.tpl-forum-list-cont').removeClass('editing hide');
1912		$(this).parents('.list-item').find('.tpl-guestbook-more-menu').removeClass('editing hide');
1913		$(this).parents('.list-item').find('.tpl-guestbook-more-menu-area-el2').removeClass('editing hide');
1914		$(this).parents('.list-item').find('.guestbook-edit').remove();
1915		$('.tpl-guestbook-more-menu-area-el2').css('display','');		
1916	});
1917
1918
1919	//guest book2
1920	$(document).on('click', '.tpl-guestbook-more-menu-area-el2 div', function(e) {
1921	
1922		var $cont_box = $(this).parents('.list-item').find('.tpl-forum-list-cont');		
1923		var check_text = $(this).parents('.btn-area2').parents('.list-item').find('.content').text();	
1924		var $btn = $(this);
1925		var element = $(this).parents('.element');
1926		var oper = $btn.attr('data-oper');
1927		var fm_id = $cont_box.attr('data-fm_mb_id');
1928		var id = $cont_box.attr('data-id');
1929		var element = $(this).closest('.element');
1930		var pid = element.attr('data-id');
1931		var $list_item = $btn.parents('.list-item');
1932
1933		if (element.find('.fr34').hasClass('fr34')) {
1934		var chk_delete_first = check_text.substr(1);		
1935		var chk_delete_last = chk_delete_first.slice(0, -1);
1936		}
1937
1938		var makeUpdateForm = function() {
1939			$('.guestbook-edit').remove();
1940			$('.editing.hide').removeClass('editing hide');
1941
1942			$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
1943				if(typeof data.error != 'undefined' && data.error) {
1944					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
1945					return false;
1946				} else {
1947					if(data.own) {
1948						$list_item.find('.tpl-guestbook-more-menu-area-el2').addClass('editing hide');
1949						var text = $.trim($cont_box.text());
1950						var button_area = element.find('.button-area').clone();						
1951						button_area.find('.tpl-guestbook-write').before('<button type="button" class="btn tpl-guestbook-cancel">' + element.find('.tpl-guestbook-cancel:first').text() + '</button>');
1952						
1953					var hasTextClass = button_area[0].classList.contains('fr34-input-height');
1954					var fr35_hasTextClass = button_area[0].classList.contains('guestfr35');
1955					if(hasTextClass === false){
1956						if(fr35_hasTextClass === true){ //forum35							
1957						var html = '\
1958							<div class="guestbook-edit">\
1959							<div class="textarea-wrap-error" style="position:relative;">\
1960								<textarea class="input-content form-control input-bg-opacity keyup-check" style="height: 91px;"maxlength="300" ></textarea><div class="textcount edit-text-check" style="position: absolute;right:63px;top:63px;">'+check_text.length+'/300</div>\
1961								</div>\
1962								' + button_area.outerHTML() + '\
1963							</div>\
1964						';	
1965						}else{//forum29,32,33
1966							
1967						var html = '\
1968							<div class="guestbook-edit">\
1969								<textarea class="input-content form-control input-bg-opacity"></textarea>\
1970								' + button_area.outerHTML() + '\
1971							</div>\
1972						';}
1973					}else if(fr35_hasTextClass === false ){//forum34
1974
1975						var html = '\
1976							<div class="guestbook-edit">\
1977								<div class="textarea-wrap-error " style="position:relative;">\
1978								<textarea class="input-content form-control input-bg-opacity keyup-check" style="height:140px;" maxlength="300"></textarea><div class="textcount edit-text-check" >'+chk_delete_last.length+'/300</div>\
1979								</div>\
1980								' + button_area.outerHTML() + '\
1981							</div>\
1982						';						
1983						text = text.replace(/^"*/,"").replace(/"*$/,"");
1984					} 
1985					var $html = $(html);
1986						$cont_box.before($html);
1987						$html.find('.input-content').val(text);
1988						if(data.option == 'S') $cont_box.prev('.guestbook-edit').find('.secret-check input[type="checkbox"]').prop('checked', true);
1989						$cont_box.prev('.guestbook-edit').find('.tpl-guestbook-write').attr('data-id', id);
1990						$cont_box.addClass('editing hide');
1991					}
1992					var header_check = $("header").attr("data-fh-type");										
1993					 var editor_height = ( $(".editor-navbar").hasClass("editor-navbar")) ? $(".editor-navbar").outerHeight(true) : 0 ;
1994					
1995					
1996
1997					if (header_check != "sidebar") { 
1998						var header_height = $("header").outerHeight(true); 
1999					}else{
2000						var header_height = 0;
2001					}
2002					
2003					
2004					if ( PAGE_MODE == ('c')) {						
2005						$('.dsgn-body').scrollTop($('.dsgn-body').scrollTop() + $cont_box.closest('.list-item').offset().top  - editor_height - header_height );
2006								
2007					} else if (PAGE_MODE == ('s')) {							
2008						//$(document).scrollTop($(document).scrollTop() + $cont_box.closest('.list-item').offset().top  -  header_height );
2009						$(document).scrollTop ($cont_box.closest('.list-item').offset().top - header_height - 200 )
2010						
2011					}	
2012							
2013				}
2014			}, 'json');
2015		};
2016
2017		if(oper == 'D') { // 삭제
2018			if(PAGE_MODE == 'c' || RENDER.b.UMEMBER.check_adm == true || RENDER.b.UMEMBER.check_uadm == true) {
2019				var modal = $(this).showModalFlat('', $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
2020					modal.modal('hide');
2021					deleteGuestbook(pid, id);
2022				}, 'cancel', $.lang[LANG]['config.delete'],'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-t80 cl-modal cl-none-title cl-close-btn');
2023			} else {
2024				$.forum.deleteGuestbook(pid, id);
2025			}
2026		} else if(oper == 'U') { // 수정
2027			if(PAGE_MODE == 'c' || (PAGE_MODE != 'c' && fm_id != '' && fm_id == RENDER.b.UMEMBER.id)) {
2028				makeUpdateForm();
2029			} else {
2030
2031				var modal = $(this).showModalFlat($.lang[LANG]['forum.guestbook.title.edit'], passwdForm(), true, true, function() {
2032					var $pass = $('#comm-pass'),
2033						isSubmit = true;
2034					$('label.error').remove();
2035					if($pass.val().length<4) {
2036						//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2037						$pass.closest('.cl-s-form-wrap').addClass('error');
2038						$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13">
2038<path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
2039						$pass.focus();
2040						isSubmit = false;
2041					}
2042
2043					if(isSubmit) {
2044						//$('.comment-addform.password').parent().find('.error').remove();
2045						$('.comment-addform.password').removeClass('error');
2046						$.post('/fm/password', { id: id, passwd : hex_md5($pass.val()) }, function(data) {
2047							if(typeof data.error != 'undefined' && data.error) {
2048								//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
2049								$pass.closest('.cl-s-form-wrap').addClass('error');
2050								$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+data.error+'</label>');
2051								return false;
2052							}
2053							var date = new Date(),
2054								cookietime = 20 * 60 * 1000;
2055							date.setTime(date.getTime() + cookietime);
2056							
2057							$.removeCookie('checkPostHighWriter',{path:'/'});
2058							$.cookie('checkPostWriter', id, { path: '/' , expires: date});
2059							$.cookie('hash', data.hash, { path: '/' , expires: date});
2060							$('.modal[id*=flat-modal]').modal('hide');
2061
2062							
2063							makeUpdateForm();
2064						},'json');
2065					}
2066					modalEmptyCheck();
2067					
2068				}, 'cancel', 'ok','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', '', '', function() {
2069					modal.find('#comm-pass').addClass('guestbook-pass');
2070				});
2071				
2072			}
2073		}
2074		// $(this).parents('.tpl-guestbook-more-menu-area-el2').css('display','none');
2075	});
2076
2077
2078
2079
2080	$(document).on('click', '.tpl-guestbook-more-menu-area div', function(e) {
2081		var $cont_box = $(this).parents('.list-item').find('.tpl-forum-list-cont');
2082		var $btn = $(this);
2083		var element = $(this).parents('.element');
2084		var oper = $btn.attr('data-oper');
2085		var fm_id = $cont_box.attr('data-fm_mb_id');
2086		var id = $cont_box.attr('data-id');
2087		var element = $(this).closest('.element');
2088		var pid = element.attr('data-id');
2089		var $list_item = $btn.parents('.list-item');
2090		var makeUpdateForm = function() {
2091			$('.guestbook-edit').remove();
2092			$('.editing.hide').removeClass('editing hide');
2093
2094			$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
2095				if(typeof data.error != 'undefined' && data.error) {
2096					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2097					return false;
2098				} else {
2099					if(data.own) {
2100						$list_item.find('.tpl-guestbook-more-menu').addClass('editing hide');
2101						var text = $.trim($cont_box.text());
2102						var button_area = element.find('.button-area').clone();
2103						
2104						button_area.find('.tpl-guestbook-write').before('<button type="button" class="btn tpl-guestbook-cancel">' + element.find('.tpl-guestbook-cancel:first').text() + '</button>');
2105
2106						$cont_box.before(`
2107							<div class="guestbook-edit">
2108								<textarea class="input-content form-control ${(element.hasClass('versioncheck')) ? 'input-bg-opacity' : ''}">${text}</textarea>
2109								${button_area.outerHTML()}
2110							</div>
2111						`);
2112						if(data.option == 'S') $cont_box.prev('.guestbook-edit').find('.secret-check input[type="checkbox"]').prop('checked', true);
2113						$cont_box.prev('.guestbook-edit').find('.tpl-guestbook-write').attr('data-id', id);
2114						$cont_box.addClass('editing hide');
2115					}
2116				}
2117			}, 'json');
2118		};
2119
2120		if(oper == 'D') { // 삭제
2121			if(PAGE_MODE == 'c' || RENDER.b.UMEMBER.check_adm == true || RENDER.b.UMEMBER.check_uadm == true) {
2122				var modal = $(this).showModalFlat('', $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
2123					modal.modal('hide');
2124					deleteGuestbook(pid, id);
2125				}, 'cancel', $.lang[LANG]['config.delete'],'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-t80 cl-modal cl-none-title cl-close-btn');
2126			} else {
2127				$.forum.deleteGuestbook(pid, id);
2128			}
2129		} else if(oper == 'U') { // 수정
2130			if(PAGE_MODE == 'c' || (PAGE_MODE != 'c' && fm_id != '' && fm_id == RENDER.b.UMEMBER.id)) {
2131				makeUpdateForm();
2132			} else {
2133
2134				var modal = $(this).showModalFlat($.lang[LANG]['forum.guestbook.title.edit'], passwdForm(), true, true, function() {
2135					var $pass = $('#comm-pass'),
2136						isSubmit = true;
2137					$('label.error').remove();
2138					if($pass.val().length<4) {
2139						//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2140						$pass.closest('.cl-s-form-wrap').addClass('error');
2141						$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13">
2141<path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
2142						$pass.focus();
2143						isSubmit = false;
2144					}
2145
2146					if(isSubmit) {
2147						//$('.comment-addform.password').parent().find('.error').remove();
2148						$('.comment-addform.password').removeClass('error');
2149						$.post('/fm/password', { id: id, passwd : hex_md5($pass.val()) }, function(data) {
2150							if(typeof data.error != 'undefined' && data.error) {
2151								//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
2152								$pass.closest('.cl-s-form-wrap').addClass('error');
2153								$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+data.error+'</label>');
2154								return false;
2155							}
2156							var date = new Date(),
2157								cookietime = 20 * 60 * 1000;
2158							date.setTime(date.getTime() + cookietime);
2159
2160							$.removeCookie('checkPostHighWriter',{path:'/'});
2161							$.cookie('checkPostWriter', id, { path: '/' , expires: date});
2162							$.cookie('hash', data.hash, { path: '/' , expires: date});
2163							$('.modal[id*=flat-modal]').modal('hide');
2164
2165							
2166							makeUpdateForm();
2167						},'json');
2168					}
2169					modalEmptyCheck();
2170					
2171				}, 'cancel', 'ok','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', '', '', function() {
2172					modal.find('#comm-pass').addClass('guestbook-pass');
2173				});
2174			}
2175		}
2176		$(this).parents('.tpl-guestbook-more-menu-area').remove();
2177	});
2178
2179	$(document).on('click', '[data-type="forum"] .list-item.blind', function(e) {
2180		e.preventDefault();
2181		e.stopPropagation();
2182		var $list_item = $(this);
2183		var $cont_box = $(this).find('.tpl-forum-list-cont');
2184		var element = $(this).parents('.element');
2185		var fm_id = $cont_box.attr('data-fm_mb_id');
2186		var id = $cont_box.attr('data-id');
2187		var element = $(this).closest('.element');
2188		var pid = element.attr('data-id');
2189
2190		var modal = $(this).showModalFlat($.lang[LANG]['forum.guestbook.title.secret'], passwdForm(), true, true, function() {
2191			var $pass = $('#comm-pass'),
2192				isSubmit = true;
2193			$('label.error').remove();
2194			if($pass.val().length<4) {
2195				//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2196				$pass.closest('.cl-s-form-wrap').addClass('error');
2197				$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
2198				$pass.focus();
2199				isSubmit = false;
2200			}
2201
2202			if(isSubmit) {
2203				//$('.comment-addform.password').parent().find('.error').remove();
2204				$('.comment-addform.password').removeClass('error');
2205				$.post('/fm/password', { id: id, passwd : hex_md5($pass.val()) }, function(data) {
2206					if(typeof data.error != 'undefined' && data.error) {
2207						//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
2208						$pass.closest('.cl-s-form-wrap').addClass('error');
2209						$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>
2209'+data.error+'</label>');
2210						return false;
2211					}
2212					var date = new Date(),
2213						cookietime = 20 * 60 * 1000;
2214					date.setTime(date.getTime() + cookietime);
2215					
2216					$.removeCookie('checkPostHighWriter',{path:'/'});
2217					$.cookie('checkPostWriter', id, { path: '/' , expires: date});
2218					$.cookie('hash', data.hash, { path: '/' , expires: date});
2219
2220					$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
2221						if(typeof data.error != 'undefined' && data.error) {
2222							$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2223							return false;
2224						} else {
2225							$cont_box.html(nl2br(data.content));
2226							$list_item.removeClass('blind');
2227							$list_item.find('.tpl-guestbook-more-menu').removeClass('hide');
2228							$list_item.find('.tpl-guestbook-more-menu-area-el2').removeClass('hide');
2229						}
2230					}, 'json');
2231
2232
2233					$('.modal[id*=flat-modal]').modal('hide');
2234
2235				},'json');
2236			}
2237			modalEmptyCheck();
2238			
2239		}, 'cancel', 'ok','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', '', '', function() {
2240			modal.find('#comm-pass').addClass('guestbook-pass');
2241		});
2242	});
2243
2244	$(document).on('click', function(e) {
2245		var container = $('.tpl-guestbook-more-menu-area');
2246		if(container.has(e.target).length == 0 && container.get(0) != e.target && $('.tpl-guestbook-more-menu').has(e.target).length == 0 && !$(e.target).hasClass('tpl-guestbook-more-menu')) {
2247			container.hide();
2248			//버그수정
2249			container.remove();
2250
2251		}
2252
2253		if($('.search-forum-user-posts').length > 0 && !$(e.target).is('.tpl-forum-list-name')) {
2254			$('.tpl-forum-list-name').removeClass('search-on');
2255			$('.search-forum-user-posts').remove();
2256		}
2257	});
2258	$(document).on('keyup keydown','.keyup-check',function(e) {	
2259	if (e.keyCode == 13) {e.preventDefault();} 
2260		var content = $(this).val();
2261          $($(this).next('.textcount, .textarea-height')).text(""+ content.length + "/300");
2262        if (content.length >= 300) {
2263        	$(this).val($(this).val().substring(0, 300)); 
2264         	$($(this).next('.textcount,.textarea-height')).text(""+ "300" + "/300");   
2265         } 
2266	});
2267	$(document).on('click','.tpl-forum-write',function(e) {
2268		var sid = (typeof property == 'undefined') ? SID : property.SID;
2269		var pid = $(this).attr('data-pid');
2270		var id = (typeof $(this).attr('data-id') != 'undefined') ? $(this).attr('data-id') : '';
2271		var reply = (typeof $(this).attr('data-reply') != 'undefined') ? $(this).attr('data-reply') : '';
2272		var one = (typeof ONE == 'undefined') ? property.ONE : ONE;
2273		var page = (typeof PAGE == 'undefined') ? property.PAGE : PAGE;
2274
2275		try {
2276			var validType = property['VALIDTYPE'];
2277		} catch (err) {
2278			var validType = '';
2279		}
2280
2281		var idstr = (id) ? '/m/u/id/' + id : '';
2282		var replystr = (reply) ? '/reply/' + reply : '';
2283
2284		if(id) {
2285			updateForumPost(id,pid);
2286			return false;
2287		}
2288
2289		var url = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
2290		var is_new = (id != '') ? 'false' : 'true';
2291		$.post('/fm/checkUser', { pid : pid, reply : reply, id : id, isnew : is_new }, function(data) {
2292			if(!data.user || typeof data.user == 'undefined') {
2293				if(typeof data.error != 'undefined' && data.error) {
2294					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2295					return false;
2296				}
2297				
2298				var base_url = (PAGE_MODE=='s') ? '/' : '/render/';
2299				if(PAGE_MODE == 'c') {
2300					base_url = '/'+CONFIG_URL+'config/page/'
2301				}
2302
2303				var page_url = (one) ? base_url + 'index#' + page : base_url + page;
2304				var action = (validType == 'SM') ? '/_login' : '/_cllogin',
2305					html = '\
2306						<form name="write_login_form" id="write_login_form" method="post" action="' + action + '" style="display:none;">\
2307							<input type="hidden" name="status" value="write">\
2308							<input type="hidden" name="sid" value="'+sid+'">\
2309							<input type="hidden" name="type" value="F">\
2310							<input type="hidden" name="pid" value="'+pid+'">\
2311							<input type="hidden" name="page_url" value="'+page_url+'">\
2312							<input type="hidden" name="page_mode" value="'+data.access+'">\
2313							<input type="hidden" name="url" value="'+url+'">\
2314							<input type="hidden" name="reply" value="'+reply+'">\
2315							<input type="hidden" name="id" value="'+id+'">\
2316						</form>\
2317					';
2318
2319				$('body').append(html);
2320				document.write_login_form.submit();
2321
2322				/*
2323				if (validType == 'SM') {
2324					var html = '<form name="write_login_form" id="write_login_form" method="post" action="/_login" style="display:none;">\
2325									<input type="hidden" name="status" value="write">\
2326									<input type="hidden" name="url" value="'+url+'">\
2327									<input type="hidden" name="pid" value="'+pid+'">\
2328									<input type="hidden" name="pid_type" value="forum">\
2329									<input type="hidden" name="reply" value="'+reply+'">\
2330									<input type="hidden" name="id" value="'+id+'">\
2331									<input type="hidden" name="page_mode" value="'+data.access+'">\
2332								</form>';
2333
2334					$('body').append(html);
2335					document.write_login_form.submit();
2336				} else {
2337					// FREE or BN login
2338					var html = '<form name="write_cllogin_form" id="write_cllogin_form" method="post" action="/_cllogin" style="display:none;">\
2339									<input type="hidden" name="status" value="write">\
2340									<input type="hidden" name="sid" value="'+F_SID+'">\
2341									<input type="hidden" name="url" value="'+url+'">\
2342									<input type="hidden" name="pid" value="'+pid+'">\
2343									<input type="hidden" name="pid_type" value="forum">\
2344									<input type="hidden" name="reply" value="'+reply+'">\
2345									<input type="hidden" name="id" value="'+id+'">\
2346									<input type="hidden" name="page_mode" value="'+data.access+'">\
2347								</form>';
2348
2349					$('body').append(html);
2350					document.write_cllogin_form.submit();
2351				}
2352				*/
2353
2354			} else { //login user
2355				if(data.writeable == false) {
2356					var access = data.access;
2357					var message = 'error';
2358					
2359					switch (access) {
2360						// case 'NM':
2361						// 	message = $.lang[LANG]['board.nonmembers-can-write'];
2362						// 	break;
2363						case 'G':
2364							message = $.lang[LANG]['board.group-can-write'];
2365							break;
2366						case 'ADM':
2367							message = $.lang[LANG]['board.admin-can-write'];
2368							break;
2369						default:
2370							break;
2371					}
2372
2373					$(this).showModalFlat('INFORMATION', message, true, false, '', 'ok', '', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title');
2374					return false;
2375				}
2376				setWriteUser(data, function() {
2377					location.href = url;
2378				});
2379			}
2380		},'json');
2381//asdf
2382
2383
2384	
2385				// return false;
2386
2387
2388				// var modal_str = signForm(id,pid,data.access,data.stoken);
2389				// if(typeof modal_str != 'string') return false;
2390				// var modal = $(this).showModalFlat($.lang[LANG]['config.postforum'],modal_str,true,true,function() {
2391
2392				// 	var isSubmit = true;
2393				// 	//$('.error').remove();
2394				// 	var $name = $('#comm-name'),
2395				// 		$pass = $('#comm-pass'),
2396				// 		$key = $('#wr_key'),
2397				// 		nameLength = getBytes( $name.val() );
2398
2399				// 	$('.kcaptcha-error').remove();
2400				// 	$('label.error').remove();
2401
2402				// 	if( nameLength==0) {
2403				// 		//$name.after('<label class="error">' +  $.lang[LANG]['config.enter-name'] + '</label>').focus();
2404				// 		$name.closest('.cl-s-form-wrap').addClass('empty');
2405				// 		$name.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.enter-name']+'</label>');
2406				// 		isSubmit = false;
2407				// 	}
2408				// 	else if ( nameLength > 20 ) {
2409				// 		//$name.after('<label class="error">' +  $.lang[LANG]['config.guest-id-max-length'] + '</label>').focus();
2410				// 		$name.closest('.cl-s-form-wrap').addClass('empty');
2411				// 		$name.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.guest-id-max-length']+'</label>');
2412				// 		isSubmit = false;
2413				// 	}
2414				// 	if($pass.val().length<4) {
2415				// 		//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2416				// 		$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
2417				// 		$pass.closest('.cl-s-form-wrap').addClass('empty');
2418				// 		isSubmit = false;
2419				// 	}
2420				// 	// if($('#recaptcha').attr('data-res')=='') {
2421				// 	// 	$key.after('<label class="error">' +  $.lang[LANG]['config.enter-captcha'] + '</label>').focus();
2422				// 	// 	isSubmit = false;
2423				// 	// }
2424
2425				// 	if($key.val().length==0) {
2426				// 		//$key.after('<label class="error">' +  $.lang[LANG]['config.enter-captcha'] + '</label>').focus();
2427				// 		$key.closest('.kcaptcha-box').addClass('empty');
2428				// 		$key.closest('.kcaptcha-box').after('<label class="error kcaptcha-error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2429				// 		isSubmit = false;
2430				// 	}
2431
2432				// 	if($key.val() && (Base64.encode($key.val().trim()) != md5_norobot_key)) {
2433				// 		//$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2434				// 		$key.closest('.kcaptcha-box').addClass('error');
2435				// 		$key.closest('.kcaptcha-box').after('<label class="error kcaptcha-error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2436				// 		// console.log('input value :' + $key.val());
2437				// 		// console.log('hex_md5 : ' + Base64.encode($key.val().trim()));
2438				// 		// console.log('key : ' + md5_norobot_key);
2439				// 		isSubmit = false;
2440				// 	}
2441
2442				// 	// var key = '';
2443				// 	// if(isSubmit == true) {
2444				// 	// 	key = checkCaptcha();
2445				// 	// 	if(!key.success) {
2446				// 	// 		$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2447				// 	// 		isSubmit = false;
2448				// 	// 	}
2449				// 	// }
2450
2451				// 	modalEmptyCheck();
2452
2453				// 	if($('.tab-pane.active .empty, .tab-pane.active .error').length > 0) {
2454				// 		$('.tab-pane.active .empty').find('input').eq(0).focus();
2455				// 		isSubmit = false;
2456				// 		return false;
2457				// 	}
2458
2459
2460				// 	resetObject(user);
2461				// 	if(isSubmit==true) {
2462				// 		$('.modal[id*=flat-modal]').modal('hide');
2463				// 		user.name = data.name = $name.val();
2464				// 		user.nameLength = nameLength;
2465				// 		user.pass = hex_md5( $pass.val() );
2466				// 		user.key = $key.val().trim();
2467				// 		setWriteUser(data,function() {
2468				// 			location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
2469				// 			// forumWrite(id,pid,reply);
2470				// 		});
2471				// 	}
2472				// },'cancel','','cl-modal cl-cmmodal cl-p130 cl-s-btn cl-close-btn w560 block-write','','',function() {
2473				// 	// loadCaptcha();
2474				// 	load_kcaptcha();
2475				// });
2476				// $('.flat-modal .modal-body').addClass('comment');
2477				// $('body').addClass('no-fixed');
2478				// if($('.flat-modal .modal-body .comment-signForm').hasClass('default-mode') || $('.flat-modal .modal-body .comment-signForm').hasClass('sitemember-mode')) 
2479				// 	$('.flat-modal .modal-footer').hide();
2480				// // $('#kcaptcha').click();
2481
2482	});
2483
2484	// $(document).on('click','.tpl-forum-write, .tpl-toolbar-question-edit',function(e) {
2485	$(document).off('click', '.tpl-toolbar-question-edit').on('click','.tpl-toolbar-question-edit',function(e) {
2486		var id = $(this).attr('data-id'),
2487			pid = $(this).attr('data-pid'),
2488			reply = $(this).attr('data-reply');
2489		try {
2490			var validType = property['VALIDTYPE'];
2491		} catch (err) {
2492			var validType = '';
2493		}
2494		
2495		id = (typeof id == 'undefined') ? '' : id;
2496		reply = (typeof reply == 'undefined') ? '' :reply;
2497
2498		var idstr = (id) ? '/m/u/id/' + id : '',
2499			replystr = (reply) ? '/reply/' + reply : '';
2500
2501		if(reply) {
2502			idstr = '';
2503			// location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
2504			// return false;
2505		}
2506		// location.href = '/post/t/' + F_MODE + idstr + '/pid/' + pid + replystr;
2507
2508		if(id && !reply) {
2509			updateForumPost(id,pid);
2510			return false;
2511		}
2512
2513		$.post('/fm/checkUser', { pid : pid, reply : reply, id : id }, function(data) {
2514			if(!data.user || typeof data.user == 'undefined') {
2515				if(typeof data.error != 'undefined' && data.error) {
2516					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
2517					return false;
2518				}
2519
2520				if (validType == 'SM') {
2521					var url = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
2522					var status = 'write';
2523
2524					var html = '<form name="write_login_form" id="write_login_form" method="post" action="/_login" style="display:none;">\
2525									<input type="hidden" name="status" value="'+status+'">\
2526									<input type="hidden" name="url" value="'+url+'">\
2527									<input type="hidden" name="pid" value="'+pid+'">\
2528									<input type="hidden" name="page_mode" value="'+data.access+'">\
2529									<input type="hidden" name="reply" value="'+reply+'">\
2530									<input type="hidden" name="id" value="'+id+'">\
2531								</form>';
2532
2533					$('body').append(html);
2534					document.write_login_form.submit();
2535					return false;
2536				}
2537
2538				var modal_str = signForm(id,pid,data.access,data.stoken);
2539				if(typeof modal_str != 'string') return false;
2540				var modal = $(this).showModalFlat($.lang[LANG]['config.postforum'],modal_str,true,true,function() {
2541
2542					var isSubmit = true;
2543					//$('.error').remove();
2544					var $name = $('#comm-name'),
2545						$pass = $('#comm-pass'),
2546						$key = $('#wr_key'),
2547						nameLength = getBytes( $name.val() );
2548
2549					$('.kcaptcha-error').remove();
2550					$('label.error').remove();
2551
2552					if( nameLength==0) {
2553						//$name.after('<label class="error">' +  $.lang[LANG]['config.enter-name'] + '</label>').focus();
2554						$name.closest('.cl-s-form-wrap').addClass('empty');
2555						$name.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.enter-name']+'</label>');
2556						isSubmit = false;
2557					}
2558					else if ( nameLength > 20 ) {
2559						//$name.after('<label class="error">' +  $.lang[LANG]['config.guest-id-max-length'] + '</label>').focus();
2560						$name.closest('.cl-s-form-wrap').addClass('empty');
2561						$name.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.guest-id-max-length']+'</label>');
2562						isSubmit = false;
2563					}
2564					if($pass.val().length<4) {
2565						//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
2566						$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
2567						$pass.closest('.cl-s-form-wrap').addClass('empty');
2568						isSubmit = false;
2569					}
2570					// if($('#recaptcha').attr('data-res')=='') {
2571					// 	$key.after('<label class="error">' +  $.lang[LANG]['config.enter-captcha'] + '</label>').focus();
2572					// 	isSubmit = false;
2573					// }
2574
2575					if($key.val().length==0) {
2576						//$key.after('<label class="error">' +  $.lang[LANG]['config.enter-captcha'] + '</label>').focus();
2577						$key.closest('.kcaptcha-box').addClass('empty');
2578						$key.closest('.kcaptcha-box').after('<label class="error kcaptcha-error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2579						isSubmit = false;
2580					}
2581
2582					if($key.val() && (Base64.encode($key.val().trim()) != md5_norobot_key)) {
2583						//$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2584						$key.closest('.kcaptcha-box').addClass('error');
2585						$key.closest('.kcaptcha-box').after('<label class="error kcaptcha-error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2586						// console.log('input value :' + $key.val());
2587						// console.log('hex_md5 : ' + Base64.encode($key.val().trim()));
2588						// console.log('key : ' + md5_norobot_key);
2589						isSubmit = false;
2590					}
2591
2592					// var key = '';
2593					// if(isSubmit == true) {
2594					// 	key = checkCaptcha();
2595					// 	if(!key.success) {
2596					// 		$key.after('<label class="error">' +  $.lang[LANG]['config.wrong-captcha'] + '</label>').focus();
2597					// 		isSubmit = false;
2598					// 	}
2599					// }
2600
2601					modalEmptyCheck();
2602
2603					if($('.tab-pane.active .empty, .tab-pane.active .error').length > 0) {
2604						$('.tab-pane.active .empty').find('input').eq(0).focus();
2605						isSubmit = false;
2606						return false;
2607					}
2608
2609
2610					resetObject(user);
2611					if(isSubmit==true) {
2612						$('.modal[id*=flat-modal]').modal('hide');
2613						user.name = data.name = $name.val();
2614						user.nameLength = nameLength;
2615						user.pass = hex_md5( $pass.val() );
2616						user.key = $key.val().trim();
2617						setWriteUser(data,function() {
2618							location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
2619							// forumWrite(id,pid,reply);
2620						});
2621					}
2622				},'cancel','','cl-modal cl-cmmodal cl-p130 cl-s-btn cl-close-btn w560 block-write','','',function() {
2623					// loadCaptcha();
2624					load_kcaptcha();
2625				});
2626				$('.flat-modal .modal-body').addClass('comment');
2627				$('body').addClass('no-fixed');
2628				if($('.flat-modal .modal-body .comment-signForm').hasClass('default-mode') || $('.flat-modal .modal-body .comment-signForm').hasClass('sitemember-mode')) 
2629					$('.flat-modal .modal-footer').hide();
2630				// $('#kcaptcha').click();
2631			} else {
2632				// resetObject(user);
2633
2634				setWriteUser(data, function() {
2635					location.href = '/post/t/' + PAGE_MODE + idstr + '/pid/' + pid + replystr;
2636					// forumWrite(id,pid,reply);
2637				});
2638			}
2639		},'json');
2640	});
2641
2642	$(document).off('click', '.tpl-forum-list').on('click','.tpl-forum-list',function(e) {
2643		// $.cookie('gallery','.' + F_PARENT.element, { path: '/' });
2644		$.cookie('forum-item',F_PARENT.pid, { path: '/' });
2645		
2646		if(PAGE_MODE != 'c') {
2647			var url = (PAGE_MODE=='s') ? '/' : '/render/',
2648				uri = (F_ONE) ? url + 'index#' + F_PARENT.page : url + F_PARENT.page;
2649
2650			var hash = uri.split('#');
2651			if(hash.length>1) {
2652				RENDER.history.pushState(null,property.TITLE,hash[0]);
2653				history.pushState('', '', hash[0] + '#' + hash[1]);
2654			} else {
2655				RENDER.history.pushState(null,property.TITLE,uri);
2656			}
2657			// (F_ONE) ? location.replace(url + '#' + F_PARENT.page) : location.replace(url + F_PARENT.page);	
2658			// (F_ONE) ? location.replace('/' + url + '/index#') + F_PARENT.page : location.replace('/' + url + '/' + F_PARENT.page);	
2659		} else {
2660			(F_ONE) ? location.replace('/'+CONFIG_URL+'config/page/index#') + F_PARENT.page : location.replace('/'+CONFIG_URL+'config/page/' + F_PARENT.page);
2661		}
2662	});
2663
2664	$(document).off('click', '.tpl-forum-delete').on('click','.tpl-forum-delete',function(e) {
2665		var id = $(this).attr('data-id');
2666		// if($('.cm-row ').length >= 1) {
2667			$.forum.delete(id);			
2668		// } else {
2669			// var modal = $(this).showModalFlat($.lang[LANG]['board.ask-permanent-delete.title'], $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
2670			// modal.modal('hide');
2671			// $.forum.delete(id);			
2672			// }, 'cancel', $.lang[LANG]['config.delete'],'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-t80 cl-modal cl-none-title cl-close-btn');
2673		// }
2674	});
2675
2676	$(document).off('click', '.tpl-forum-page').on('click','.tpl-forum-page', function(e) {
2677		e.preventDefault();
2678		if($(this).closest('.element').find('[data-loop="true"]').hasClass('sample-loop')) return false;
2679		var id = $(this).attr('data-id'),
2680			page = $(this).attr('data-page'),
2681			page_num = $(this).attr('data-page-num'),
2682			view = $(this).attr('data-view'),
2683			forum_el = $(this).closest('.element'),
2684			sfl = $.cookie('forum_' + id + '_prev_sfl') ? $.cookie('forum_' + id + '_prev_sfl') : "",
2685			stx = getForumPrevStx(id),
2686			scate = ($(forum_el).find('.search-box #scate').length > 0) ? $(forum_el).find('.search-box #scate').val() : "";
2687		
2688		var regexp = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+┼<>@\#$%&\'\"\\\(\=“‘,]/gi;
2689		if(regexp.test(stx) || regexp.test(scate)) {
2690			$(this).showModalFlat('ERROR', '특수문자를 입력할 수 없습니다.', true , false, '', 'close');
2691			return false;
2692		}
2693
2694		if($(forum_el).find('input[name="user_stx"]').length > 0 && $(forum_el).find('input[name="user_sfl"]').length > 0) {
2695			stx = $(forum_el).find('input[name="user_stx"]').val();
2696			sfl = $(forum_el).find('input[name="user_sfl"]').val();
2697		}
2698		
2699		$.forum.setForumCookie(id,page_num,stx,sfl,scate);
2700		cookie_page_num = $.cookie('forum_'+id);
2701		
2702		$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
2703		activeEL('userEL'+id);
2704	});
2705
2706	$(document).on('click','.forum-login',function(e) {
2707
2708		var forumLoginModal = $(this).closest('.modal'),
2709			id = $(this).attr('data-id'),
2710			pid = $(this).attr('data-pid'),
2711			F_SERVICE = (typeof SERVICE == 'undefined') ? property.SERVICE : SERVICE,
2712			F_VALIDTYPE = (typeof VALIDTYPE == 'undefined') ? property.VALIDTYPE : VALIDTYPE,
2713			F_SITEUM = (typeof SITEUM == 'undefined') ? property.SITEUM : SITEUM,
2714			isGabia = (F_SERVICE.indexOf('gabia') > -1) ? true : false,
2715			login_type = (isGabia || F_VALIDTYPE=='SM' || (F_VALIDTYPE=='BN' && F_SITEUM > 0)) ? 'um' : 'mb';
2716
2717		$('.comment .error').remove();
2718
2719		var $input_id = $('#'+login_type+'_forum_id'),
2720			$input_password = $('#'+login_type+'_forum_password'),
2721			isSubmit = true,
2722			idErrorTxt = (isGabia || F_VALIDTYPE=='SM' || (F_VALIDTYPE=='BN' && F_SITEUM > 0)) ? $.lang[LANG]['config.enter-id'] : $.lang[LANG]['config.enter-email'];
2723
2724		if($input_id.val().length==0) {
2725			//$input_id.after('<label class="error">! ' +  $.lang[LANG]['config.enter-id'] + '</label>').focus();
2726			//$input_id.closest('.cl-s-form-wrap').addClass('empty');
2727			$input_id.closest('.cl-s-form-wrap').addClass('empty');
2728			$input_id.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+idErrorTxt+'</label>');
2729			isSubmit = false;
2730		}
2731
2732		if($input_password.val().length==0) {
2733			//$input_password.after('<label class="error">! ' +  $.lang[LANG]['config.enter-password'] + '</label>').focus();
2734			//$input_password.closest('.cl-s-form-wrap').addClass('empty');
2735			$input_password.closest('.cl-s-form-wrap').addClass('empty');
2736			$input_password.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.enter-password']+'</label>');
2737			isSubmit = false;
2738		}
2739
2740		modalEmptyCheck();
2741
2742		if($('.tab-pane.active .empty, .tab-pane.active .error').length > 0) {
2743			$('.tab-pane.active .empty').find('input').eq(0).focus();
2744			isSubmit = false;
2745			return false;
2746		}
2747
2748		if(isSubmit) {
2749			var sid = (typeof MODE == 'undefined') ? '' : SID; //config outlogin limit
2750			var login_success_fnc = function() {
2751				$('button.close').click();
2752				if(RELOAD) {
2753					// $.cookie('gallery','.' + F_PARENT.element, { path: '/' });
2754					location.reload();
2755				}
2756				if(typeof MODE == 'undefined') RENDER.setLoginout(property.LOGINOUT, property.SID, 1, property.PROFILEIMG);
2757				//forumWrite(id,pid);
2758			}
2759
2760			if(login_type == 'mb') {
2761				$.post('/member/login/outlogin', { mb_id : $input_id.val(), mb_password : $input_password.val(), sid : sid}, function(data) {
2762					if(typeof data.error != 'undefined' && data.error) {
2763						$('.tab-pane.active').find('.bottom-box.text-right').before('<label class="error text-center error_login"><svg viewBox="0 0 13 13" width="13" height="13">
2763<path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg><span>' + data.error + '</span></label>');
2764						$('.cl-s-form-group input').val('');
2765						$('.tab-pane.active').find('.cl-s-form-wrap').addClass('empty');
2766						return false;
2767					}
2768					login_success_fnc();
2769				}, 'json');
2770
2771			} else {
2772
2773				var input_data = {
2774					'id' : $input_id.val().toLowerCase(),
2775					'password' : hex_md5($input_password.val()),
2776				};
2777
2778				$.post('/umember/login/in', { sid : sid, data : JSON.stringify(input_data) }, function(data) {
2779
2780					if (typeof data.result != 'undefined' && data.result == 'fail') {
2781						alert(data.message);
2782						return false;
2783					} else {
2784						$.umember.init();
2785						login_success_fnc();
2786
2787						if(typeof data.result != 'undefined' && data.result == 'success') {
2788							if(typeof data.ss_url != 'undefined' && data.ss_url) {
2789								$.each(data.ss_url, function(i,url) {
2790									$('.dsgn-body').after('<img class="auth-img" src="' + ss_url + '">');
2791								});
2792							}
2793
2794							if(typeof data.ga_uid != 'undefined' && data.ga_uid) {
2795								localStorage.setItem('googleAnalyticsUID'+sid, data.ga_uid);
2796							}
2797						}
2798					}
2799					/*
2800					if(typeof data.error != 'undefined' && data.error) {
2801						$.each(data.error, function(key,str) {
2802							if(forumLoginModal.find('#um_forum_'+key).length > 0 ) {
2803								forumLoginModal.find('#um_forum_'+key).after('<span class="error">' + str + '</span>');
2804							} else { 
2805								$('.comment-signForm').after("<label class='error text-center'>" + str + "</label>"); 
2806							}
2807						});
2808						if(forumLoginModal.find('.error').length > 0) return false;
2809					}
2810
2811					$.umember.init();
2812					login_success_fnc();
2813
2814					if(data.member.check_login) {
2815						if(typeof data.ss_url != 'undefined' && data.ss_url) {
2816							$.each(data.ss_url, function(i,url) {
2817								$('.dsgn-body').after('<img class="auth-img" src="' + ss_url + '">');
2818							});
2819						}
2820					}
2821					*/					
2822
2823				},'json');
2824
2825			}
2826		}
2827	});	
2828
2829	$doc.off('click', '[data-loop]:not(.sample-loop) .tpl-forum-list-name:not(.namemask)')
2830		.on('click', '[data-loop]:not(.sample-loop) .tpl-forum-list-name:not(.namemask)', function(e){
2831		e.stopPropagation();
2832		
2833		var parentEl = $(this).parents('.element');
2834		if(parentEl.attr('data-type') != 'forum' || parentEl.attr('data-type2') == 'guestbook') return false;
2835
2836		var userid = ($(this).attr('data-userid') !== undefined)? $(this).attr('data-userid') : '';
2837		var username = $(this).contents().filter(function() {
2838					return this.nodeType === 3; // 텍스트 노드만 선택
2839				}).text().trim();
2840		var langClass = (LANG == 'ko')? 'ko':'en';
2841		// console.log(userid);
2842		if($(this).hasClass('search-on')) {
2843			$('.tpl-forum-list-name').removeClass('search-on');
2844			$('.search-forum-user-posts').remove();
2845		} else {
2846			$('.tpl-forum-list-name').removeClass('search-on');
2847			$('.search-forum-user-posts').remove();
2848			$(this).addClass('search-on');
2849			var searchBox = '<div class="search-forum-user-posts tpl-forum-list-etc '+langClass+'" data-userid="'+userid+'" data-username="'+username+'"><span>'+$.lang[LANG]['board.search.user.posts']+'</span></div>';
2850
2851			var text = $(this).text().trim();
2852			var fontSize = parseFloat($(this).css("font-size"));
2853			
2854			var span = $('<span>').css({
2855				'display': 'inline-block',
2856				'font-family': $(this).css('font-family'),
2857				'font-size': fontSize + 'px',
2858				'font-weight': $(this).css('font-weight'),
2859				'visibility': 'hidden'
2860			}).text(text);
2861
2862			// 가상 요소를 body에 추가한 후, 너비를 가져오기
2863			$('body').append(span);
2864			var textWidth = parseFloat(span.width());
2865			// 가상 요소 삭제하기
2866			span.remove();
2867
2868			var textHeight = parseFloat($(this).css("line-height"));
2869			var height = $(this)[0].getBoundingClientRect().height;
2870			var width = $(this)[0].getBoundingClientRect().width;
2871			var translateX = (langClass == 'en')? 61 : 46;
2872
2873			var offset = $(this).offset();
2874			var parentOffset = parentEl.offset();
2875			var paddingTop = (height - $(this).height()) * 0.5;
2876			var paddingLeft = ($(this).is('td') || $(this).css('text-align') == 'center')? (width - textWidth) * 0.5 : (width - $(this).width()) * 0.5;
2877			if($(this).css('text-align') == 'right') paddingLeft = width - textWidth;
2878			if(paddingTop < 0) paddingTop = 0;
2879			if(paddingLeft < 0) paddingLeft = 0;
2880			
2881			var top = offset.top - parentOffset.top + paddingTop + textHeight + 5;
2882			var left = ($('.dsgn-body').hasClass('sidebar'))? offset.left + paddingLeft + textWidth*0.5 - parentOffset.left - translateX : offset.left + paddingLeft + textWidth*0.5 - translateX;
2883			// console.log(offset, parentOffset);
2884			parentEl.append(searchBox);
2885			$('.search-forum-user-posts').css({'top': top, 'left': left});
2886
2887			var $searchBtn = $('.search-forum-user-posts');
2888			if($('.dsgn-body').hasClass('sidebar')) {
2889				if($searchBtn.offset().left < parentOffset.left) {
2890					left = 0;
2891					$searchBtn.css({'top': top, 'left': left});
2892				}
2893			} else {
2894				if($searchBtn.offset().left < 0) {
2895					left -= $searchBtn.offset().left;
2896					$searchBtn.css({'top': top, 'left': left});
2897				}
2898			}
2899			if($('header .navbar-toggle').css('display') == 'block' && ($searchBtn.offset().left + $searchBtn.width() > $('.dsgn-body').width())) {
2900				left = $('.dsgn-body').width() - $searchBtn.width();
2901				$searchBtn.css({'top': top, 'left': left});
2902			}
2903		}
2904	});
2905
2906	$(document).on('click','.forum-type-btn',function(e) {
2907		if($(this).parents('.element').attr('data-type') != 'forum') return false;
2908		e.preventDefault();
2909
2910		var dataCheck =  ($(this).parents('.element').find('.tpl-forum-pagination').children().length > 0) ? true :  false;
2911		var typeCheck = $(this).attr('data-type'),
2912			$elementCheck = $(this).parents('.element');
2913
2914		if($elementCheck.attr('data-list-type') == typeCheck) return false;
2915		
2916		$this_pagination = $(this).parents('.element').find('.tpl-forum-pagination li.active');
2917		var data_sfl = $(this).parents('.search-box').find('#sfl').val(),
2918			data_stx = '',
2919			data_scate = ($(this).parents('.search-box').find('#scate option:selected').length > 0) ? $(this).parents('.search-box').find('#scate option:selected').val() : '',
2920			id = (dataCheck) ? $this_pagination.attr('data-id') : $(this).parents('.element').attr('data-id'),
2921			page = (dataCheck) ? $this_pagination.attr('data-page') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-page'),
2922			data_page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
2923			view = (dataCheck) ? $this_pagination.attr('data-view') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-view');
2924		
2925		var F_PARENT = (typeof PARENT == 'undefined') ? property.PARENT : PARENT;
2926			F_ONE = (typeof ONE == 'undefined') ? property.ONE : ONE;
2927			F_SID = (typeof SID == 'undefined') ? property.SID : SID;
2928			F_PAGE = (typeof PAGE == 'undefined') ? property.PAGE : PAGE;
2929
2930		var page_num = (typeof data_page_num != 'undefined' && data_page_num) ? data_page_num : -1,
2931			sfl = (typeof data_sfl == 'undefined') ? 'all' : data_sfl, 
2932			stx = (typeof data_stx == 'undefined') ? '' : data_stx,
2933			scate = (typeof data_scate == 'undefined') ? '' : data_scate;
2934
2935			if(page_num < 0) {
2936				page_num = (typeof $.cookie('forum_'+id) != 'undefined' && $.cookie('forum_'+id)) ? $.cookie('forum_'+id) : 1;
2937				$.removeCookie('forum_'+id,{path:'/'});
2938			}
2939			if(!stx) stx = getForumPrevStx(id);
2940			if(sfl=='all' && typeof $.cookie('forum_'+id+'_sfl') != 'undefined') sfl = $.cookie('forum_'+id+'_sfl');
2941			if(!scate && typeof $.cookie('forum_'+id+'_scate') != 'undefined') scate = $.cookie('forum_'+id+'_scate');
2942			$.forum.setForumCookie(id,page_num,stx,sfl,scate);
2943			cookie_page_num = $.cookie('forum_'+id);
2944			$.cookie('forum_'+id+'_type', typeCheck);
2945
2946			$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
2947			activeEL('userEL'+id);
2948
2949			// fmID = id;
2950   //          $.ajax({
2951   //              url: '/fm/lists/pid/' + id + '/sid/' + F_SID + '/page/' + F_PAGE + '/view/' + view + '/page_num/' + page_num,
2952   //              dataType: 'json',
2953   //              type: 'POST',
2954   //              data: { sfl: sfl, stx: stx, scate: scate},
2955   //              async: false,
2956   //              cache: false,
2957   //              success: function (data) {
2958   //              	if(typeof data.error != 'undefined' && data.error) {
2959   //              		$(this).showModalFlat('ERROR', data.error, true , false, '', 'close');
2960   //              		return false;
2961   //              	}
2962			// 		displayTypeForum(data,$elementCheck,typeCheck,view,page_num,id);
2963   //      		}
2964
2965   //          });
2966	});
2967
2968	$('.tpl-forum-my').live('click', function(e) {
2969		if($(this).parents('.element').attr('data-type') != 'forum') return false;
2970		e.preventDefault();
2971		var dataCheck =  ($(this).parents('.element').find('.tpl-forum-pagination').children().length > 0) ? true :  false;
2972		
2973		$this_pagination = $(this).parents('.element').find('.tpl-forum-pagination li.active');
2974		var umember = (PAGE_MODE == 'c') ? UMEMBER : property.UMEMBER,
2975			sfl ='mb_id',
2976			stx = umember.id,
2977			scate = ($(this).parents('.search-box').find('#scate option:selected').length > 0) ? $(this).parents('.search-box').find('#scate option:selected').val() : '',
2978			id = (dataCheck) ? $this_pagination.attr('data-id') : $(this).parents('.element').attr('data-id'),
2979			page = (dataCheck) ? $this_pagination.attr('data-page') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-page'),
2980			page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
2981			view = (dataCheck) ? $this_pagination.attr('data-view') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-view');
2982
2983    	$.forum.setForumCookie(id,page_num,stx,sfl,scate);
2984		cookie_page_num = $.cookie('forum_'+id);
2985		$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
2986		activeEL('userEL'+id);
2987	});
2988
2989	$.forum = {
2990		modoo_loop_card : `
2991			<div class="table" data-loop="true">
2992				<div class="col-xs-12 col-sm-6 col-md-4 item">
2993	                <div class="item-inner op_itemline10">
2994	                    <div class="thumb-wrap">
2995	                        <div class="tpl-forum-list-thumb">
2996	                            <img src="//storage.googleapis.com/i.addblock.net/sample/forum_thumb_4_1.jpg" class="img-responsive">
2997	                        </div>
2998	                        <div class="tpl-forum-list-num"><i class="tpl-forum-list-notice-icon cl-icon notice01" aria-hidden="true"></i></div>
2999	                    </div>
3000	                    <div class="cont-wrap">
3001	                        <div class="tpl-forum-list-content">
3002	                            <span class="tpl-forum-list-title" data-selector=".tpl-forum-list-title" data-font="true" data-title="title font">작업의 페이지 및 모든 프로세스에 대해 궁금한 점, 질문 드립니다.</span>
3003	                        </div>
3004	                        <div class="tpl-forum-list-cont" data-selector=".tpl-forum-list-cont" data-font="true" data-title="content font">항상 배우는 마음으로 보고 있습니다. 이번 프로젝트도 꼭 따라해보고 싶어요. 프로젝트를 보면서 디자인에 궁금한 점이 있습니다. 프로젝트 작업하실 때 주로 어디서 영감을 얻으시나요?</div>
3005	                        <ul>
3006	                            <div>
3007	                            <li class="tpl-forum-list-name tpl-forum-list-etc">데이비드 제임스</li>
3008	                            <li class="tpl-forum-list-date tpl-forum-list-etc">방금 전</li>
3009	                            </div>
3010	                            <div>
3011	                            <li class="tpl-forum-list-comment tpl-forum-list-etc">25</li>
3012	                            </div>
3013	                        </ul>
3014	                        <ul>
3015	                            <li class="tpl-forum-list-category tpl-forum-list-etc">카테고리</li>
3016	                            <li class="tpl-forum-list-hit tpl-forum-list-etc">1486</li>
3017	                            <li class="tpl-forum-list-like tpl-forum-list-etc hidden"><svg viewBox="0 0 28 28" width="28" height="28"><path d="m22.76 14.7-8.74 8.97-8.75-8.97m0 0c-2.31-2.32-2.37-6.14-.13-8.53 2.24-2.4 5.93-2.46 8.24-.14.23.23.44.48.63.75 1.93-2.67 5.59-3.2 8.16-1.2s3.09 5.79 1.16 8.45c-.18.24-.37.47-.58.68"></path><path d="M14.01 24.57c-.24 0-.48-.1-.64-.27l-8.74-8.97c-2.64-2.66-2.71-7.04-.15-9.78a6.576 6.576 0 0 1 4.74-2.12c1.79-.01 3.5.67 4.8 1.96a6.576 6.576 0 0 1 3.74-1.86c1.77-.25 3.54.22 4.97 1.34 2.95 2.29 3.55 6.64 1.33 9.69-.2.28-.42.54-.66.78l-.06.06-8.68 8.9c-.17.17-.4.27-.65.27zm-8.1-10.51c0 .01.01.01 0 0l8.1 8.32 8.1-8.31.06-.06c.15-.16.3-.33.43-.52 1.65-2.27 1.21-5.51-.98-7.22a4.723 4.723 0 0 0-3.61-.97c-1.31.2-2.47.91-3.27 2a.91.91 0 0 1-.73.37c-.29 0-.56-.14-.73-.38-.16-.22-.34-.44-.54-.64a4.78 4.78 0 0 0-3.49-1.43A4.83 4.83 0 0 0 5.8 6.78c-1.91 2.04-1.86 5.31.11 7.28z"></path></svg><span class="forum-like-cnt">0</span></li>
3018	                        </ul>
3019	                    </div>
3020	                </div>
3021	            </div>
3022            </div>
3023		`,
3024		modoo_loop_list : `
3025			<table class="table">
3026				<thead>
3027					<tr class="thead-bottom-line tpl-forum-header-row" data-selector=".tpl-forum-header-row" data-font="true" data-title="header row font">
3028						<th class="ntpl-forum-num tpl-forum-num tpl-forum-header-row">no</th>
3029						<th class="ntpl-forum-category tpl-forum-category tpl-forum-header-row">카테고리</th>
3030						<th class="ntpl-forum-content tpl-forum-content tpl-forum-header-row">제목</th>
3031						<th class="ntpl-forum-name tpl-forum-name tpl-forum-header-row">작성자</th>
3032						<th class="ntpl-forum-date tpl-forum-date tpl-forum-header-row">작성일</th>
3033						<th class="ntpl-forum-hit tpl-forum-hit tpl-forum-header-row">조회수</th>
3034						<th class="ntpl-forum-like tpl-forum-like tpl-forum-header-row">좋아요</th>
3035					</tr>
3036				</thead>
3037				<tbody data-loop="true">
3038					<tr class="op_itemline10">
3039						<td scope="row" class="tpl-forum-list-num tpl-forum-list-etc config-font-etc" data-selector=".tpl-forum-list-etc" data-font="true" data-title="others"><i class="tpl-forum-list-notice-icon cl-icon notice01" aria-hidden="true"></i></td>
3040						<td class="tpl-forum-list-category tpl-forum-list-etc config-font-etc">카테고리</td>
3041						<td class="tpl-forum-list-content" data-selector=".tpl-forum-list-content" data-font="true" data-title="title font"><span class="tpl-forum-list-title">작업의 페이지 및 모든 프로세스에 대해 궁금한 점, 질문 드립니다.</span> <span class="tpl-forum-list-comment"><i class="fa fa-comment-o tpl-forum-list-comment-icon"></i> <span class="forum-comment-cnt">7</span></span></td>
3042						<td class="tpl-forum-list-name tpl-forum-list-etc config-font-etc">작성자</td>
3043						<td class="tpl-forum-list-date tpl-forum-list-etc config-font-etc">방금 전</td>
3044						<td class="tpl-forum-list-hit tpl-forum-list-etc config-font-etc">50</td>
3045						<td class="tpl-forum-list-like tpl-forum-list-etc config-font-etc" data-selector=".tpl-forum-list-like" data-font="true" data-title="like">0</td>
3046					</tr>
3047				</tbody>
3048			</table>
3049		`,
3050		init : function(id, page, view, page_num, sfl, stx, scate) {
3051			F_PARENT = (typeof PARENT == 'undefined') ? property.PARENT : PARENT;
3052			F_ONE = (typeof ONE == 'undefined') ? property.ONE : ONE;
3053			F_SID = (typeof SID == 'undefined') ? property.SID : SID;
3054			F_PAGE = (typeof PAGE == 'undefined') ? property.PAGE : PAGE;
3055
3056			// var page_num = (typeof page_num == 'undefined' || page_num == 'NaN') ? 1 : page_num,
3057			var page_num = (typeof page_num != 'undefined' && page_num) ? page_num : -1,
3058				sfl = (typeof sfl == 'undefined') ? 'all' : sfl, 
3059				stx = (typeof stx == 'undefined') ? '' : stx,
3060				scate = (typeof scate == 'undefined') ? '' : scate;
3061
3062			if(page_num < 0) {
3063				page_num = (typeof $.cookie('forum_'+id) != 'undefined' && $.cookie('forum_'+id)) ? $.cookie('forum_'+id) : 1;
3064				$.removeCookie('forum_'+id,{path:'/'});
3065				$.removeCookie('forum_'+id+'_type');
3066			}
3067
3068			if(!stx) stx = getForumPrevStx(id);
3069			if(sfl=='all' && typeof $.cookie('forum_'+id+'_sfl') != 'undefined') sfl = $.cookie('forum_'+id+'_sfl');
3070			if(!scate && typeof $.cookie('forum_'+id+'_scate') != 'undefined') scate = $.cookie('forum_'+id+'_scate');
3071			$.forum.setForumCookie(id,page_num,stx,sfl,scate);
3072			
3073			fmID = id;
3074            $.ajax({
3075                url: '/fm/lists/pid/' + id + '/sid/' + F_SID + '/page/' + F_PAGE + '/view/' + view + '/page_num/' + page_num,
3076                dataType: 'json',
3077                type: 'POST',
3078                data: { sfl: sfl, stx: stx, scate: scate},
3079                async: false,
3080                cache: false,
3081                success: function (data) {
3082                	if(typeof data.error != 'undefined' && data.error) {
3083                		$(this).showModalFlat('ERROR', data.error, true , false, '', 'close');
3084                		return false;
3085                	}
3086
3087					$.forum.set(id,page_num,view,F_PAGE,sfl,stx,scate,data);
3088                }
3089            });
3090		},
3091		update_ver1 : function(id,page_num,view,page,sfl,stx,scate,data) {
3092			var modoo_login_check;
3093        	var source = (typeof data.source == 'undefined') ? '' : data.source;
3094        	var $source = $(htmlspecialchars_decode(source)),
3095        		type = (typeof $source.attr('data-forum-type') == 'undefined' || !$source.attr('data-forum-type')) ? '' : $source.attr('data-forum-type'),
3096	        	elsetting = (typeof data.elsettings != 'undefined' && data.elsettings) ? $.parseJSON(data.elsettings) : {};
3097
3098        	if(elsetting.forum_type == 'modoo') {
3099        		//모두 게시판 source 교체
3100				var $loopElement,
3101					data_view = $source.find('[data-loop="true"]').attr('data-view');
3102				if(typeof $.cookie('forum_'+id+'_type') != 'undefined' && $.cookie('forum_'+id+'_type') == 'card' ||
3103					typeof $.cookie('forum_'+id+'_type') == 'undefined' && $source.attr('data-list-type') == 'card') {
3104					$loopElement = $source.clone();
3105					$loopElement.find('.table-container').empty().append($.forum.modoo_loop_card);
3106					$loopElement.find('[data-loop="true"]').attr('data-view',data_view);
3107					$source = $loopElement;
3108					type = 'thumb';
3109				} else {
3110					if(typeof $.cookie('forum_'+id+'_type') != 'undefined' && $.cookie('forum_'+id+'_type') == 'list' && $source.find('table.table').length < 1) {
3111						$loopElement = $source.clone();
3112						$loopElement.find('.table-container').empty().append($.forum.modoo_loop_list);
3113						$loopElement.find('[data-loop="true"]').attr('data-view',data_view);
3114						$source = $loopElement;
3115					}
3116				}
3117				$source.find('.forum-title').empty().text(elsetting.forum_block_title);
3118				modoo_login_check = (PAGE_MODE != 'c') ? property.UMEMBER.check_login : true;
3119
3120				if(!modoo_login_check) $source.find('.tpl-forum-my').css('visibility','hidden');
3121			}
3122
3123        	var $first = (type == 'qna') ? $source.find('[data-loop="true"]').children('.qna-item').eq(0).clone() : $source.find('[data-loop="true"]').children().eq(0).clone(),
3124        		F_SID = (typeof SID == 'undefined') ? property.SID : SID,
3125	        	F_VALIDPLAN = (typeof VALIDPLAN == 'undefined') ? property.VALIDPLAN : VALIDPLAN,
3126	        	F_VALIDTYPE = (typeof VALIDTYPE == 'undefined') ? property.VALIDTYPE : VALIDTYPE;
3127        	var field_lang = (typeof elsetting.field_lang != 'undefined') ? elsetting.field_lang : (typeof elsetting.blocklang != 'undefined' && elsetting.blocklang ? elsetting.blocklang : LANG);
3128        	var is_templates = checkTemplateSite(F_SID);
3129        	if($.inArray(type, ['qna', 'faq', 'guestbook']) == -1 && F_VALIDPLAN && $first.find('.tpl-forum-list-like').length == 0) {
3130				if((elsetting.like_display != undefined && elsetting.like_display == 'ON') || (elsetting.likeComment_display != undefined && elsetting.likeComment_display == 'ON')) {
3131					if($source.find('table').length > 0) { //table
3132						if($source.find('thead').length > 0) { //thead
3133							$source.find('thead tr').append('<th class="ntpl-forum-like tpl-forum-like tpl-forum-header-row op_itemline10 hidden" width="100">'+$.lang[field_lang.toLowerCase()]['forum.field.tpl-forum-like']+'</th>');
3134		        			$first.append('<td class="tpl-forum-list-like tpl-forum-list-etc old-fm op_itemline10" data-selector=".tpl-forum-list-like" data-font="true" data-title="like">0</td>');
3135		        			if(data.total == 0) {
3136		        				$source.find('tbody tr').append('<td class="tpl-forum-list-like tpl-forum-list-etc old-fm op_itemline10" data-selector=".tpl-forum-list-like" data-font="true" data-title="like">0</td>');
3137		        			}
3138		        		} else {
3139		        			$first.append('<td class="tpl-forum-list-like tpl-forum-list-etc old-fm op_itemline10" data-selector=".tpl-forum-list-like" data-font="true" data-title="like">0</td>');
3140		        			if(data.total == 0) {
3141		        				$source.find('tbody tr').append('<td class="tpl-forum-list-like tpl-forum-list-etc old-fm op_itemline10" data-selector=".tpl-forum-list-like" data-font="true" data-title="like">0</td>');
3142		        			}
3143		        		}
3144					} else {
3145						if(data.total == 0) {
3146							$source.find('.item ul').each(function(idx, v){
3147								if($(v).find('.tpl-forum-list-like').length > 0) return true;
3148								if(idx == 0) $(v).append('<li class="tpl-forum-list-like tpl-forum-list-etc old-fm" data-selector=".tpl-forum-list-like" data-font="true" data-title="like"><svg viewBox="0 0 28 28" width="28" height="28"><path d="m22.76 14.7-8.74 8.97-8.75-8.97m0 0c-2.31-2.32-2.37-6.14-.13-8.53 2.24-2.4 5.93-2.46 8.24-.14.23.23.44.48.63.75 1.93-2.67 5.59-3.2 8.16-1.2s3.09 5.79 1.16 8.45c-.18.24-.37.47-.58.68"></path><path d="M14.01 24.57c-.24 0-.48-.1-.64-.27l-8.74-8.97c-2.64-2.66-2.71-7.04-.15-9.78a6.576 6.576 0 0 1 4.74-2.12c1.79-.01 3.5.67 4.8 1.96a6.576 6.576 0 0 1 3.74-1.86c1.77-.25 3.54.22 4.97 1.34 2.95 2.29 3.55 6.64 1.33 9.69-.2.28-.42.54-.66.78l-.06.06-8.68 8.9c-.17.17-.4.27-.65.27zm-8.1-10.51c0 .01.01.01 0 0l8.1 8.32 8.1-8.31.06-.06c.15-.16.3-.33.43-.52 1.65-2.27 1.21-5.51-.98-7.22a4.723 4.723 0 0 0-3.61-.97c-1.31.2-2.47.91-3.27 2a.91.91 0 0 1-.73.37c-.29 0-.56-.14-.73-.38-.16-.22-.34-.44-.54-.64a4.78 4.78 0 0 0-3.49-1.43A4.83 4.83 0 0 0 5.8 6.78c-1.91 2.04-1.86 5.31.11 7.28z"></path></svg><span class="forum-like-cnt">0</span></li>');
3149								else $(v).append('<li class="tpl-forum-list-like tpl-forum-list-etc old-fm"><svg viewBox="0 0 28 28" width="28" height="28"><path d="m22.76 14.7-8.74 8.97-8.75-8.97m0 0c-2.31-2.32-2.37-6.14-.13-8.53 2.24-2.4 5.93-2.46 8.24-.14.23.23.44.48.63.75 1.93-2.67 5.59-3.2 8.16-1.2s3.09 5.79 1.16 8.45c-.18.24-.37.47-.58.68"></path><path d="M14.01 24.57c-.24 0-.48-.1-.64-.27l-8.74-8.97c-2.64-2.66-2.71-7.04-.15-9.78a6.576 6.576 0 0 1 4.74-2.12c1.79-.01 3.5.67 4.8 1.96a6.576 6.576 0 0 1 3.74-1.86c1.77-.25 3.54.22 4.97 1.34 2.95 2.29 3.55 6.64 1.33 9.69-.2.28-.42.54-.66.78l-.06.06-8.68 8.9c-.17.17-.4.27-.65.27zm-8.1-10.51c0 .01.01.01 0 0l8.1 8.32 8.1-8.31.06-.06c.15-.16.3-.33.43-.52 1.65-2.27 1.21-5.51-.98-7.22a4.723 4.723 0 0 0-3.61-.97c-1.31.2-2.47.91-3.27 2a.91.91 0 0 1-.73.37c-.29 0-.56-.14-.73-.38-.16-.22-.34-.44-.54-.64a4.78 4.78 0 0 0-3.49-1.43A4.83 4.83 0 0 0 5.8 6.78c-1.91 2.04-1.86 5.31.11 7.28z"></path></svg><span class="forum-like-cnt">0</span></li>');
3150							});
3151
3152							$source.find('.b_txt ul').each(function(idx, v){
3153								if($(v).find('.tpl-forum-list-like').length > 0) return true;
3154								if(idx == 0) $(v).append('<li class="tpl-forum-list-like tpl-forum-list-etc old-fm" data-selector=".tpl-forum-list-like" data-font="true" data-title="like"><svg viewBox="0 0 28 28" width="28" height="28"><path d="m22.76 14.7-8.74 8.97-8.75-8.97m0 0c-2.31-2.32-2.37-6.14-.13-8.53 2.24-2.4 5.93-2.46 8.24-.14.23.23.44.48.63.75 1.93-2.67 5.59-3.2 8.16-1.2s3.09 5.79 1.16 8.45c-.18.24-.37.47-.58.68"></path><path d="M14.01 24.57c-.24 0-.48-.1-.64-.27l-8.74-8.97c-2.64-2.66-2.71-7.04-.15-9.78a6.576 6.576 0 0 1 4.74-2.12c1.79-.01 3.5.67 4.8 1.96a6.576 6.576 0 0 1 3.74-1.86c1.77-.25 3.54.22 4.97 1.34 2.95 2.29 3.55 6.64 1.33 9.69-.2.28-.42.54-.66.78l-.06.06-8.68 8.9c-.17.17-.4.27-.65.27zm-8.1-10.51c0 .01.01.01 0 0l8.1 8.32 8.1-8.31.06-.06c.15-.16.3-.33.43-.52 1.65-2.27 1.21-5.51-.98-7.22a4.723 4.723 0 0 0-3.61-.97c-1.31.2-2.47.91-3.27 2a.91.91 0 0 1-.73.37c-.29 0-.56-.14-.73-.38-.16-.22-.34-.44-.54-.64a4.78 4.78 0 0 0-3.49-1.43A4.83 4.83 0 0 0 5.8 6.78c-1.91 2.04-1.86 5.31.11 7.28z"></path></svg><span class="forum-like-cnt">0</span></li>');
3155								else $(v).append('<li class="tpl-forum-list-like tpl-forum-list-etc old-fm"><svg viewBox="0 0 28 28" width="28" height="28"><path d="m22.76 14.7-8.74 8.97-8.75-8.97m0 0c-2.31-2.32-2.37-6.14-.13-8.53 2.24-2.4 5.93-2.46 8.24-.14.23.23.44.48.63.75 1.93-2.67 5.59-3.2 8.16-1.2s3.09 5.79 1.16 8.45c-.18.24-.37.47-.58.68"></path><path d="M14.01 24.57c-.24 0-.48-.1-.64-.27l-8.74-8.97c-2.64-2.66-2.71-7.04-.15-9.78a6.576 6.576 0 0 1 4.74-2.12c1.79-.01 3.5.67 4.8 1.96a6.576 6.576 0 0 1 3.74-1.86c1.77-.25 3.54.22 4.97 1.34 2.95 2.29 3.55 6.64 1.33 9.69-.2.28-.42.54-.66.78l-.06.06-8.68 8.9c-.17.17-.4.27-.65.27zm-8.1-10.51c0 .01.01.01 0 0l8.1 8.32 8.1-8.31.06-.06c.15-.16.3-.33.43-.52 1.65-2.27 1.21-5.51-.98-7.22a4.723 4.723 0 0 0-3.61-.97c-1.31.2-2.47.91-3.27 2a.91.91 0 0 1-.73.37c-.29 0-.56-.14-.73-.38-.16-.22-.34-.44-.54-.64a4.78 4.78 0 0 0-3.49-1.43A4.83 4.83 0 0 0 5.8 6.78c-1.91 2.04-1.86 5.31.11 7.28z"></path></svg><span class="forum-like-cnt">0</span></li>');
3156							});
3157						}
3158					}
3159				}
3160			}
3161
3162        	var first_html = $first.prop('outerHTML'),
3163        		$bbs = $('.element[data-id="' + id + '"]');
3164
3165        	var d = document.createElement('div');
3166        	$(d).html(first_html);
3167
3168			$source.find('thead tr th').each(function() {
3169				var field_text = (typeof $(this).attr('class') != 'undefined') ? $(this).attr('class') : 'tpl-forum-title';
3170				if(field_text.indexOf('ntpl') > -1) field_text = field_text.split(' ')[1];  //게시판 폰트설정 -  기존, 새 코드 블럭 구분
3171
3172				if(field_text.indexOf('title') > -1 || field_text.indexOf('content') > -1) $(this).text($.lang[field_lang.toLowerCase()]['forum.field.tpl-forum-title']);
3173				else $(this).text($.lang[field_lang.toLowerCase()]['forum.field.' + field_text]);
3174				if($source.find('.tpl-forum-num').hasClass('num-ko') && field_text.indexOf('num') > -1) $(this).text($.lang[field_lang.toLowerCase()]['forum.field.' + field_text +'.ko']);
3175			});
3176
3177			if($source.find('tr.tpl-forum-header-row').length > 0) {
3178				var checkHeaderOnlyTitle = ($source.find('tr.tpl-forum-header-row th:not(.hide)').length === 1) ? true : false;
3179				if(checkHeaderOnlyTitle) $source.find('tr.tpl-forum-header-row').addClass('hide');
3180				else $source.find('tr.tpl-forum-header-row').removeClass('hide');
3181			}
3182			var answer	= (type == 'qna') ? $source.find('[data-loop="true"]').children('.qna-details').eq(0).clone().prop('outerHTML') : '';
3183
3184			var loop = $(d).html() + '\
3185    				'+ answer;
3186    		$(d).remove();
3187        	$bbs.html($source.html());
3188
3189        	var	$row = $bbs.find('[data-loop="true"]'),
3190        		$pagination = $bbs.find('.tpl-forum-pagination'),
3191        		$write = $bbs.find('.tpl-forum-write').attr('data-pid',id),
3192        		css_id = $bbs.attr('data-el'),
3193        		block_lang = ($bbs.attr('data-blocklang')) ? $bbs.attr('data-blocklang') : LANG;
3194
3195        	var data_el = $bbs.attr('data-el');
3196
3197        	if(data.total > 0) {
3198				$bbs.find('[data-loop="true"]').removeClass('sample-loop');
3199           		$row.html('');
3200
3201				if(typeof elsetting.forum_type !== "undefined" && elsetting.forum_type == "modoo") {
3202					var typeCookieCheck;
3203					if(typeof $.cookie('forum_'+id+'_type') == 'undefined') typeCookieCheck = $source.attr('data-list-type');
3204						else typeCookieCheck = $.cookie('forum_'+id+'_type');
3205						
3206		    		if(typeCookieCheck == 'list') {
3207		    			$bbs.attr('data-list-type','list');
3208		    			$bbs.attr('data-msny', false);
3209		    		} else if(typeCookieCheck == 'card') {
3210		    			$bbs.attr('data-list-type','card');
3211		    			$bbs.attr('data-msny', true);
3212		    		}
3213				}
3214
3215                // if(typeof elsetting.forum_type !== "undefined" && elsetting.forum_type == "modoo") {
3216                //     if($source.attr('data-list-type') == 'card') {
3217                //         displayTypeForum(data,$source,'card',view,page_num,id);
3218                //         return false;
3219                //     }
3220                // }
3221
3222				if(data.total<=((view*page_num)-view)) {
3223					page_num = page_num-1;
3224					if(page_num==0) page_num=1;
3225				}
3226
3227        		$.each(data.list, function(i,v) {
3228        			var num = data.total - (view * (page_num-1)) - i;
3229					$row.append(forumRow(v, num, page_num, id, loop, data.config, type, $source));
3230        		});
3231
3232			}
3233
3234        	var field_disable = getOrDefault(elsetting,'field_disable',[]),
3235				check_faq = (type == 'faq' && $(d).find('.tpl-forum-list-content .inner-box').length > 0) ? true : false;
3236        	if(check_faq) {
3237        		if($.inArray('name',field_disable) > -1 && $.inArray('date',field_disable) > -1) {
3238					$bbs.find('[data-loop="true"] .tpl-forum-list-name').removeClass('removeBar');
3239				} else if($.inArray('date',field_disable) > -1) {
3240					$bbs.find('[data-loop="true"] .tpl-forum-list-name').addClass('removeBar');
3241				}
3242			}
3243
3244		},
3245		view : function(id) {
3246		    var deferred = $.Deferred();
3247			F_PARENT = (typeof PARENT == 'undefined') ? property.PARENT : PARENT;
3248			F_ONE = (typeof ONE == 'undefined') ? property.ONE : ONE;
3249			F_SID = (typeof SID == 'undefined') ? property.SID : SID;
3250			F_PAGE = (typeof PAGE == 'undefined') ? property.PAGE : PAGE;
3251			F_VIEW = id;
3252
3253			var ps_forumview = forumView(id);
3254			ps_forumview.done(function(data) {
3255				setForumWrap();
3256				if(typeof MODE != 'undefined' && (MODE=='config' || MODE=='demo')) displayComment(data);
3257
3258				deferred.resolve(data);
3259			}).fail(function(error_msg) {
3260				deferred.reject(error_msg);
3261
3262				if(error_msg == 404) show404();
3263			});
3264
3265		    return deferred.promise();
3266		},
3267		delete : function(id) {
3268			$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
3269				if(typeof data.error != 'undefined' && data.error) {
3270					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
3271					return false;
3272				}
3273				if(data.fmid && data.sign == false) {
3274					userLogin();
3275					return false;
3276				}
3277				if(data.comment_count > 0) {
3278					$(this).showModalFlat('ERROR', $.lang[LANG]['config.forum.delete.alert1'], true, false, '', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title');
3279					return false;
3280				}
3281
3282
3283				if(data.sign == false) {
3284					var passwordModal = $(this).showModalFlat($.lang[LANG]['board.button.delete.password'],passwdForm(),true,true,function() {
3285						var $pass = $('#comm-pass'),
3286							isSubmit = true,
3287							userInput = $pass.val();
3288						$('label.error').remove();
3289						if($pass.val().length<4) {
3290							//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
3291							$pass.closest('.cl-s-form-wrap').addClass('error');
3292							$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
3293							$pass.focus();
3294							isSubmit = false;
3295						}
3296
3297						if(isSubmit) {
3298							//$('.comment-addform.password').parent().find('.error').remove();
3299							$.post('/fm/password',{ id: id, passwd : hex_md5($pass.val()) }, function(data) {
3300								if(typeof data.error != 'undefined' && data.error) {
3301									//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
3302									$pass.closest('.cl-s-form-wrap').addClass('error');
3303									$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+data.error+'</label>');
3304									return false;
3305								}
3306								var date = new Date(),
3307									cookietime = 20 * 60 * 1000;
3308					            date.setTime(date.getTime() + cookietime);
3309
3310								$.cookie('hash', data.hash, { path: '/' , expires: date});
3311								$('.modal[id*=flat-modal]').modal('hide');
3312								resetObject(user);
3313								user.pass = hex_md5($pass.val());
3314								if(data.fm_type && data.fm_type == 'qna' ) {
3315									deleteForumPost(id);
3316								} else {
3317									var modal = $(this).showModalFlat($.lang[LANG]['board.ask-permanent-delete.title'], $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {			
3318									deleteForumPost(id);
3319									modal.modal('hide');												
3320									}, 'cancel', $.lang[LANG]['config.delete'],'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-t80 cl-modal cl-none-title cl-close-btn');												
3321								}
3322
3323								passwordModal.modal('hide');
3324							},'json');
3325						}
3326						modalEmptyCheck();
3327					},'cancel','','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password');
3328				} else if(data.own == true || data.mgr == true) {
3329					if(data.fm_type && $.inArray(data.fm_type, ['qna','faq']) > -1) {
3330						deleteForumPost(id);
3331					} else {
3332						var modal = $(this).showModalFlat($.lang[LANG]['board.ask-permanent-delete.title'], $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {			
3333						deleteForumPost(id);
3334						modal.modal('hide');												
3335						}, 'cancel', $.lang[LANG]['config.delete'],'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-t80 cl-modal cl-none-title cl-close-btn');												
3336					}
3337				} else {
3338					 alert( $.lang[LANG]['board.not-own-no-delete'] );
3339				}
3340			}, 'json');
3341		},
3342		deleteGuestbook : function(pid, id) {
3343			$.post('/fm/info', { id : id, sid : F_SID }, function(data) {
3344				if(typeof data.error != 'undefined' && data.error) {
3345					$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
3346					return false;
3347				}
3348				if(data.fmid && data.sign == false) {
3349					userLogin();
3350					return false;
3351				}
3352
3353				if(data.sign == false) {
3354					var passwordModal = $(this).showModalFlat($.lang[LANG]['guestbook.button.delete.password'],passwdForm(),true,true,function() {
3355						var $pass = $('#comm-pass'),
3356							isSubmit = true,
3357							userInput = $pass.val();
3358						$('label.error').remove();
3359						if($pass.val().length<4) {
3360							//$pass.after('<label class="error">' +  $.lang[LANG]['config.pass-min-length'] + '</label>').focus();
3361							$pass.closest('.cl-s-form-wrap').addClass('error');
3362							$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+$.lang[LANG]['config.pass-min-length']+'</label>');
3363							$pass.focus();
3364							isSubmit = false;
3365						}
3366
3367						if(isSubmit) {
3368							//$('.comment-addform.password').parent().find('.error').remove();
3369							$.post('/fm/password',{ id: id, passwd : hex_md5($pass.val()) }, function(data) {
3370								if(typeof data.error != 'undefined' && data.error) {
3371									//$('.comment-addform.password').before('<label class="error">' + data.error + '</label>');
3372									$pass.closest('.cl-s-form-wrap').addClass('error');
3373									$pass.closest('.cl-s-form-wrap').after('<label for="input" class="cl-s-control-label error"><svg viewBox="0 0 13 13" width="13" height="13"><path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/><rect x="6" y="3" width="1" height="5"/><rect x="6" y="9" width="1" height="1"/></svg>'+data.error+'</label>');
3374									return false;
3375								}
3376								var date = new Date(),
3377									cookietime = 20 * 60 * 1000;
3378					            date.setTime(date.getTime() + cookietime);
3379
3380								$.cookie('hash', data.hash, { path: '/' , expires: date});
3381								$('.modal[id*=flat-modal]').modal('hide');
3382								resetObject(user);
3383								user.pass = hex_md5($pass.val());
3384								deleteGuestbook(pid, id);
3385								passwordModal.modal('hide');
3386							},'json');
3387						}
3388						modalEmptyCheck();
3389					},'cancel','','cl-modal cl-cmmodal cl-p70 cl-s-btn w560 cl-close-btn cl-t80 board-password', '', '', function() {
3390						passwordModal.find('#comm-pass').addClass('guestbook-pass');
3391					});
3392				} else if(data.own == true || data.mgr == true) {
3393					deleteGuestbook(pid, id);
3394				} else {
3395					 alert( $.lang[LANG]['board.not-own-no-delete'] );
3396				}
3397			}, 'json');
3398		},
3399		setForumCookie : function(id,page_num,stx,sfl,scate) {
3400			// Recent  forum only
3401			// var cookies = $.cookie();
3402			// for(var cookie in cookies) {
3403			// 	if( cookie.indexOf($.cookie('forum')) == -1 && cookie.indexOf('forum') > -1) {
3404			// 		$.removeCookie(cookie);
3405			// 	}
3406			// }
3407			// console.log('setForumCookie', id,page_num,stx,sfl,scate);
3408			var prev_sfl = (typeof $.cookie('forum_'+id+'_prev_sfl') == 'undefined') ? '' : $.cookie('forum_'+id+'_prev_sfl'),
3409				prev_stx = (typeof $.cookie('forum_'+id+'_prev_stx') == 'undefined') ? '' : $.cookie('forum_'+id+'_prev_stx'),
3410				prev_scate = (typeof $.cookie('forum_'+id+'_prev_scate') == 'undefined') ? '' : $.cookie('forum_'+id+'_prev_scate'),
3411				change_stx = (prev_stx != stx) ? true : false,
3412				change_sfl = (prev_sfl != sfl && stx.length > 0) ? true : false,
3413				change_scate = (prev_scate != scate) ? true : false;
3414			if(change_stx || (!change_stx && (change_sfl || change_scate))) page_num = 1;
3415			// console.log(prev_sfl, prev_stx, prev_scate);
3416			// console.log(change_stx, change_sfl, change_scate, page_num);
3417			$.cookie('forum',id,{path:'/'});
3418			$.cookie('forum_'+id, page_num,{path:'/'});
3419			if(typeof stx != 'undefined' && stx) {
3420				$.cookie('forum_'+id+'_sfl',sfl,{path:'/'});
3421				$.cookie('forum_'+id+'_stx',stx,{path:'/'});
3422			} else {
3423				$.removeCookie('forum_'+id+'_stx',{path:'/'});
3424			}
3425
3426			if(typeof scate != 'undefined' && scate) {
3427				$.cookie('forum_'+id+'_scate',scate,{path:'/'});
3428			} else {
3429				$.removeCookie('forum_'+id+'_scate',{path:'/'});
3430			}
3431
3432			// console.log($.cookie('forum_'+id+'_sfl'), $.cookie('forum_'+id+'_stx'), $.cookie('forum_'+id));
3433			if(stx || sfl) {
3434				$.cookie('forum_'+id+'_prev_sfl', sfl, {path:'/'});
3435				if(stx) {
3436					$.cookie('forum_'+id+'_prev_stx', stx, {path:'/'});
3437				} else {
3438					$.removeCookie('forum_'+id+'_prev_stx', {path:'/'});
3439				}
3440				$.cookie('forum_'+id+'_prev_scate', scate, {path:'/'});
3441			} else {
3442				$.removeCookie('forum_'+id+'_prev_sfl', {path:'/'});
3443				$.removeCookie('forum_'+id+'_prev_stx', {path:'/'});
3444				$.removeCookie('forum_'+id+'_prev_scate', {path:'/'});
3445			}
3446		},
3447		setDefaultConfig : function(config) {
3448			var defaultConfig = {
3449				group 			: '',
3450				write_level 	: (PLAN || SERVICE.indexOf('gabia') > -1) ? 'NM' : 'M',
3451				reply_level		: (PLAN || SERVICE.indexOf('gabia') > -1) ? 'NM' : 'A',
3452				view_level		: 'A',
3453				list_level		: 'A',
3454				modify			: 0,
3455				delete 			: 0,
3456				page_row		: 10,
3457				secret_display	: 'U',
3458				comment_display : 'OFF',
3459				secretComment_display: 'U',
3460				sns_share_display	: 'OFF',
3461				bottomlist_display	: 'OFF',
3462				forum_count		: 0,
3463				comment_count	: 0,
3464				field_lang		: 'en',
3465				field_disable	: [],
3466				searchbox_display : 'ON',
3467				writebtn_display : 'ON',
3468			}
3469			if(config==null) config = defaultConfig;
3470			$.each(defaultConfig, function(k,v) {
3471				if(typeof config[k] == 'undefined') config[k] = v;
3472			});
3473			return config;
3474		},
3475		groupconfig : function(id) {
3476			$('.config-modal').remove();
3477
3478			if(typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == id) {
3479				var modal = $(this).showModalFlat($.lang[LANG]['board.manage-groups'],groupConfigForum(bc_fr.config,id,bc_fr.group),true,false,'','close', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0 gc-modal',true).attr({'data-fid':id, 'id':''}).closest('.flat-modal').addClass('flat-gc-modal'); 
3480			} else {
3481				$.post('/fm/config', { id : id }, function(data) {
3482					if(typeof data.error != 'undefined' && data.error) {
3483						$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
3484						return false;
3485					}
3486					var modal = $(this).showModalFlat($.lang[LANG]['board.manage-groups'],groupConfigForum(data.config,id,data.group),true,false,'','close', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0 gc-modal',true).attr({'data-fid':id, 'id':''}).closest('.flat-modal').addClass('flat-gc-modal'); 
3487				},'json');
3488			}
3489		},
3490		getgroupdata : function(id) {
3491			if(typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == id) {
3492				str = '', groups = bc_fr.group;
3493				for(var i=0; i<groups.length; i++) {
3494					str = str + getGroupList(groups[i].id, groups[i].name, groups[i].member_count);
3495				}
3496				$('#group-accordion').html(str);
3497			} else {
3498				$.post('/fm/config', { id : id }, function(data) {
3499					if(typeof data.error != 'undefined' && data.error) {
3500						return false;
3501					}
3502					str = '', groups = data.group;
3503					for(var i=0; i<groups.length; i++) {
3504						str = str + getGroupList(groups[i].id, groups[i].name, groups[i].member_count);
3505					}
3506					$('#group-accordion').html(str);
3507				},'json');
3508			}
3509		},
3510		getGroupNameList : function(fid) {
3511			var str = '';
3512			if(typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == fid) {
3513				groups = bc_fr.group;
3514				for(var i=0; i<groups.length; i++) {
3515					str = str + '<option value="' + groups[i].name + '" data-id="' + groups[i].id + '" data-member-count="' + groups[i].member_count + '">' + groups[i].name + '</option>';
3516				}
3517				return str;
3518			} else {
3519				$.post('/fm/config', { id : fid }, function(data) {
3520					if(typeof data.error != 'undefined' && data.error) {
3521						return false;
3522					}				
3523					groups = data.group;
3524					for(var i=0; i<groups.length; i++) {
3525						str = str + '<option value="' + groups[i].name + '" data-id="' + groups[i].id + '" data-member-count="' + groups[i].member_count + '">' + groups[i].name + '</option>';
3526					}
3527					return str;
3528				}, 'json');
3529			}
3530		},
3531		setfile : function (file,file_name,orig_name) {
3532			var $file = $('<div class="result-file" data-file="' + file + '" data-file-name="' + file_name + '">'),
3533				$result = $('<span><i class="fa fa-paperclip"></i></span> <span class="set-image hand"><i class="fa fa-arrow-circle-up"></i></span> <span>'+ orig_name + '</span>');
3534				$del = $('<span class="file-delete hand"><i class="fa fa-times"></i></span>');
3535
3536			$file.append($result).append($del);
3537			$file.appendTo('.upload-files');
3538			
3539			$('#fm-editor').froalaEditor('selection.restore');
3540
3541			if(upTYPE == 'image') {
3542				if(isReplace == true) editorImageReplace('http:' + file, orig_name);
3543				else $('#fm-editor').froalaEditor('image.insert', 'http:' + file, true);
3544			} else $('#fm-editor').froalaEditor('file.insert', 'http:' + file, orig_name, { 'link' : 'http:' + file, 'target': '_blank' });
3545		},
3546		drawSelboxCategory : function(sel_replace,pid) {
3547			F_SID = (typeof SID == 'undefined') ? property.SID : SID;
3548
3549			var str = '',
3550				block_lang = ($(sel_replace).attr('data-blocklang')) ? $(sel_replace).attr('data-blocklang') : LANG,
3551				block_content = (typeof SID == 'undefined') ? property.CONTENTS['el'+pid] : {};
3552
3553			if(block_content === undefined || block_content.category === undefined) {
3554				$.ajax({
3555	                url: '/fm/category/list',
3556	                dataType: 'json',
3557	                type: 'POST',
3558	                data: { pid: pid, sid: F_SID },
3559	                async: true,
3560	                cache: false,
3561	                success: function (list_data) {
3562						if(typeof list_data.error != 'undefined' && list_data.error) {
3563							$(this).showModalFlat('ERROR',list_data.error,true,false,'','ok');
3564							return false;
3565						}
3566						displayCategoryHtml(pid,list_data,sel_replace,block_lang);
3567					}
3568				});
3569			} else displayCategoryHtml(pid,block_content.category,sel_replace,block_lang);
3570		},
3571		callOpenForumCategoryConfig : function(pid) {
3572			openForumCategoryConfig(pid);
3573		},
3574		set : function(id,page_num,view,page,sfl,stx,scate,data) {
3575			var F_SID = (typeof SID == 'undefined') ? property.SID : SID,
3576				F_VALIDPLAN = (typeof VALIDPLAN == 'undefined') ? property.VALIDPLAN : VALIDPLAN,
3577				F_VALIDTYPE = (typeof VALIDTYPE == 'undefined') ? property.VALIDTYPE : VALIDTYPE;
3578
3579			var _fu = {
3580				pid: id,
3581				sid: F_SID,
3582				validplan: F_VALIDPLAN,
3583				validtype: F_VALIDTYPE,				
3584				elname: data.elname,
3585				eltag: (typeof data.source == 'undefined') ? '' : data.source,
3586				elcss: (typeof data.css != 'undefined') ? CSSJSON.toJSON(htmlspecialchars_decode(data.css)) : CSSJSON.toJSON(),
3587				elsettings: (typeof data.elsettings != 'undefined' && data.elsettings) ? $.parseJSON(data.elsettings) : {},
3588				config: (typeof data.config != 'undefined' && data.config) ? data.config : {},
3589				check: {
3590					templateview: (window.location != window.parent.location) ? true : false,
3591					demo: data.demo,
3592					notsupported: false,
3593				},
3594			};
3595
3596			_fu.elstyle =  style.get(_fu.elcss,`.${_fu.elname}`);
3597			_fu.sampleEL =  $(htmlspecialchars_decode(_fu.eltag));
3598			_fu.blockEL = $(`.element[data-id="${id}"]`);
3599
3600			_fu.el = _fu.blockEL.attr('data-el');
3601			_fu.elname = _fu.blockEL.attr('data-name');
3602			_fu.eltype = _fu.blockEL.attr('data-type');
3603			_fu.eltype2 = _fu.blockEL.attr('data-type2');
3604			_fu.elmsny = _fu.blockEL.is('[data-msny="true"]');
3605			_fu.field_lang = (_fu.elsettings.field_lang || _fu.elsettings.blocklang || LANG).toLowerCase();
3606			_fu.block_lang = (_fu.elsettings.blocklang || LANG).toLowerCase();
3607
3608        	if(!checkTemplateSite(F_SID) 
3609				&& (!F_VALIDPLAN || F_VALIDTYPE == 'PK') 
3610				&& $.inArray(_fu.eltype2, ['qna', 'faq']) > -1
3611			) {
3612				_fu.check.notsupported = true;
3613				if(PAGE_MODE != 'c') {
3614					_fu.blockEL.empty().addClass('hide');
3615					return false;
3616				}
3617			}
3618
3619			if(_fu.elcss === CSSJSON.toJSON()) {
3620				if(typeof data.msg == 'undefined') _fu.blockEL.empty().addClass('hide');
3621			} else {
3622				_fu.blockEL.removeClass('hide');
3623				$(`#${_fu.el}css`).text(data.css);
3624			}
3625
3626			initForumField(_fu.sampleEL);
3627			_fu.blockEL.html(_fu.sampleEL.html()).attr('data-init',true);
3628			_fu.blockLoop = _fu.blockEL.find('[data-loop="true"]');
3629
3630			if(_fu.check.notsupported) $.notSupported.set(F_SID, id, _fu.eltype2, true);
3631
3632			if(_fu.eltype2) _fu.blockEL.attr('data-forum-type',_fu.eltype2);
3633			else _fu.blockEL.removeAttr('data-forum-type');
3634
3635			// [data-ver="1"] add default init root css 
3636			if(_fu.blockEL.length > 0) {
3637				if(getOrDefault(_fu.elstyle,'__forum_color','') == '') {
3638					var forum_color = (typeof _fu.elsettings.forum_color != 'undefined') ? _fu.elsettings.forum_color : ((typeof _fu.blockEL.attr('data-fcolor') != 'undefined') ? _fu.blockEL.attr('data-fcolor') : '#191919');
3639					if($.inArray(forum_color, ['black','white']) > -1) forum_color = (forum_color == 'black') ? '#191919' : '#ffffff';
3640					_fu.blockEL.attr('data-fcolor',forum_color);
3641
3642					if(document.querySelector(`.${_fu.elname}`)) {
3643						document.querySelector(`.${_fu.elname}`).style.setProperty('--forum-color', forum_color, null);
3644						document.querySelector(`.${_fu.elname}`).style.setProperty('--forum-color-rgb', Coloris.getChangeColorVal(forum_color,'rgb_str'), null);
3645						document.querySelector(`.${_fu.elname}`).style.setProperty('--searchbox-option-color', forum_color, null);
3646						document.querySelector(`.${_fu.elname}`).style.setProperty('--searchbox-option-bgcolor', _fu.blockEL.css('background-color'), null);
3647					}
3648				}
3649				if(_fu.blockEL.is('[data-fcolor]')) _fu.blockEL.attr('data-ver','1');
3650			}
3651
3652			if(data.total == 0) {
3653        		if(data.msg) {
3654        			RELOAD = true;
3655        			if(data.sign == false) _fu.blockEL.find('.tpl-forum-write').text($.lang[_fu.field_lang]['config.comment.login-modal']);
3656        		}
3657
3658				if(!_fu.check.templateview 
3659					&& !_fu.check.demo
3660					&& (typeof MODE == 'undefined' || typeof $.cookie(`forum_${id}_stx`) != 'undefined' || typeof $.cookie(`forum_${id}_scate`) != 'undefined')
3661				) {
3662					if(data.msg) _fu.blockEL.find('.search-box').addClass('hide');
3663					_fu.blockEL.find('.table thead').addClass('hide');
3664
3665					var msg = data.msg;
3666					if (msg && /<br\s*\/?>/i.test(msg)) {
3667						msg = msg.replace(/<br\s*\/?>/gi, '\n');   // 개행 처리
3668						_fu.blockLoop.addClass('has-multiline-desc');
3669					}					
3670
3671					_fu.blockLoop.empty().attr('data-description',msg ? msg : $.lang[_fu.block_lang]['board.no-posts']
3672					);
3673
3674					// Fix : html content="" 값으로 <br> 태그 들어가는 경우 개행 처리가 되지 않아 위와 같이<br> 예외 처리 수정
3675					//_fu.blockLoop.empty().attr('data-description',(data.msg) ? data.msg : $.lang[_fu.block_lang]['board.no-posts']);
3676					_fu.blockEL.find('.tpl-forum-pagination').empty().attr({'data-page':page, 'data-view':view});
3677				} else {
3678					// view sample block
3679					_fu.blockLoop.addClass('sample-loop');
3680					_fu.blockLoop.find(`
3681								.tpl-guestbook-more-menu, 
3682								.tpl-guestbook-more-menu-area-el2
3683					`).remove();
3684				}
3685			} else {
3686				
3687				if(	_fu.eltype2 == 'guestbook'
3688					|| _fu.blockEL.is('[data-ver="1"]')
3689				) {
3690					$.forum.update_ver1(id,page_num,view,page,sfl,stx,scate,data);
3691				} else {
3692					_fu.blockLoop.empty();
3693
3694					if(data.total<=((view*page_num)-view)) {
3695						page_num = page_num-1;
3696						if(page_num==0) page_num=1;
3697					}
3698	
3699					$.each(data.list, function(post_i,post) {
3700						var num = data.total - (view * (page_num-1)) - post_i;
3701						var item_tag = getForumListItem(num,post,_fu);
3702						_fu.blockLoop.append(item_tag);
3703	
3704					});
3705					if(_fu.sampleEL.find('.layout-table .tpl-forum-header-row').length > 0) {
3706						_fu.blockLoop.prepend(_fu.sampleEL.find('.layout-table .tpl-forum-header-row').prop('outerHTML'));
3707					}
3708				}
3709			}
3710
3711			showHideForumField(_fu.blockEL, _fu.elsettings);
3712
3713			// 검색창
3714			var searchbox_onoff = (typeof _fu.elsettings.searchbox_display != 'undefined' && _fu.elsettings.searchbox_display == 'OFF') ? false : true;
3715			if(!searchbox_onoff) _fu.blockEL.find('.search-box').addClass('hide');
3716			else {
3717				_fu.blockEL.find('.search-box').removeClass('hide');
3718				if(!_fu.blockEL.find('#scate').hasClass('hide')) $.forum.drawSelboxCategory(_fu.blockEL,id);
3719	
3720				if(typeof scate != 'undefined' && scate) scate = data.scate;
3721				if(typeof stx != 'undefined' && stx) stx = data.stx;
3722				$.forum.setForumCookie(id,page_num,stx,sfl,scate);
3723	
3724				if($.inArray(sfl, ['mb_id','nonmem']) > -1) {
3725					_fu.blockEL.remove('input[name="user_sfl"], input[name="user_stx"]');
3726					_fu.blockEL.append(`<input type="hidden" name="user_sfl" value="${sfl}"><input type="hidden" name="user_stx" value="${stx}">`);
3727				} else {
3728					var prev_stx = getForumPrevStx(id);
3729					_fu.blockEL.find('.search-box #sfl').val(sfl);
3730					_fu.blockEL.find('.search-box #stx, .serach-box #stx, .search-box input[name="stx"], .serach-box input[name="stx"]').attr('autocomplete','off').val(prev_stx);
3731					_fu.blockEL.find('.search-box #sfl option').map( function() {
3732						var sfl = $(this).attr('value');
3733						$(this).text($.lang[_fu.block_lang][`board.sfl.${sfl}`]);
3734					});
3735
3736					if($.inArray(sfl, ['mb_id','nonmem']) < 0
3737						&& stx.length > 0 
3738						&& _fu.blockLoop.find(`.tpl-forum-list-title a:contains("${stx}")`).length > 0
3739					) {
3740						_fu.blockLoop.find(`.tpl-forum-list-title a:contains("${stx}")`).each(function() {
3741							var title_txt = $(this).text(),
3742								regex = new RegExp(stx,'gi'),
3743								new_title_txt = title_txt.replace(regex, `<strong class="search-txt">${stx}</strong>`);
3744							$(this).html(new_title_txt);
3745						});
3746					}
3747				}
3748	
3749				if(!sfl) _fu.blockEL.find('.search-box select').children().first().attr('selected','selected');
3750				if(!stx || stx.length==0) _fu.blockEL.find('.search-box #sfl').val($('.search-box #sfl').children().first().attr('value'));
3751	
3752				_fu.blockEL.find('.search-box #scate').val(scate);
3753				if(!scate || scate.length==0) _fu.blockEL.find('.search-box #scate').val('');
3754			}
3755
3756			// 항목 > 언어
3757			_fu.blockEL.find('.tpl-forum-header-row').children('[class*="tpl-forum-"]').each(function(idx, v) {
3758				var tmp_cls = $(this).attr('class'),
3759				tmp_matches = [...tmp_cls.matchAll(/tpl-forum-(\w+)/g)].map(match => match[1])[0];
3760				if(tmp_matches == 'content') tmp_matches = 'title';
3761				else if(tmp_matches == 'num' && $(this).hasClass('num-ko')) tmp_matches += '.ko';
3762				if(typeof $.lang[_fu.field_lang][`forum.field.tpl-forum-${tmp_matches}`] != 'undefined') $(this).text($.lang[_fu.field_lang][`forum.field.tpl-forum-${tmp_matches}`]);
3763			});
3764
3765            // 버튼 > 텍스트 
3766            var btn_arr = (_fu.eltype2 == 'guestbook') ? ['write','cancel'] : ['write'];
3767            $.each(btn_arr, function(i,k) {
3768                var tmp_k = (_fu.eltype2 == 'guestbook') ? _fu.eltype2 : 'forum',
3769                    tmp_selector = `.tpl-${tmp_k}-${k}`,
3770                    tmp_custom = `btn${i > 0 ? k.charAt(0).toUpperCase() + k.slice(1) : ''}Text`,
3771                    tmp_text = _fu.elsettings[tmp_custom] ?? $.lang[_fu.block_lang][`forum.field${tmp_selector}`] ?? _fu.blockEL.find(tmp_selector).text().trim();
3772
3773				_fu.blockEL.find(tmp_selector).text(tmp_text).attr('data-pid',id);
3774            });
3775
3776			// 페이지네이션
3777			if(!_fu.blockEL.find('[data-loop="true"]').is('.sample-loop')) {
3778				setForumPagination(_fu.blockEL.find('.tpl-forum-pagination'),data.total,view,page_num,id,page);
3779				if(Number(data.total) <= Number(view)) _fu.blockEL.find('.tpl-forum-pagination').addClass('hide');
3780				else _fu.blockEL.find('.tpl-forum-pagination').removeClass('hide');
3781			}
3782
3783			switch(_fu.eltype2) {
3784				case 'faq':
3785					if(typeof MODE == 'undefined') _fu.blockEL.find('.tpl-forum-write').remove();
3786					break;
3787				
3788				default:
3789					 break;
3790			}
3791
3792			// 방명록 캡챠
3793			if(_fu.eltype2 == 'guestbook') {
3794				var captcha_onoff = (getOrDefault(_fu.elsettings,'captcha_display','OF
3794F') == 'ON') ? true : false;
3795				if(captcha_onoff) {
3796					_fu.blockEL.find('.kcaptcha-box img').attr('src', '//storage.googleapis.com/i.addblock.net/js/load_kcaptcha.gif');
3797					$.post(rt_path + '/check/kcaptcha/session/' + id + '?_' + new Date().getTime(), function(data) {
3798						// md5_norobot_key = data;
3799						var tmpImg = new Image();
3800						tmpImg.src = rt_path + '/check/kcaptcha/image/' + id;
3801						tmpImg.onload = function() {
3802							_fu.blockEL.find('.kcaptcha-box img').attr('src', rt_path + '/check/kcaptcha/image/' + id + '?_' + new Date().getTime());
3803						};          
3804					});
3805		
3806					_fu.blockEL.find('.kcaptcha.small').off('click').on('click', function() {
3807						_fu.blockEL.find('.kcaptcha-box img').attr('src', '//storage.googleapis.com/i.addblock.net/js/load_kcaptcha.gif');
3808						$.post(rt_path + '/check/kcaptcha/session/' + id + '?_' + new Date().getTime(), function(data) {
3809							// md5_norobot_key = data;
3810							var tmpImg = new Image();
3811							tmpImg.src = rt_path + '/check/kcaptcha/image/' + id;
3812							tmpImg.onload = function() {
3813								_fu.blockEL.find('.kcaptcha-box img').attr('src', rt_path + '/check/kcaptcha/image/' + id + '?_' + new Date().getTime());
3814							};          
3815						});
3816					});
3817				} else {
3818					_fu.blockEL.find('.captcha').hide();
3819				}
3820		
3821				_fu.blockEL.find('.default_top, .default_bottom').removeClass('flex-value-order1 flex-value-order2');
3822				var guestbook_input_updown = getOrDefault(_fu.elsettings,'input_updown','U');
3823				if(guestbook_input_updown == 'U') {
3824					_fu.blockEL.find('.default_top').addClass('flex-value-order1');
3825					_fu.blockEL.find('.default_bottom').addClass('flex-value-order2');
3826				} else {
3827					_fu.blockEL.find('.default_top').addClass('flex-value-order2');
3828					_fu.blockEL.find('.default_bottom').addClass('flex-value-order1');
3829				}
3830			}
3831
3832			var writebtn_onoff = (typeof _fu.elsettings.writebtn_display !='undefined' && _fu.elsettings.writebtn_display == 'OFF') ? false : true;
3833			if(typeof MODE == 'undefined' && !writebtn_onoff) {
3834				_fu.blockEL.find('.tpl-forum-write[data-disabled="true"]').remove();
3835			}
3836			
3837			_fu.blockEL.removeClass('preloading');
3838		},
3839	};
3840
3841	$.forumChangeList = {
3842		init : function(id){
3843
3844		},
3845		makeList : function(F_SID,id){
3846			var listStr = '';
3847
3848			$.ajax({
3849                url: '/fm/ChangeList/type/get',
3850                dataType: 'json',
3851                type: 'POST',
3852                data: { sid: F_SID, pid : id},
3853                async: false,
3854                cache: false,
3855                success: function (data) {
3856
3857                	if(typeof data.error != 'undefined' && data.error) {
3858                		$(this).showModalFlat('ERROR', data.error, true , false, '', 'close');
3859                		return false;
3860                	}
3861
3862                	var notice_list = [],
3863                		general_list = [];
3864
3865            		$.each(data,function(f,g){
3866            			if(g.fm_option=='N') notice_list.push(g);
3867            			else general_list.push(g);
3868            		});
3869                	
3870
3871                	listStr += '\
3872                		<div class="change-list-box">\
3873                		';
3874                	
3875                	if(notice_list.length>0) {		
3876                	listStr +='\
3877                			<h3>'+$.lang[LANG]['editor.forum.faqChangeList.config.notice']+'</h3>\
3878                			';
3879            		}
3880
3881            		listStr +='\
3882            				<ul class="ui-sortable change-list" data-listtype="notice">\
3883	            				';
3884        					$.each(notice_list,function(i,v){
3885					listStr += '\
3886								<li data-num="'+v.fm_num+'" data-seq="'+v.seq+'">\
3887									<div class="change-list-move hand cl-sort-handle change-list-handle-notice">\
3888									' + clSVG('move_handle', 20, 20) + '\
3889									</div>\
3890									<div class="change-list-text">\
3891										' + initSVGIcon('item_forum_notice','bc-svg-notice') + '\
3892										<span class="change-fmtitle">'+v.fm_title+'</span>\
3893									</div>\
3894								</li>\
3895								';
3896							});
3897            		listStr += '\
3898            				</ul>\
3899                		';
3900
3901            		if(general_list.length>0) {		
3902            		listStr += '\
3903            				<h3>'+$.lang[LANG]['editor.forum.faqChangeList.config.normal']+'</h3>\
3904            				';
3905    				}
3906            		
3907            		listStr += '\
3908		            		<ul class="ui-sortable change-list" data-listtype="general">\
3909            				';
3910        					$.each(general_list,function(s,d){
3911					listStr += '\
3912								<li data-num="'+d.fm_num+'" data-seq="'+d.seq+'">\
3913									<div class="change-list-move hand cl-sort-handle change-list-handle-normal">\
3914									' + clSVG('move_handle', 20, 20) + '\
3915									</div>\
3916									<div class="change-list-text">\
3917										' + (d.fm_option=='S' ? initSVGIcon('item_forum_secret','bc-svg-secret') : '') + '\
3918										<span class="change-fmtitle">'+d.fm_title+'</span>\
3919									</div>\
3920								</li>\
3921								';
3922							});
3923            		listStr += '\
3924            				</ul>\
3925            			</div>\
3926            		';
3927
3928                }
3929            });		
3930
3931			return listStr;
3932
3933		},
3934		open : function(id){
3935			//$.forumChangeList.init(id);			
3936			F_SID = (typeof SID == 'undefined') ? property.SID : SID;
3937			
3938			var listStr = $.forumChangeList.makeList(F_SID,id),
3939				modal = $(this).showModalFlat($.lang[LANG]['editor.forum.faqChangeList.config'],listStr,true,true,function(){
3940
3941				$.progressON($.lang[LANG]['editor.forum.faqChangeList.config.changing'],'','',true);
3942				
3943				var updateList = {},
3944					updateList_notice = {},
3945					updateList_general = {};
3946
3947				$.each($('.change-list'),function(z,x){
3948					var listType = $(this).attr('data-listtype');
3949
3950					if(listType=='notice') {
3951					 	updateList_notice = $(this).find('li').map(function(i,v) {
3952							var dataNum = $(this).attr('data-num'),
3953								dataSeq = $(this).attr('data-seq');
3954
3955							return {
3956								dataNum : dataNum,
3957								dataSeq : dataSeq
3958							}
3959						}).get();
3960					} else {
3961						updateList_general = $(this).find('li').map(function(i,v) {
3962							var dataNum = $(this).attr('data-num'),
3963								dataSeq = $(this).attr('data-seq');
3964
3965							return {
3966								dataNum : dataNum,
3967								dataSeq : dataSeq
3968							}
3969						}).get();
3970					}
3971
3972					updateList = updateList_notice.concat(updateList_general);
3973					$('.progress-bar').css('width','40%');
3974				});
3975
3976				$.ajax({
3977	                url: '/fm/ChangeList/type/update',
3978	                dataType: 'json',
3979	                type: 'POST',
3980	                data: { sid: F_SID, pid : id, updateList : updateList },
3981	                async: false,
3982	                cache: false,
3983	                success: function (data) {
3984	                	if(typeof data.error != 'undefined' && data.error) {
3985	                		$(this).showModalFlat('ERROR', data.error, true , false, '', 'close');
3986	                		return false;
3987	                	}
3988	                	$('.progress-bar').css('width','100%');
3989	                	setTimeout(function() {		                		
3990                			modal.modal('hide');
3991		                  	$.progressOFF();
3992		                  	showPageCallback(showPage);	
3993		                },'650');
3994	                }
3995                });	
3996
3997                var type = getElementType();
3998                setLogs(type,'forum.faq.sort','block-sort', type);
3999				
4000			},'config.close','config.save', 'cl-cmmodal cl-cmwide cl-s-btn w700 cl-p70 cl-p0 cl-forum-changeList',true,'',function(){			
4001				var num_array = [];
4002				$('.change-list').each(function(){
4003					$(this).sortable({
4004						placeholder:'chage-list-move-placeholder',
4005						connectWith: $(this),
4006		                handle : '.change-list-move',
4007		                revert :50,
4008		                tolerance: 'pointer',
4009						helper : 'clone',
4010		                update : function(e,ui){
4011		                	$(this).find('li').removeClass('chage-list-move-placeholder');
4012		                	num_array = $(this).sortable( "toArray", { attribute : 'data-num' });
4013		                	num_array.sort(function(q,w){
4014		                		return q - w;
4015		                	});
4016
4017		                	var listType = $(this).attr('data-listtype');
4018
4019		                	$.each(num_array,function(a,b){
4020								$.each($('.change-list[data-listtype="'+listType+'"] li'),function(n,m){
4021									if(a==n) $(this).attr('data-num',b);
4022								});
4023							});
4024		                }
4025		            }).disableSelection();
4026				});
4027			});
4028		},
4029	};
4030
4031	var getConfigChecked = function (value,select,valstr) {
4032		valstr = (typeof valstr == 'undefined') ? 'selected' : valstr;
4033		var check = [];
4034
4035		$.each(select, function(i,v) {
4036			check.push((value.toUpperCase()==v) ? valstr : '');
4037		});
4038		return check;
4039	}
4040
4041	var groupConfigForum = function(config,id,group) {
4042		config = $.forum.setDefaultConfig(config);
4043
4044		var tpUser = ['ADM','A','M','N','G'],
4045			tpOnoff = ['ON','OFF'],
4046			tpSecret = ['N','U','A'],
4047			tpSecretComment = ['N','U','A'],
4048			mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink',
4049			group_member = 0,
4050			groups = group,
4051			select_group = config.group,
4052			select_group_str = '';
4053
4054		var preference = { group : '', write : [], view : [], reply : [], list : [], modify : config.modify, delete : config.delete, row : config.page_row, secret : [], sns : [], comment : []}
4055		preference.write 	= getConfigChecked(config.write_level,tpUser);
4056		preference.view 	= getConfigChecked(config.view_level,tpUser);
4057		preference.reply 	= getConfigChecked(config.reply_level,tpUser);
4058		preference.list 	= getConfigChecked(config.list_level,tpUser);
4059		preference.secret 	= getConfigChecked(config.secret_display,tpSecret,'checked');
4060		preference.secretComment = getConfigChecked(config.secretComment_display,tpSecretComment,'checked');
4061		preference.comment 	= getConfigChecked(config.comment_display,tpOnoff,'checked');
4062
4063		var namelist_str = $.forum.getGroupNameList(id);
4064
4065		var str = '\
4066		<div class="clearwrap">\
4067			<div class="forum-member-search">\
4068				<div class="select-wrap">\
4069					<select class="hand" id="g-sfl" name="g-sfl" placeholder="' + $.lang[LANG]['board.g-sfl.all'] + '">\
4070						<option value="all" data-id="all" selected>' + $.lang[LANG]['board.g-sfl.all'] + '</option>\
4071						' + namelist_str + '\
4072					</select>\
4073				</div>\
4074				<div class="cl-common-form-wrap nonplace-holder">\
4075                    <div class="cl-common-form-group">\
4076    					<input id="g-stx" name="g-stx" class="config-input member-search" placeholder="' + $.lang[LANG]['board.search.userid.'+mtype] + '">\
4077                        <label class="lock-input-error"></label>\
4078                    </div>\
4079                    <span class="btn btn-xs btn-forum-config btn-forum-group-search" data-toggle="tooltip" data-placement="top" data-id="' + SID + '">\
4080	                	<svg viewBox="0 0 13 13" width="13" height="13">\
4081	                		<path d="M13 12.29L9.73 9.02C10.52 8.06 11 6.84 11 5.5 11 2.46 8.54 0 5.5 0 2.46 0 0 2.46 0 5.5 0 8.54 2.46 11 5.5 11c1.34 0 2.57-0.48 3.52-1.27L12.29 13 13 12.29zM1 5.5C1 3.02 3.02 1 5.5 1S10 3.02 10 5.5 7.98 10 5.5 10 1 7.98 1 5.5z"/>\
4082	                	</svg>\
4083	                </span>\
4084                </div>\
4085			</div>\
4086		</div>\
4087		<div class="config-wrap">';
4088		if(groups.length == 0) {
4089			str = str + '<div class="forum-settings group empty"><p>그룹이 없습니다.</p></div>';
4090		} else {
4091			str = str + '\
4092			<div class="panel-group forum-settings group" id="group-accordion">\
4093			';
4094			for(var i=0; i<groups.length; i++) {
4095				if(select_group == groups[i].id) {
4096					selected = 'selected';
4097					group_member = groups[i].member_count;
4098					select_group_str = ' - ' + groups[i].name;
4099				} else {
4100					selected = '';
4101				}
4102				
4103				str = str + getGroupList(groups[i].id, groups[i].name, groups[i].member_count);
4104			}
4105
4106			str = str + '\
4107			</div>\
4108		';
4109		}
4110		str = str + '\
4111		</div>\
4112		<div class="froum-group-add">\
4113			<span class="btn btn-group-add">\
4114				<span><svg viewBox="0 0 12 12" width="12" height="12"><polygon points="12 5 7 5 7 0 5 0 5 5 0 5 0 7 5 7 5 12 7 12 7 7 12 7 "/></svg></span>\
4115			' + $.lang[LANG]['board.add-group'] + '</span>\
4116		</div>\
4117		';
4118		return str;
4119	}
4120
4121
4122	var getGroupList = function (gid, gname, gmcount) {
4123		var str =  '\
4124				<div class="panel">\
4125					<div class="panel-heading">\
4126						<div class="panel-title">\
4127							<a class="accordion-toggle group-item hand" data-id="' + gid + '" data-member-count="' + gmcount + '">\
4128								<label class="group-name hand">' + gname + '</label>\
4129								<span class="group-member-count">' + gmcount + '</span>\
4130								<svg viewBox="0 0 8 4" width="8" height="4"><polygon points="0 0 4 4 8 0 "/></svg>\
4131							</a>\
4132							<div class="content">\
4133								<span>\
4134									<svg viewBox="0 0 13 13" width="13" height="13" class="group-user-add hand">\
4135										<polygon points="13 2 11 2 11 0 10 0 10 2 8 2 8 3 10 3 10 5 11 5 11 3 13 3 "/>\
4136										<path d="M6.83 8.36C7.54 7.81 8 6.96 8 6c0-1.66-1.34-3-3-3S2 4.34 2 6c0 0.96 0.46 1.81 1.17 2.36C1.31 9.09 0 10.89 0 13h1c0-2.21 1.79-4 4-4s4 1.79 4 4h1C10 10.89 8.69 9.09 6.83 8.36zM3 6c0-1.1 0.9-2 2-2 1.1 0 2 0.9 2 2S6.1 8 5 8C3.9 8 3 7.1 3 6z"/>\
4137									</svg>\
4138								</span>\
4139								<span>\
4140									<svg viewBox="0 0 13 13" width="13" height="13" class="group-name-edit hand">\
4141										<path d="M4.32 8.05C4.2 8.39 4.46 8.71 4.79 8.71c0.05 0 0.11-0.01 0.16-0.03L7 8l6-6-2-2L5 6 4.32 8.05zM5.87 6.54L11 1.41 11.59 2 6.46 7.13 5.58 7.42 5.87 6.54z"/>\
4142										<path d="M9 11c0 0.55-0.45 1-1 1H2c-0.55 0-1-0.45-1-1V4c0-0.55 0.45-1 1-1h3V2H2C0.9 2 0 2.9 0 4v7c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V8H9V11z"/>\
4143									</svg>\
4144								</span>\
4145								<span>\
4146									<svg viewBox="0 0 12 13" width="12" height="13" class="group-delete hand">\
4147										<path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/>\
4148										<rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/>\
4149									</svg>\
4150								</span>\
4151							</div>\
4152						</div>\
4153					</div>\
4154					<div id="group-list-' + gid + '" class="panel-collapse" style="display:none;" data-load="'+((gmcount > 0) ? 'true' : 'false')+'">\
4155						<div class="panel-body">\
4156						</div>\
4157					</div>\
4158				</div>\
4159		';
4160		return str;
4161	}
4162
4163	var getGroupMemberList = function (id,userid) {
4164
4165		var userid = (typeof userid == 'undefined' || !userid) ? '' : userid, 
4166			mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink',
4167			str = '';
4168
4169		$.post('/fm/group/member', { id : id, page : 1, userid : userid, mtype:mtype }, function(data) {
4170			if(typeof data.error != 'undefined' && data.error) {
4171				return false;
4172			}
4173
4174			if(data.total>0) {
4175				str = '		<ul class="group-member-list">';
4176				$.each(data.list, function(i,v) {
4177					str = str + '\
4178								<li class="gm-item">\
4179									<div>\
4180										<div class="gmi-img">\
4181											<span class="hexagon">\
4182												<img src="'+v.img+'" alt="" class="img-responsive">\
4183											</span>\
4184										</div>\
4185										<div class="gmi-info">\
4186					';
4187					if(v.name != v.id && v.name) {
4188						str = str + '\
4189											<span class="gmi-name">' + v.name + '</span>\
4190						';
4191					}
4192						str = str + '\
4193											<span class="gmi-id">' + v.id + '</span>\
4194										</div>\
4195										<div class="gmi-btn">\
4196											<svg viewBox="0 0 12 13" width="12" height="13" class="gmi-del hand" data-userid="' + v.id + '" data-id="' + v.fg_id + '">\
4197												<path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/>\
4198												<rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/>\
4199											</svg>\
4200										</div>\
4201									</div>\
4202								</li>';
4203				});
4204				str = str + '</ul>';
4205			} else {
4206				str = '		<div class="empty">' + $.lang[LANG]['board.group-no-members'] + '</div>';
4207			}
4208
4209		}, 'json');
4210		return str;
4211	}
4212
4213	var settingEditMode = function(mode) {
4214		if(mode) {
4215			$('.forum-member-search, .froum-group-add').css('pointer-events','none');
4216			$('#group-accordion').find('.forum-group-update').css('pointer-events','auto').find('input').focus();
4217			$('#group-accordion').find('.forum-group-user-add').css('pointer-events','auto').find('input').focus();
4218		} else {
4219			$('.forum-member-search, .froum-group-add').css('pointer-events','auto');
4220			$('#group-accordion').find('.config-error').remove();
4221		}
4222	}
4223
4224	var addForumGroupUpdateInput = function(gid, gname) {
4225		var gid = (typeof gid=='undefined' || !gid) ? '' : gid,
4226			gname = (typeof gname=='undefined' || !gname) ? '' : gname,
4227			str = '\
4228			<div class="forum-group-update">\
4229				<div class="input-group">\
4230					<input type="text" class="forum-group-name hand forum-control" placeholder="' + $.lang[LANG]['board.enter-group-name'] + '" value="' + gname + '"/>\
4231					<div class="input-group-btn hand ga-save" data-id="' + gid + '">\
4232						<svg viewBox="0 0 15 10" width="15" height="10" class="">\
4233							<path d="M14.29 0L5.5 8.79 0.71 4 0 4.71l5.15 5.15C5.24 9.95 5.37 10 5.5 10s0.26-0.05 0.35-0.15L15 0.71 14.29 0z"/>\
4234						</svg>\
4235					</div>\
4236					<div class="ga-cancel">\
4237						<svg viewBox="0 0 12 12" width="12" height="12">\
4238							<polygon points="12 0.71 11.29 0 6 5.29 0.71 0 0 0.71 5.29 6 0 11.29 0.71 12 6 6.71 11.29 12 12 11.29 6.71 6 "/>\
4239						</svg>\
4240					</div>\
4241				</div>\
4242			</div>\
4243		';
4244		return str;
4245	}
4246
4247
4248	$doc.on('hidden.bs.modal','.flat-gc-modal .modal', function (e) {
4249		var ctrlChmodSelectGroup = $('#el-blockConfig .ctrl-chmod-select[data-mode="group"]'),
4250			gid = ctrlChmodSelectGroup.find('option:selected').attr('data-id'),
4251			str = $.forum.getGroupNameList(selectID);
4252		settingEditMode(false);
4253
4254		ctrlChmodSelectGroup.html(str);
4255		var selectGroup = (ctrlChmodSelectGroup.find('option[data-id="' + gid + '"]').length > 0) ? ctrlChmodSelectGroup.find('option[data-id="' + gid + '"]') : ctrlChmodSelectGroup.find('option:first-child');
4256		selectGroup.attr('selected',true);
4257
4258		$('#el-blockConfig .ctrl-chmod-select option[value="G"]').each(function() {
4259			$(this).text($.lang[LANG]['board.access-group-label'] + ' - ' + selectGroup.val());
4260		});
4261		$('.flat-gc-modal').remove();
4262	});
4263
4264
4265	$doc.on('click','.btn-group-add', function (e) {
4266		if($('#group-accordion').find('.forum-group-update').length > 0) return false;
4267
4268		$('#g-stx').val('');
4269		$('#g-sfl option:first-child').attr('selected',true);
4270		$.forum.getgroupdata($('.flat-gc-modal .modal').attr('data-fid'));
4271
4272		var input_text = addForumGroupUpdateInput();
4273		$(input_text).appendTo($('#group-accordion'));
4274		settingEditMode(true);
4275	});
4276
4277	$doc.on('click','.ga-cancel',function (e) {
4278		settingEditMode(false);
4279		$('#group-accordion').find('.forum-group-update').remove();
4280	});	
4281
4282
4283	$doc.on('click','.ga-save', function (e) {
4284		if($(this).hasClass('clicked')) return false;
4285		else $(this).addClass('clicked');
4286
4287		var group_name = $('.forum-group-name').val();
4288		var id = $(this).attr('data-id');
4289		var categoryRegexp =  /[\[\]|,'"<>{}\/\\:;%&@$!*?\^]/;
4290		var special_pattern = /[~!?@\#$%<>^&*\(){}\-\[\]\\:;=+_\’'"]/gi;
4291		var editgroupname = (id) ? 'g-edit' : '';
4292		$position = (id) ? $('.group-item[data-id="'+id+'"]').parents('.panel-title') : $('#group-accordion');
4293
4294		$('.config-error').remove();
4295		var show_error_ga_save = function(error_message) {
4296			$position.find('.forum-group-update').removeClass('error-forum').addClass('error-forum');
4297			$position.append('\
4298				<div class="config-error '+editgroupname+'">\
4299					' + clSVG('info',13,13) +'\
4300					<span>' + error_message + '</span>\
4301				</div>\
4302		    ');
4303		    $('.ga-save').removeClass('clicked');
4304		}
4305
4306		if($('.group-item[data-id="'+id+'"] .group-name').text() == group_name) {
4307			settingEditMode(false);
4308			$('#group-accordion').find('.forum-group-update').remove();
4309			$('.ga-save').removeClass('clicked');
4310			return false;
4311		}
4312
4313		if(!group_name.trim()) {
4314			show_error_ga_save($.lang[LANG]['board.allowed-chars.none']);
4315			return false;
4316		}
4317		if(checkEmojis(group_name.trim())) {
4318			show_error_ga_save($.lang[LANG]['config.unable.emoji']);
4319			return false;
4320		}
4321		if((special_pattern.test(group_name.trim()) == true)) {
4322			show_error_ga_save($.lang[LANG]['board.allowed-chars']);
4323            return false;
4324        }
4325		if(group_name.length<1) {
4326			show_error_ga_save($.lang[LANG]['board.enter-group-name']);
4327			return false;
4328		}
4329		if(group_name.length>60) {
4330			show_error_ga_save($.lang[LANG]['board.enter-max-chars.60']);
4331			return false;
4332		}
4333
4334		$.post('/fm/group/update', { sid : F_SID, id : id, name : encodeURIComponent(group_name) }, function(data) {
4335			if(typeof data.error != 'undefined' && data.error) {
4336				show_error_ga_save(data.error);
4337				return false;
4338			}
4339
4340			$('#group-accordion').find('.forum-group-update').remove();
4341			settingEditMode(false);
4342			if(id) {
4343				var str = '\
4344					<label class="group-name">' + data.name + '</label>\
4345					<span class="group-member-count">' + $('#group-accordion .group-item[data-id="' + data.id + '"]').attr('data-member-count') + '</span>\
4346					<svg viewBox="0 0 8 4" width="8" height="4"><polygon points="0 0 4 4 8 0 "/></svg>\
4347				';
4348				$('#group-accordion .group-item[data-id="' + data.id + '"]').html(str);
4349				$('.flat-gc-modal #g-sfl option[data-id="' + data.id + '"]').attr('value',data.name).text(data.name);
4350			} else {
4351				var newgroup = getGroupList(data.id, data.name, 0);
4352				$('#group-accordion').append(newgroup);
4353				$('#group-accordion .group-item[data-id="' + data.id + '"]').click();
4354				$('.flat-gc-modal #g-sfl').append('<option value="'+data.name+'" data-id="'+data.id+'" data-member-count="'+data.member_count+'">'+data.name+'</option>');
4355			}
4356
4357			groups = getForumGroupObject();
4358			if($('#el-blockConfig.open').length > 0 && (typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == selectID)) {
4359				bc_fr.group = groups;
4360			}
4361			$('.ga-save').removeClass('clicked');
4362
4363		}, 'json');
4364	});
4365
4366	$doc.on('click','.group-user-add, .group-item', function (e) {
4367		if($('#group-accordion').find('.forum-group-user-add').length > 0) return false;
4368		$select_group = $(this).parents('.content').prev('.group-item');
4369
4370		var gid = ($(this).hasClass('group-item')) ? $(this).attr('data-id') : $select_group.attr('data-id'),
4371			mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink',
4372			group_member_list_check = $(this).parents('.panel').find('.group-member-list').length,
4373			display_check = $('#group-list-'+gid).css('display');
4374
4375		var input_text = '\
4376			<li class="gm-item forum-group-user-add-li">\
4377				<div class="forum-group-user-add">\
4378					<div class="input-group">\
4379						<input type="text" class="gua-userid forum-control" placeholder="' + $.lang[LANG]['board.enter-member-email.'+mtype] + '"/>\
4380						<span class="input-group-btn hand gua-save" data-id="' + gid + '" data-mtype="' + mtype + '">\
4381							<svg viewBox="0 0 15 10" width="15" height="10" >\
4382								<path d="M14.29 0L5.5 8.79 0.71 4 0 4.71l5.15 5.15C5.24 9.95 5.37 10 5.5 10s0.26-0.05 0.35-0.15L15 0.71 14.29 0z"/>\
4383							</svg>\
4384						</span>\
4385						<div class="gua-cancel">\
4386							<svg viewBox="0 0 12 12" width="12" height="12">\
4387								<polygon points="12 0.71 11.29 0 6 5.29 0.71 0 0 0.71 5.29 6 0 11.29 0.71 12 6 6.71 11.29 12 12 11.29 6.71 6 "/>\
4388							</svg>\
4389						</div>\
4390					</div>\
4391				</div>\
4392			</li>\
4393		',
4394		member_list = '\
4395			<ul class="group-member-list">\
4396			' + input_text + '\
4397			</ul>\
4398			';
4399
4400		if(display_check=='none') {
4401			if($(this).hasClass('group-item')=== false) {
4402		 		groupAddClass(group_member_list_check,$(this),input_text,member_list);
4403			} else {
4404
4405				if($('#group-list-'+gid).is('[data-load="true"]')) {
4406					var glist_html = getGroupMemberList(gid);
4407					$('#group-list-'+gid+' .panel-body').html(glist_html);
4408					$('#group-list-'+gid).removeAttr('data-load');
4409				}
4410			}
4411
4412			$('#group-list-'+gid).slideDown();
4413			$(this).addClass('glOpen');
4414
4415		} else {			
4416			if($(this).hasClass('group-item')===false) {
4417				groupAddClass(group_member_list_check,$(this),input_text,member_list);
4418			} else {
4419				$(this).removeClass('glOpen');
4420				$('#group-list-'+gid).slideUp();
4421			}
4422		}
4423	});
4424	
4425
4426	$doc.on('click','.gua-cancel',function (e) {
4427		var empty_check = $(this).parents('.panel-body').find('.empty').css('display');
4428		if(empty_check == 'none') {
4429			$(this).parent('.panel').find('.group-member-list').remove();
4430			$(this).parents('.panel').find('.empty').show();  
4431		}	
4432		settingEditMode(false);
4433		$('#group-accordion').find('.forum-group-user-add-li').remove();
4434	});
4435
4436	$doc.on('click','.gua-save',function (e) {
4437		if($(this).hasClass('clicked')) return false;
4438		else $(this).addClass('clicked');
4439
4440		var $select_group = $(this).parents('.panel').find('.group-item'),
4441			$add_error = $(this).parents('.gm-item'),
4442			$userid = $('.gua-userid'),
4443			id = $(this).attr('data-id'),
4444			mtype = $(this).attr('data-mtype');
4445
4446		$('.config-error').remove();
4447		var show_error_gua_save = function(error_message) {
4448			$add_error.append('\
4449				<div class="config-error">\
4450					' + clSVG('info',13,13) +'\
4451					<span>' + error_message + '</span>\
4452				</div>\
4453		    ');
4454		    $('.gua-save').removeClass('clicked');
4455		}
4456
4457		if(!$userid.val().trim()) {
4458			show_error_gua_save($.lang[LANG]['board.enter-member-email.um']);
4459			return false;
4460		}
4461		if(checkEmojis($userid.val().trim())) {
4462			show_error_gua_save($.lang[LANG]['config.unable.emoji']);
4463			return false;
4464		}
4465		if(typeof id == 'undefined' || id==null || !id) {
4466			show_error_gua_save('Invalid variable');
4467			return false;
4468		}
4469		$.post('/fm/group/useradd', { id:id, userid:$userid.val().trim().toLowerCase(), mtype:mtype }, function(data) {
4470			if(typeof data.error != 'undefined' || data.error) {
4471				show_error_gua_save(data.error);
4472				return false;
4473			}
4474
4475			if($('.member-search').val()) {
4476				$('#g-stx').val('');
4477				$('#g-sfl option:first-child').attr('selected',true);
4478				$.forum.getgroupdata($('.flat-gc-modal .modal').attr('data-fid'));
4479			}
4480			$select_group.attr('data-member-count',data.count);
4481			$select_group.find('.group-member-count').text(data.count);
4482
4483			settingEditMode(false);
4484
4485			$('#group-accordion').find('.forum-group-user-add-li').remove();
4486			groups = getForumGroupObject();
4487			if($('#el-blockConfig.open').length > 0 && (typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == selectID)) {
4488				bc_fr.group = groups;
4489			}
4490
4491			getGroupMembers(id);
4492			$('.gua-save').removeClass('clicked');
4493
4494		},'json');
4495	});
4496
4497	$doc.on('click','.group-name-edit',function (e) {
4498		$select_group = $(this).parents('.content').prev('.group-item');
4499		var gid = $select_group.attr('data-id'),
4500			gname = $select_group.find('.group-name').text();
4501		if($('#group-accordion').find('.forum-group-update').length > 0) return false;
4502
4503		var input_text = addForumGroupUpdateInput(gid, gname);
4504		$(input_text).appendTo($select_group.closest('.panel-title'));
4505		settingEditMode(true);
4506	});
4507
4508	$doc.on('click','.group-delete',function (e) {
4509		$select_group = $(this).parents('.content').prev('.group-item');
4510		var gid =  $select_group.attr('data-id'),
4511			gname = $select_group.find('.group-name').text();
4512
4513		if($('#group-accordion .group-item').length==1) {
4514			if($('#group-accordion .group-item').find('.config-error').length==0)
4515				$select_group.parents('.panel-title').append('<div class="config-error managegroups-error">\
4516						<svg viewBox="0 0 13 13" width="13" height="13">\
4517		                    <path d="M6.5 0C2.91 0 0 2.91 0 6.5S2.91 13 6.5 13 13 10.09 13 6.5 10.09 0 6.5 0zM6.5 12C3.47 12 1 9.53 1 6.5S3.47 1 6.5 1 12 3.47 12 6.5 9.53 12 6.5 12z"/>\
4518		                    <rect x="6" y="3" width="1" height="5"/>\
4519		                    <rect x="6" y="9" width="1" height="1"/>\
4520		                </svg>\
4521	                <span>' + $.lang[LANG]['board.min-num-groups'] + '</span></div>');
4522			return false;
4523		}
4524		var str = $.lang[LANG]['board.ask-delete-group-2'] + "\
4525		";
4526
4527		$('.modal.modal-default.fade.in').css('zIndex','1029');
4528		var gd_modal = $(this).showModalFlat($.lang[LANG]['board.ask-delete-group.title'], str, true, true, function() {
4529			$.post('/fm/group/delete', { id : gid }, function(data) {
4530				if(typeof data.error != 'undefined' || data.error) {
4531					$('.forum-group-delete .content').append('<div class="config-error">' + data.error + '</div>');
4532					return false;
4533				}
4534				$('#group-accordion .group-item[data-id="' + data.id + '"]').parents('.panel').remove();
4535				$('.flat-gc-modal #g-sfl option[data-id="' + data.id + '"]').remove();
4536				groups = getForumGroupObject();
4537				if($('#el-blockConfig.open').length > 0 && (typeof bc_fr != 'undefined' && typeof bc_fr.block_id != 'undefined' && bc_fr.block_id == selectID)) {
4538					bc_fr.group = groups;
4539				}
4540				gd_modal.modal('hide');
4541			},'json');
4542
4543		}, 'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0','','','',function(){
4544			$('.modal.modal-default.fade.in').css('zIndex','');
4545		});
4546		$('#delete-group-name').text(gname);
4547	});
4548
4549	$doc.on('click','.gmi-del', function (e) {
4550		var userid = $(this).attr('data-userid'),
4551			id = $(this).attr('data-id'),
4552			mtype = $(this).attr('data-mtype'),
4553			$select_group = $('.group-item[data-id="'+id+'"]'),
4554			gmcount = parseInt($select_group.find('.group-member-count').text()),
4555			str = userid + $.lang[LANG]['board.ask-delete-member-from-group'];
4556
4557		$('.modal.modal-default.fade.in').css('zIndex','1029');
4558		var gmid_modal = $(this).showModalFlat($.lang[LANG]['config.information'], str, true, true, function() {
4559			$.post('/fm/group/userdel', { id : id, userid : userid, mtype : mtype }, function(data) {
4560				if(typeof data.error != 'undefined' && data.error) {
4561					$select_group.append('<div class="config-error">' + data.error + '</div>');
4562					return false;
4563				}
4564
4565				$select_group.attr('data-member-count',gmcount-1);
4566				$select_group.find('.group-member-count').text(gmcount-1);
4567
4568				getGroupMembers(id);
4569				gmid_modal.modal('hide');
4570			},'json');
4571		},'cancel', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0','','','',function(){
4572			$('.modal.modal-default.fade.in').css('zIndex','');
4573		});
4574	});
4575
4576
4577	$doc.on('click','#ctrl-forum-group', function(e) {
4578		var id = $(this).attr('data-id');
4579		$.forum.groupconfig(id);
4580	});
4581
4582	$doc.on('click','#bc-default-forum-chlistmod', function(e) {
4583		var id = $('.forum-change-list').attr('data-id'),
4584			hasNoList = $('.forum-change-list').hasClass('noList') ? true : false,
4585			hasDisabled = $('.forum-change-list').hasClass('disabled') ? true : false,
4586			check_count_txt = (hasNoList) ? $.lang[LANG]['editor.forum.faqChangeList.config.noList'] : $.lang[LANG]['editor.forum.faqChangeList.config.disabled'];
4587
4588		if(hasNoList || hasDisabled) {
4589			$(this).showModalFlat($.lang[LANG]['config.information'],check_count_txt,true,false,'','ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70');
4590		} else $.forumChangeList.open(id);
4591	});
4592
4593	$doc.on('change','.property-form-wrap select, #prop-forum-etcmod .switch-input', function(e) {
4594		var id =  $(this).attr('data-id'),
4595			mode = $(this).attr('data-mode'),
4596			value = (mode == 'group') ? $(this).find('option:selected').attr('data-id') : $(this).val();
4597
4598		if(typeof id == 'undefined' || id==null || id=='') {
4599			$(this).showModalFlat('ERROR', $.lang[LANG]['board.error-setting-value'], true, false, '', 'ok');
4600			return false;
4601		}
4602
4603		if(value != 'undefined' && value == 'NULL') {
4604			e.preventDefault();
4605
4606            var upgrade_text = (SERVICE.indexOf('gabia') > -1) ? ((VALIDPLAN && VALIDTYPE == 'BN') ? $.lang[LANG]['board.chmod.upgrade-plan.gabia-bn'] : $.lang[LANG]['board.chmod.upgrade-plan.gabia']) : $.lang[LANG]['board.chmod.upgrade-plan'];
4607			$(this).showModalFlat('INFORMATION', upgrade_text, true, false, '', 'close');
4608            $(this).val( $(this).data('choice') );
4609			return false;
4610		}
4611
4612		if(mode == 'comment') value = ($(this).prop('checked')) ? 'ON' : 'OFF';
4613		if(mode == 'sns') 	  value = ($(this).prop('checked')) ? 'ON' : 'OFF';
4614		if(mode == 'bottomlist') value = ($(this).prop('checked')) ? 'ON' : 'OFF';
4615		if(mode == 'searchbox') value = ($(this).prop('checked')) ? 'ON' : 'OFF';
4616		if(mode == 'captcha') value = ($(this).prop('checked')) ? 'ON' : 'OFF';
4617
4618		var modetype = {
4619			'group' : 'group',
4620			'write'	: 'write_level',
4621			'view'	: 'view_level',
4622			'reply'	: 'reply_level',
4623			'list'	: 'list_level',
4624			'secret' : 'secret_display',
4625			'comment': 'comment_display',
4626			'like': 'like_display',
4627			'sns'	: 'sns_share_display',
4628			'bottomlist': 'bottomlist_display',
4629			'fieldlang' : 'field_lang',
4630			'searchbox': 'searchbox_display',
4631			'date' : 'date',
4632			'captcha' : 'captcha_display',
4633		}, settings = {};
4634
4635		settings[modetype[mode]] = value;
4636
4637
4638		$.post('/template/settings', { sid : F_SID, settings : JSON.stringify(settings), el : id }, function(data) {
4639			if(typeof data.error != 'undefined' && data.error) {
4640				$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
4641				return false;
4642			}
4643			var block_lang = ($('.element[data-id="' + id + '"]').attr('data-blocklang')) ? $('.element[data-id="' + id + '"]').attr('data-blocklang') : LANG;
4644
4645			if(mode == 'fieldlang') {
4646				$('.element[data-id="' + id + '"]').attr('data-fieldlang',value.toLowerCase());
4647				$('.element[data-id="' + id + '"] thead tr th').each(function() {
4648					var field_text = (typeof $(this).attr('class') != 'undefined') ? $(this).attr('class') : 'tpl-forum-title';
4649					if(field_text.indexOf('title') > -1 || field_text.indexOf('content') > -1) $(this).text($.lang[value.toLowerCase()]['forum.field.tpl-forum-title']);
4650					else $(this).text($.lang[value.toLowerCase()]['forum.field.' + field_text]);
4651				});
4652
4653				if($('.element[data-id="' + id + '"]').attr('data-type') == 'forum' && $('.element[data-id="' + id + '"]').attr('data-type2') == 'qna') {
4654					$('.element[data-id="' + id + '"] .qna-item .tpl-forum-list-state').each(function(i) {
4655                        if($(this).closest('.qna-item').find('.tpl-forum-list-num').hasClass('n')) $(this).text('');
4656                        else if(typeof $(this).attr('data-state') != 'undefined' && $(this).attr('data-state') == 'true') $(this).text($.lang[block_lang]['forum.qna.state.replied']);
4657						else $(this).text($.lang[block_lang]['forum.qna.state.waiting']);
4658					});
4659				}
4660	
4661				$('.element[data-id="' + id + '"]').find('.tpl-forum-write').text($.lang[value.toLowerCase()]['forum.field.tpl-forum-write']);
4662			}
4663			if(mode == 'searchbox') {
4664				if(value == 'ON') { $('.element[data-id="' + id + '"]').find('.search-box').removeClass('hidden'); } 
4665				else { $('.element[data-id="' + id + '"]').find('.search-box').addClass('hidden'); }
4666			}
4667			if(mode == 'date') {
4668				var page = F_PAGE,
4669					page_num = 1,
4670					view = $('.element.active').find('.tpl-forum-pagination li').first().attr('data-view'),
4671					sfl = '',
4672					stx = '',
4673					scate = '';
4674
4675				$.forum.setForumCookie(id,page_num,stx,sfl,scate);
4676				cookie_page_num = $.cookie('forum_'+id);
4677				$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
4678				activeEL('userEL'+id);
4679			}
4680
4681		}, 'json');
4682	});
4683	
4684	var getForumGroupObject = function() {
4685		var $select = $('#group-accordion .group-item');
4686		groups = [];
4687		$.each($select,function(i,v) {
4688			groups[i] = {
4689				'id' : $(this).attr('data-id'),
4690				'name' : $(this).find('.group-name').text(),
4691				'member_count' : $(this).attr('data-member-count')
4692			}
4693		});
4694		return groups;
4695	}
4696
4697	var deleteForumPost = function(id) {
4698
4699			$.post('/fm/delete', { id : id, user : user }, function(data) {
4700				if(typeof data.error != 'undefined' && data.error) {
4701					$('.flat-modal .modal').modal('hide');
4702					var modal = $(this).showModalFlat('ERROR', data.error, true, false, '', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title');
4703					return false;
4704				}
4705
4706				//this case:: forum QnA / FAQ block, answer delete =>> page refresh
4707				var checkPageReload = (	$('.element[data-type="forum"][data-type2="qna"] .qna-details .tpl-toolbar-question-del[data-id="' + id + '"]').length > 0 
4708										|| $('.fctrl-item[data-cmd="del"]').attr('data-seq') == id
4709										|| $(`.element[data-type="forum"][data-type2="faq"] .tpl-forum-faq-ctrl [data-id="${id}"]`).length > 0
4710									) ? true : false;
4711
4712				if( $('.page-bottomlist').length > 0 && $('.page-bottomlist').attr('data-pid') === id ) {
4713					checkPageReload = false;				
4714				}
4715				
4716				if(checkPageReload) location.reload();
4717				else $('.tpl-forum-list').click();
4718
4719				// modal.modal('hide');
4720			},'json');
4721
4722	}
4723
4724	var deleteGuestbook = function(pid, id) {
4725		$.post('/fm/delete', { id : id, user : user }, function(data) {
4726			if(typeof data.error != 'undefined' && data.error) {
4727				$('.flat-modal .modal').modal('hide');
4728				var modal = $(this).showModalFlat('ERROR', data.error, true, false, '', 'ok','','cl-cmmodal cl-s-btn w560 cl-p130 cl-t80 cl-modal cl-none-title');
4729				return false;
4730			} else {
4731				var view = $('.element[data-id="' + pid + '"]').find('[data-view]').attr('data-view');
4732				$.forum.init(pid, 1, view);
4733			}
4734		},'json');
4735	}
4736
4737	var setForumPagination = function($obj, total, view, page_num, id, page) {
4738		var page_view = 5,
4739		    start = Math.floor((page_num-1) / page_view) * page_view,
4740		    pages = Math.ceil(total/view),
4741		    end = (Math.floor((page_num-1) / page_view) + 1) * page_view,
4742		    end = (end>pages) ? pages : end,
4743		    prev = (start > 0) ? start : 1,
4744		    next = ((end+1) > pages) ? pages : end+1;
4745		$obj.find('li').addClass('tpl-forum-page');
4746
4747		var arrow_selector = `.userEL${$obj.parents('.element').data('id')}`,
4748			arrow_str = (document.querySelector(arrow_selector) != null) ? getComputedStyle(document.querySelector(arrow_selector)).getPropertyValue('--pagination-arrow') : '',
4749			arrow_arr = arrow_str.trim().split(','),
4750			arrow_obj = {
4751				check: arrow_arr[0] ? true : false,
4752				type: arrow_arr[0] || '1',
4753				w: arrow_arr[1] || '12',
4754				h: arrow_arr[2] || '12',
4755			};
4756
4757		if(!arrow_obj.check && $obj.children().first().find('svg').length == 0) {
4758			arrow_obj.arrow = [`<i class="fa fa-angle-double-left"></i>`,`<i class="fa fa-angle-double-right"></i>`];
4759		} else {
4760			arrow_obj.arrow = [clSVG(`forum_arrow${arrow_obj.type}_2`, arrow_obj.w, arrow_obj.h),clSVG(`forum_arrow${arrow_obj.type}_2`, arrow_obj.w, arrow_obj.h)];
4761		}
4762
4763		var $prev = $obj.children().first().clone(),
4764			$next = $obj.children().last().clone();
4765		$prev.attr({'data-page': page, 'data-id': id, 'data-view': view, 'data-page-num':prev});
4766		$next.attr({'data-page': page, 'data-id': id, 'data-view': view, 'data-page-num':next});
4767
4768		var $first = $prev.clone(),
4769			$last = $next.clone();
4770		$first.attr({'data-page-num':'1'}).find('a').empty().append(arrow_obj.arrow[0]);
4771		$last.attr({'data-page-num':pages}).find('a').empty().append(arrow_obj.arrow[1]);
4772
4773		$obj.empty().append($prev).append($next);
4774
4775		for(i=start;i<end;i++) {
4776			var active = ((i+1) == page_num) ? 'active' : '';
4777			$obj.children().last().before($(`
4778					<li class="tpl-forum-page ${active}" data-id="${id}" data-page="${page}" data-view="${view}" data-page-num="${i+1}" data-pid="${id}">
4779						<a href="#">${i+1}</a>
4780					</li>
4781				`));
4782		}
4783
4784		if(pages>1 && pages>=page_num && pages>page_view) $obj.prepend($first).append($last);
4785	}
4786
4787
4788	var getGroupMembers = function(id, userid) {
4789		userid = (typeof userid == 'undefined' || !userid) ? '' : userid;
4790		var $grouplist = $('#group-list-'+id+' .panel-body');
4791		$grouplist.find('.empty').remove();
4792		$grouplist.find('.group-member-list').remove();
4793
4794		$grouplist.append(getGroupMemberList(id,userid));
4795	}
4796
4797	var setMemberPagination = function($obj,total,page_num,id) {
4798		var page_view = 10, view = 10,
4799		    start = Math.floor((page_num-1) / page_view) * page_view,
4800		    pages = Math.ceil(total/view),
4801		    end = (Math.floor((page_num-1) / page_view) + 1) * page_view,
4802		    end = (end>pages) ? pages : end,
4803		    prev = (start > 0) ? start : 1,
4804		    next = ((end+1) > pages) ? pages : end+1;
4805
4806		var $prev = $('<li class="forum-group-member-pagination" data-id="' + id + '" data-view="' + page_view + '" data-page-num="' + prev + '"><a href="#"><i class="fa fa-angle-left"></i></a></li>'),
4807			$next = $('<li class="forum-group-member-pagination" data-id="' + id + '" data-view="' + page_view + '" data-page-num="' + next + '"><a href="#"><i class="fa fa-angle-right"></i></a></li>');
4808			
4809		$obj.empty();
4810		$obj.append($prev);
4811		for(i=start;i<end;i++) {
4812			var active = ((i+1) == page_num) ? 'active' : '';
4813			$obj.append($('<li class="forum-group-member-pagination ' + active + '" data-id="' + id + '" data-view="' + page_view + '" data-page-num="' + (i+1) + '"><a href="#">' + (i+1) + '</a></li>'));
4814		}
4815		if(end==0) { 
4816			$obj.append($('<li class="forum-group-member-pagination" data-id="' + id + '" data-view="' + page_view + '" data-page-num="0"><a href="#">1</a></li>'));
4817		}
4818		$obj.append($next);
4819	}
4820
4821	$doc.on('click','.forum-group-member-pagination', function(e) {
4822		var id = $(this).attr('data-id'),
4823			page = $(this).attr('data-page-num');
4824		if(page==0) return false;
4825	});
4826
4827	var tplmemberSearch = function(id) {
4828		var str = '\
4829			<div class="forum-member-search">\
4830				<input type="text" class="config-input member-search" placeholder="' + $.lang[LANG]['board.enter-member-id'] + '">\
4831				<span class="btn btn-forum-config btn-forum-group-search" data-toggle="tooltip" data-placement="top" title="SEARCH" data-id="' + id + '" style="margin-top:-3px;height:39px;"><i class="fa fa-check"></i></span>\
4832			</div>\
4833		';
4834		return str;
4835	}
4836
4837	$doc.on('change','#g-sfl',function(e) {
4838		$('.btn-forum-group-search').click();
4839	});
4840
4841	$doc.on('click','.btn-forum-group-search',function(e) {
4842		if($(this).hasClass('clicked')) return false;
4843		else $(this).addClass('clicked');
4844
4845		var id = $(this).attr('data-id'),
4846			gsfl = $('#g-sfl option:selected').attr('data-id'),
4847			gstx = $('#g-stx').val().toLowerCase().trim(),
4848			mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink',
4849			str = '';
4850
4851		if(checkEmojis(gstx)) {
4852			e.preventDefault();
4853			$('.btn-forum-group-search').removeClass('clicked');
4854			errorEmojisModal();
4855			return false;
4856		}
4857
4858		$.post('/fm/group/membersearch', { id : id, gsfl : gsfl, gstx : gstx, mtype:mtype }, function(data) {
4859			if(typeof data.error != 'undefined' && data.error) {
4860				$('#group-accordion').html('<div class="empty">' + data.error + '</div>');
4861				$('.btn-forum-group-search').removeClass('clicked');
4862				return false;
4863			}
4864			if(!$.isNumeric(gsfl) && !gstx) {
4865				$('#g-stx').val('');
4866				$('#g-sfl option:first-child').attr('selected',true);
4867				$.forum.getgroupdata($('.flat-gc-modal .modal').attr('data-fid'));
4868				$('.btn-forum-group-search').removeClass('clicked');
4869				return false;
4870			}
4871
4872			if(data.total>0) {
4873				var group = '',
4874					mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink';
4875
4876				$.each(data.list, function(i,v) {
4877					if(group != v.fg_id) {
4878						group = v.fg_id;
4879						str = (group=='') ? '' : str + '\
4880									</ul>\
4881								</div>\
4882							</div>\
4883						</div>\
4884						';
4885						str = str + '\
4886						<div class="panel">\
4887							<div class="panel-heading">\
4888								<div class="panel-title">\
4889									<a class="accordion-toggle collapsed group-item" data-id="' + group + '" data-member-count="' + v.fg_member_count + '">\
4890										<label class="group-name hand">' + v.fg_name + '</label>\
4891										<span class="group-member-count">' + v.fg_member_count + '</span>\
4892										<svg viewBox="0 0 8 4" width="8" height="4"><polygon points="0 0 4 4 8 0 "/></svg>\
4893									</a>\
4894									<div class="content">\
4895										<span>\
4896											<svg viewBox="0 0 13 13" width="13" height="13" class="group-user-add hand">\
4897												<polygon points="13 2 11 2 11 0 10 0 10 2 8 2 8 3 10 3 10 5 11 5 11 3 13 3 "/>\
4898												<path d="M6.83 8.36C7.54 7.81 8 6.96 8 6c0-1.66-1.34-3-3-3S2 4.34 2 6c0 0.96 0.46 1.81 1.17 2.36C1.31 9.09 0 10.89 0 13h1c0-2.21 1.79-4 4-4s4 1.79 4 4h1C10 10.89 8.69 9.09 6.83 8.36zM3 6c0-1.1 0.9-2 2-2 1.1 0 2 0.9 2 2S6.1 8 5 8C3.9 8 3 7.1 3 6z"/>\
4899											</svg>\
4900										</span>\
4901										<span>\
4902											<svg viewBox="0 0 13 13" width="13" height="13" class="group-name-edit hand">\
4903												<path d="M4.32 8.05C4.2 8.39 4.46 8.71 4.79 8.71c0.05 0 0.11-0.01 0.16-0.03L7 8l6-6-2-2L5 6 4.32 8.05zM5.87 6.54L11 1.41 11.59 2 6.46 7.13 5.58 7.42 5.87 6.54z"/>\
4904												<path d="M9 11c0 0.55-0.45 1-1 1H2c-0.55 0-1-0.45-1-1V4c0-0.55 0.45-1 1-1h3V2H2C0.9 2 0 2.9 0 4v7c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V8H9V11z"/>\
4905											</svg>\
4906										</span>\
4907										<span>\
4908											<svg viewBox="0 0 12 13" width="12" height="13" class="group-delete hand">\
4909												<path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/>\
4910												<rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/>\
4911											</svg>\
4912										</span>\
4913									</div>\
4914								</div>\
4915							</div>\
4916							<div id="group-list-' + group + '" class="panel-collapse" style="display:none;">\
4917								<div class="panel-body">\
4918									<ul class="group-member-list">\
4919						';
4920					}
4921					if(v.fg_member_count!=0) {
4922						str += '\
4923										<li class="gm-item">\
4924											<div>\
4925												<div class="gmi-img">\
4926													<span class="hexagon">\
4927														<img src="'+v.img+'" alt="" class="img-responsive">\
4928													</span>\
4929												</div>\
4930					                			<div class="gmi-info">\
4931					    ';
4932					    if(v.name != v.id && v.name) {
4933						    str += '\
4934						                			<span class="gmi-name">' + v.name + '</span>\
4935							';
4936						}
4937						str += '\
4938						                			<span class="gmi-id">' + v.id + '</span>\
4939					                			</div>\
4940					                			<div class="gmi-btn">\
4941													<svg viewBox="0 0 12 13" width="12" height="13" class="gmi-del hand" data-userid="' + v.id + '" data-id="' + v.fg_id + '">\
4942														<path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/>\
4943														<rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/>\
4944													</svg>\
4945												</div>\
4946											</div>\
4947										</li>\
4948						';
4949					} else {
4950						str = str + '<div class="empty">' + $.lang[LANG]['board.group-no-members'] + '</div>';
4951					}
4952				});
4953				str = str + '\
4954									</ul>\
4955								</div>\
4956							</div>\
4957						</div>\
4958				';
4959			}
4960			//  else {
4961			// 	str = '<div class="empty">' + $.lang[LANG]['board.empty-member-in-group'] + '</div>';
4962			// }
4963			$('#group-accordion').html(str);
4964			$('.btn-forum-group-search').removeClass('clicked');
4965
4966		}, 'json');
4967	});
4968
4969	var displayMember = function(mb) {
4970		var str = '\
4971			<li>\
4972				<span class="userimg"><img src="' + mb.img + '"></span>\
4973				<span class="user-info"><div class="user-name">' + mb.name + '</div><div class="user-id">' + mb.id + '</div></span>\
4974				<div class="userdel" data-userid="' + mb.id + '" data-id="' + mb.fg_id + '"><i class="fa fa-trash-o"></i></div>\
4975			</li>\
4976		';
4977		return str;
4978	}
4979
4980	$doc.on('click','.member .userdel', function(e) {
4981		var userid = $(this).attr('data-userid'),
4982			id = $(this).attr('data-id'),
4983			mtype = (SERVICE.indexOf('gabia') > -1 || VALIDTYPE == 'SM' || (VALIDTYPE == 'BN' && SITEUM > 0)) ? 'um' : 'creatorlink';
4984
4985		initControlForm();
4986		$('.delete-member-userid').text(userid);
4987		$('.btn-forum-group-delete-member-ok').attr('data-userid',userid).attr('data-id',id).attr('data-mtype',mtype);
4988		$('.forum-group-delete-member-confirm').show();
4989	});
4990
4991	$doc.on('click','.btn-forum-group-delete-member-ok',function(e) {
4992		var userid = $(this).attr('data-userid'),
4993			id = $(this).attr('data-id'),
4994			mtype = $(this).attr('data-mtype');
4995
4996		$.post('/fm/group/userdel', { id : id, userid : userid, mtype : mtype }, function(data) {
4997			if(typeof data.error != 'undefined' && data.error) {
4998				$('.forum-group-delete-member-confirm .content').append('<div class="config-error">' + data.error + '</div>')
4999				return false;
5000			}
5001		},'json');
5002	});
5003
5004
5005	$doc.on('change','#scate', function(e) {
5006		var dataCheck =  ($(this).parents('.element').find('.tpl-forum-pagination').children().length > 0) ? true :  false;
5007		
5008		$this_pagination = $(this).parents('.element').find('.tpl-forum-pagination li.active');
5009		var sfl = $(this).parents('.search-box').find('#sfl').val(),
5010			stx = '',
5011			scate = $(this).find('option:selected').val(),
5012			id = (dataCheck) ? $this_pagination.attr('data-id') : $(this).parents('.element').attr('data-id'),
5013			page = (dataCheck) ? $this_pagination.attr('data-page') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-page'),
5014			page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
5015			view = (dataCheck) ? $this_pagination.attr('data-view') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-view');
5016
5017		stx = getForumPrevStx(id);
5018    	$.forum.setForumCookie(id,page_num,stx,sfl,scate);
5019		cookie_page_num = $.cookie('forum_'+id);
5020		$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
5021		activeEL('userEL'+id);
5022	});
5023
5024	$('.search-btn').live('click', function(e) {
5025		if($(this).parents('.element').attr('data-type') != 'forum') return false;
5026		e.preventDefault();
5027		var dataCheck =  ($(this).parents('.element').find('.tpl-forum-pagination').children().length > 0) ? true :  false;
5028		
5029		$this_pagination = $(this).parents('.element').find('.tpl-forum-pagination li.active');
5030		var sfl = $(this).parents('.search-box').find('#sfl').val(),
5031			stx = $(this).parents('.search-box').find('#stx').val(),
5032			scate = ($(this).parents('.search-box').find('#scate option:selected').length > 0) ? $(this).parents('.search-box').find('#scate option:selected').val() : '',
5033			id = (dataCheck) ? $this_pagination.attr('data-id') : $(this).parents('.element').attr('data-id'),
5034			page = (dataCheck) ? $this_pagination.attr('data-page') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-page'),
5035			page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
5036			view = (dataCheck) ? $this_pagination.attr('data-view') : $(this).parents('.element').find('.tpl-forum-pagination').attr('data-view');
5037
5038		var regexp = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+┼<>@\#$%&\'\"\\\(\=“‘,]/gi;
5039		if(regexp.test(stx) || regexp.test(scate)) {
5040			$(this).showModalFlat('ERROR', '특수문자를 입력할 수 없습니다.', true , false, '', 'close');
5041			return false;
5042		}
5043
5044    	$.forum.setForumCookie(id,page_num,stx,sfl,scate);
5045		cookie_page_num = $.cookie('forum_'+id);
5046		$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
5047		activeEL('userEL'+id);
5048	});
5049
5050	$doc.on('keypress','input#stx', function (e) {
5051		if(e.which == 13 && $(this).val().length>0) $(this).closest('.search-box').find('.search-btn').click();
5052	});
5053
5054	$('.element[data-type="forum"]:not([data-type2="guestbook"]) .search-forum-user-posts').die('click');
5055	$('.element[data-type="forum"]:not([data-type2="guestbook"]) .search-forum-user-posts').live('click', function(e) {
5056		e.stopPropagation();
5057		var parentEl = $(this).parents('.element');
5058		var dataCheck =  (parentEl.find('.tpl-forum-pagination').children().length > 0) ? true :  false;
5059		
5060		$this_pagination = parentEl.find('.tpl-forum-pagination li.active');
5061		var stx = $(this).attr('data-userid'),
5062			sfl = (stx)? 'mb_id' : 'nonmem',
5063			scate = '',
5064			id = (dataCheck) ? $this_pagination.attr('data-id') : parentEl.attr('data-id'),
5065			page = (dataCheck) ? $this_pagination.attr('data-page') : parentEl.find('.tpl-forum-pagination').attr('data-page'),
5066			page_num = (dataCheck) ? $this_pagination.attr('data-page-num') : 1,
5067			view = (dataCheck) ? $this_pagination.attr('data-view') : parentEl.find('.tpl-forum-pagination').attr('data-view');
5068		if(!stx) {
5069			stx = $(this).attr('data-username');
5070		}
5071
5072    	$.forum.setForumCookie(id,page_num,stx,sfl,scate);
5073		cookie_page_num = $.cookie('forum_'+id);
5074		$.forum.init(id,page,view,cookie_page_num,sfl,stx,scate);
5075		activeEL('userEL'+id);
5076	});
5077
5078	$(document).on('mousedown','.fr-file',function(e) {
5079		if(PAGE_MODE!='c') {
5080			var url = new getLocation($(this).closest('[data-href]').attr('data-href')),
5081				file_name = encodeURIComponent($(this).find('.fr-file-nm').text().trim() + $(this).find('.fr-file-ext').text().trim());
5082			file_name = file_name == '' ? $(this).text().trim() : file_name;
5083			var go = '/down?n=' + file_name + '&s=' + (url.pathname).replace('/cr-resource/forum/','').replace('/','&f=');
5084			window.open(go,'_blank');
5085		}
5086	});
5087
5088
5089	function groupAddClass(group_member_list_check, $select, input_text, member_list) {
5090
5091		$select.parents('.panel').find('.empty').hide();
5092		if(group_member_list_check > 0) $select.parents('.panel').find('.group-member-list').prepend(input_text);		
5093		else $select.parents('.panel').find('.panel-body').append(member_list);
5094		settingEditMode(true);
5095	}
5096
5097
5098
5099
5100	$doc.on('hidden.bs.modal', '.flat-forum-category-modal', function() {
5101		var fcategory_str = '';
5102		$(this).find('.forum-category-name').each(function(idx) {
5103			fcategory_str += (idx == 0) ? $(this).text() : ', '+$(this).text();
5104		});
5105
5106		var pid = $(this).find('.modal[id*=flat-modal]').attr('data-pid');
5107		if(	$('.element[data-id="' + pid + '"]').find('#scate').length > 0 && 
5108			$('.element[data-id="' + pid + '"]').find('#scate').css('display') !== 'none'
5109		) {
5110			$.forum.drawSelboxCategory($('.element[data-id="' + pid + '"]'),pid);
5111		}
5112
5113		if(!fcategory_str) fcategory_str = $.lang[LANG]['editor.category.empty'];
5114		if($('#el-blockConfig').length > 0) $('#ctrl-card-list-category .selected-category').text(fcategory_str);
5115		$(this).remove();
5116	});
5117
5118	var openForumCategoryConfig = function(id) {
5119		var str = '';
5120		if(typeof id == 'undefined' && typeof selectID != 'undefined') id = selectID;
5121
5122		$.post('/fm/category/list', { pid: id, sid: F_SID }, function(data) {
5123			if(typeof data.error != 'undefined' && data.error) {
5124				$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
5125				return false;
5126			}
5127			var forum_cate_modal = $(this).showModalFlat($.lang[LANG]['editor.forum.category.config'], categoryConfigForum(data,id),true,false,'','close', 'ok', 'cl-cmmodal cl-s-btn w560 cl-p70 cl-p0 forum-category-modal',true).attr({'data-pid':id}).closest('.flat-modal').addClass('flat-forum-category-modal');
5128		}, 'json');
5129
5130
5131        $('.forum-category-content:not(.empty)').sortable({
5132            items: '.forum-category-item',
5133            cancel: '.forum-category-update-cancel, button, .forum-category-update-name',
5134            handle: '.forum-category-info > .icons.cl-sort-handle svg',
5135            init: function(event,ui) {
5136                var start_idx = -1,
5137                	pid = '';
5138            },
5139            start: function(event,ui) {
5140                start_idx = ui.item.index();
5141                pid = $('.'+selectEL).attr('data-id');
5142            },
5143            update: function (event, ui) { 
5144                $(this).children().each(function(i,o) {
5145            		$(this).attr('id','forumCateSort'+i).attr('data-idx',i);
5146					$(this).find('[data-idx]').each(function() { $(this).attr('data-idx',i); });
5147					$.post('/fm/category/replace', { sid : F_SID, pid : pid, cate : $(this).attr('data-cate'), code : i+1 }, function(data) {
5148            			if(typeof data.error != 'undefined' && data.error) {
5149							$(this).showModalFlat('ERROR',data.error,true,false,'','ok');
5150							return false;
5151						}
5152					},'json');
5153                });
5154            }
5155        }).disableSelection();
5156	};
5157
5158	$doc.on('click','#el-blockConfig .forum-category-config',function(e) {
5159		openForumCategoryConfig(selectID);
5160	});
5161
5162        
5163
5164	//forum category Config (Add.Edit.Remove)
5165	var categoryConfigForum = function (data,id) {
5166		var empty = (data.length > 0) ? '' : 'empty',
5167			forum_category_list = '',
5168			str = '';
5169
5170		$.each(data, function(i,v) {
5171			if(v) forum_category_list = forum_category_list + forumCategoryItem(v.fca_name.trim(), i,v.seq);
5172		});
5173
5174		forum_category_list = (empty) ? '<p>' + $.lang[LANG]['editor.category.empty'] + '</p>' : forum_category_list;
5175
5176		str = '\
5177        <div class="forum-category-header">\
5178            <p>' + $.lang[LANG]['editor.category.description'] + '</p>\
5179        </div>\
5180        <div class="forum-category-content ' + empty + '">\
5181            ' + forum_category_list + '\
5182        </div>\
5183        <div class="btn-wrap">\
5184        	<span class="btn forum-category-add">\
5185				<svg viewBox="0 0 12 12" width="12" height="12"><polygon points="12 5 7 5 7 0 5 0 5 5 0 5 0 7 5 7 5 12 7 12 7 7 12 7 "/></svg>\
5186				' + $.lang[LANG]['config.gallery.add'] + '\
5187			</span>\
5188        </div>\
5189        ';
5190		return str;
5191	}
5192
5193	var forumCategoryItem = function(name,idx,seq) {
5194		var categoryAdd = (!name) ? 'additem' : '',
5195			cate_seq = (!seq) ? '' : seq;
5196
5197		var str = '\
5198			<div class="forum-category-item ' + categoryAdd + '" id="forumCateSort' + idx + '" data-idx="' + idx + '" data-cate="' + cate_seq + '">\
5199				<div class="forum-category-info">\
5200					<span class="icons cl-sort-handle">\
5201						' + clSVG('move_handle', 20, 20) + '\
5202					</span>\
5203					<span class="forum-category-name">' + name + '</span>\
5204				</div>\
5205				<div class="forum-config-icons">\
5206					<div class="icons hand">\
5207						<svg viewBox="0 0 13 13" width="13" height="13" class="forum-category-edit" data-idx="' + idx + '">\
5208							<path d="M4.32 8.05C4.2 8.39 4.46 8.71 4.79 8.71c0.05 0 0.11-0.01 0.16-0.03L7 8l6-6-2-2L5 6 4.32 8.05zM5.87 6.54L11 1.41 11.59 2 6.46 7.13 5.58 7.42 5.87 6.54z"/><path d="M9 11c0 0.55-0.45 1-1 1H2c-0.55 0-1-0.45-1-1V4c0-0.55 0.45-1 1-1h3V2H2C0.9 2 0 2.9 0 4v7c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V8H9V11z"/>\
5209						</svg>\
5210					</div>\
5211					<div class="icons hand">\
5212						<svg viewBox="0 0 12 13" width="12" height="13" class="forum-category-delete hand" data-idx="' + idx + '">\
5213							<path d="M12 2h-1H9V0H3.02v2H1 0v1h1v8c0 1.1 0.9 2 2 2h6c1.1 0 2-0.9 2-2V3h1V2zM4.02 1H8v1H4.02V1zM10 11c0 0.55-0.45 1-1 1H3c-0.55 0-1-0.45-1-1V3h1.02H9h1V11z"/><rect x="4" y="4" width="1" height="7"/><rect x="7" y="4" width="1" height="7"/>\
5214						</svg>\
5215					</div>\
5216				</div>\
5217			</div>\
5218		';
5219		return str;
5220	}
5221
5222	var forumCategoryItemEmptyCheck = function() {
5223		if($('.forum-category-content').find('.forum-category-item').length == 0) {
5224			$('.forum-category-content').addClass('empty').html('<p>' + $.lang[LANG]['editor.category.empty'] + '</p>');
5225		} else {
5226			$('.forum-category-content').removeClass('empty').find('p').remove();
5227
5228			$('.forum-category-content:not(.empty)').sortable({
5229				items: '.forum-category-item',
5230				cancel: '.forum-category-update-cancel, button, .forum-category-update-name',
5231				handle: '.forum-category-info > .icons.cl-sort-handle svg',
5232				update: function (event, ui) {
5233				}
5234			}).disableSelection();
5235		}
5236	}
5237
5238	var addForumCategoryInput = function(cateidx, catename, cateseq) {
5239		var cateidx = (typeof cateidx == 'undefined' || !cateidx) ? $('.forum-category-content .forum-category-item').length : cateidx;
5240		var cateseq = (typeof cateseq == 'undefined' || !cateseq) ? '' : cateseq;
5241		var catename = (typeof catename == 'undefined' || !catename) ? '' : catename;
5242		// var catecode = (typeof catecode == 'undefined' || !catecode) ? Number($('.forum-category-content .forum-category-item').last().attr('data-code')) + 1 : catecode;
5243
5244		return `
5245				<div class="forum-category-update">
5246					<div class="input-group">
5247						<input type="text" class="forum-category-update-name forum-control" placeholder="${$.lang[LANG]['editor.gallery.category.enter-name']}" value="${catename}"/>
5248						<span class="input-group-btn">
5249							<button class="forum-category-update-save btn btn-active" data-id="${selectID}" data-idx="${cateidx}" data-cate="${cateseq}">
5250								<svg viewBox="0 0 15 10" width="15" height="10"><path d="M14.29 0L5.5 8.79 0.71 4 0 4.71l5.15 5.15C5.24 9.95 5.37 10 5.5 10s0.26-0.05 0.35-0.15L15 0.71 14.29 0z"/></svg>
5251							</button>
5252						</span>
5253						<div class="forum-category-update-cancel">
5254							<svg viewBox="0 0 12 12" width="12" height="12"><polygon points="12 0.71 11.29 0 6 5.29 0.71 0 0 0.71 5.29 6 0 11.29 0.71 12 6 6.71 11.29 12 12 11.29 6.71 6 "/></svg>
5255						</div>
5256					</div>
5257				</div>
5258		`;
5259	}
5260
5261	$doc.on('click', '.forum-category-delete', function(e) {
5262		// var checkLast = ($(this).closest('.forum-category-content').find('.forum-category-item').length <= 1) ? true : false;
5263		// if(checkLast) {
5264		// 	$(this).showModalFlat($.lang[LANG]['config.information'], $.lang[LANG]['editor.gallery.category.delete.last'], true, false, '', 'ok','', 'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-okbtn-pbt70');
5265		// 	return false;
5266		// }
5267		
5268        var idx = $(this).attr('data-idx');
5269        var cate = $('.forum-category-content #forumCateSort'+idx).attr('data-cate');
5270        var category_del_modal = $(this).showModalFlat($.lang[LANG]['editor.gallery.category.delete.title'], $.lang[LANG]['editor.gallery.category.delete'], true, true, function() {
5271
5272			$.post('/fm/category/delete', {  sid : F_SID, pid : selectID, cate: cate}, function(data) {
5273				if(typeof data.error != 'undefined' && data.error) {
5274					return false;
5275				}
5276	            $('.forum-category-content #forumCateSort'+idx).remove();
5277	            $('.'+selectEL).find('#scate option[value="' + data.seq + '"]').remove();
5278				$('.'+selectEL).find('.tpl-forum-list-category[data-cate="' + cate + '"]').text('');
5279
5280				$('.forum-category-content .forum-category-item').each(function(i) {
5281					$(this).attr('id','forumCateSort'+i).attr('data-idx',i);
5282					$(this).find('[data-idx]').each(function() { $(this).attr('data-idx',i); });
5283				});
5284
5285				forumCategoryItemEmptyCheck();
5286				category_del_modal.modal('hide');
5287			},'json');
5288
5289        },'cancel','','cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 zindex1046');
5290
5291	});
5292
5293	$doc.on('click', '.forum-category-add', function(e) {
5294		if($('.forum-category-content').find('.forum-category-update').length > 0 ) {
5295			$('.forum-category-content').find('.forum-category-update-name').focus();
5296			return false;
5297		}
5298		
5299        var idx = $('.forum-category-content .forum-category-item').length;
5300        var str = forumCategoryItem('',idx,'');
5301		// var code = (idx > 0) ? Number($('.forum-category-content .forum-category-item').last().attr('data-code')) + 1 : 1,
5302
5303        $('.forum-category-content').append(str);
5304
5305        forumCategoryItemEmptyCheck();
5306        $('.forum-category-edit[data-idx=' +idx +']').click();
5307	});
5308
5309	$doc.on('click', '.forum-category-edit', function(e) {
5310        if($('.forum-category-content').find('.forum-category-update').length>0) return false;
5311
5312        var cate_idx = $(this).attr('data-idx');
5313		var cate_seq = $('.forum-category-content').find('#forumCateSort'+cate_idx).attr('data-cate');
5314		var cate_name = $('.forum-category-content').find('#forumCateSort'+cate_idx).find('.forum-category-name').text();
5315
5316        var input_text = addForumCategoryInput(cate_idx,cate_name,cate_seq);
5317
5318        $(input_text).appendTo($('.forum-category-content').find('#forumCateSort'+cate_idx).find('.forum-category-info'));
5319        
5320        $('.forum-category-content').find('.forum-category-item').css('pointer-events','none');
5321        $('.forum-category-content').find('.forum-category-update-cancel, .forum-category-update-save, .forum-category-update-name').css('pointer-events','auto');
5322        $('.forum-category-update .forum-category-update-name').focus();
5323	});
5324
5325	$doc.on('click', '.forum-category-update-cancel', function(e) {
5326		if(!$(this).closest('.forum-category-info').find('.forum-category-name').text()) {
5327			$(this).closest('.forum-category-item').remove();
5328			forumCategoryItemEmptyCheck();
5329		}
5330		$('.forum-category-content').find('.config-error').remove();
5331		$('.forum-category-content').find('.forum-category-item').removeAttr('style');
5332		$('.forum-category-content').find('.forum-category-update').remove();
5333	});
5334
5335	$doc.on('click', '.forum-category-update-save', function(e) {
5336		if($(this).hasClass('clicked')) return false;
5337		else $(this).addClass('clicked');
5338
5339        var pid = $(this).attr('data-id');
5340        var idx = $(this).attr('data-idx');
5341        var cate_seq = $('.forum-category-content').find('#forumCateSort'+idx).attr('data-cate');
5342        var position = $('.forum-category-content');
5343        var category_name = $('.forum-category-update-name').val().trim();
5344        var category_prev = position.find(`#forumCateSort${idx} .forum-category-name`).text().trim();
5345		var categoryRegexp =  /[\[\]|,'"<>{}\/\\:;%&@$!*?\^]/;
5346
5347        $position = (position.find('.forum-category-item').length > idx) ? position.find(`#forumCateSort${idx}`) : position;
5348
5349        $('.config-error').remove();
5350		var show_error_fc_save = function(error_message) {
5351			$position.append('\
5352				<div class="config-error">\
5353					' + clSVG('info',13,13) +'\
5354					<span>' + error_message + '</span>\
5355				</div>\
5356		    ');
5357		    $('.forum-category-update-save').removeClass('clicked');
5358		}
5359
5360        if(category_prev == category_name) {
5361            if($('.forum-category-content #forumCateSort'+idx).hasClass('additem')) {
5362            	show_error_fc_save($.lang[LANG]['editor.gallery.category.enter-name']);
5363            } else {
5364                $('.forum-category-content').find('.forum-category-item').removeAttr('style');
5365                $('.forum-category-content').find('.forum-category-update').remove();
5366                $('.forum-category-update-save').removeClass('clicked');
5367            }
5368            return false;
5369        }
5370        if(categoryRegexp.test(category_name)) {
5371        	show_error_fc_save($.lang[LANG]['board.allowed-chars']);
5372            return false;
5373        }
5374        if(category_name.length<1) {
5375        	show_error_fc_save($.lang[LANG]['board.enter-group-name']);
5376            return false;
5377        }
5378        if(category_name.length>30) {
5379        	show_error_fc_save($.lang[LANG]['board.enter-max-chars.30']);
5380            return false;
5381        }
5382        var list =  position.find('.forum-category-item .forum-category-name').map(function() { return $(this).text().trim(); }).get();
5383        if($.inArray(category_name,list) > -1 ) {
5384        	show_error_fc_save($.lang[LANG]["editor.gallery.category.inuse-name"]);
5385        	return false;
5386        }
5387
5388
5389		$.post('/fm/category/update', {  sid : F_SID, pid : pid, cate: cate_seq, name : encodeURIComponent(category_name) }, function(data) {
5390			if(typeof data.error != 'undefined' && data.error) {
5391				show_error_fc_save(data.error);
5392				return false;
5393			}
5394
5395			if($('#forumCateSort'+idx).hasClass('additem')) $('#forumCateSort'+idx).removeClass('additem');
5396			$('#forumCateSort'+idx).attr('data-cate',data.seq);
5397			$('#forumCateSort'+idx).find('.forum-category-name').text(category_name);
5398
5399			position.find('.forum-category-item').removeAttr('style');
5400			position.find('.forum-category-update').remove();
5401
5402			if($('.'+selectEL).find('#scate option[value="' + data.seq + '"]').length > 0 ) $('.'+selectEL).find('#scate option[value="' + data.seq + '"]').text(category_name);
5403			else $('.'+selectEL).find('#scate').append('<option value="'+data.seq+'">'+category_name+'</option>');
5404
5405			$('.'+selectEL).find('.tpl-forum-list-category[data-cate='+data.seq+']').text(category_name);
5406			
5407			$('.forum-category-update-save').removeClass('clicked');
5408		},'json');
5409	});
5410
5411	var displayCategoryHtml = function(id,list_data,sel_replace,block_lang) {
5412		var str = `
5413				<select id="scate" class="form-control" name="scate" placeholder="${$.lang[block_lang]['board.scate']}">
5414					<option value="">${$.lang[block_lang]['board.scate']}</option>
5415		`;
5416
5417		var scate = '';
5418		if(typeof $.cookie('forum_'+id+'_scate') != 'undefined' && $.cookie('forum_'+id+'_scate')) scate = $.cookie('forum_'+id+'_scate');
5419
5420		$.each(list_data, function(i,v) {
5421			str += `<option value="${v['seq']}" ${(scate == v['seq']) ? 'selected' : ''}>${v['fca_name']}</option>`;
5422			if(list_data.length == (i+1)) {
5423				str += '</select>';
5424				$(sel_replace).find('#scate').replaceWith(str);
5425				$(sel_replace).find('#scate').parent().removeClass('hidden');
5426			}
5427		});
5428
5429		if(list_data.length == 0) {
5430			str += '</select>';
5431			$(sel_replace).find('#scate').replaceWith(str);
5432			$(sel_replace).find('#scate').parent().removeClass('hidden');
5433		}
5434	}
5435
5436	var displayTypeForum = function(data,$el,typeCheck,view,page_num,id) {
5437		var isMasonry = (typeCheck == 'card') ? true : false,
5438			forum_item = '';
5439
5440		$el.attr('data-list-type',typeCheck);
5441		if(isMasonry) $el.attr('data-msny', true);
5442		else $el.attr('data-msny', false);
5443
5444		$el.find('.table-container').empty();
5445		if(typeCheck == 'card') {
5446			$el.find('.table-container').append('<div class="table" data-loop="true"></div>');
5447		} else {
5448			$el.find('.table-container').append($(data.source).find('table'));
5449			$el.find('.table [data-loop="true"]').empty();
5450		}
5451
5452		var $row = $el.find('[data-loop="true"]'),
5453			loop = $(data.source).find('[data-loop="true"]').children().eq(0).clone();
5454
5455		$.each(data.list, function(i,v) {
5456			var num = data.total - (view * (page_num-1)) - i;
5457			if(isMasonry) {
5458				forum_item = forum_item + forumRow(v, num, page_num, id, $.forum.modoo_card, data.config, 'thumb', $(data.source));
5459			} else {
5460				$row.append(forumRow(v, num, page_num, id, loop, data.config, '', $(data.source)));
5461			}
5462		});
5463
5464		if(isMasonry) {
5465			$el.find('.table').attr('data-view',view);
5466
5467			var $forum_items = ($(forum_item).find('.item').length) ? $(forum_item) : $('<div>'+forum_item+'</div>');
5468			$forum_items.hide();
5469
5470			$row.before("<div class='forum-loading-status'><div class='loading-dots'></div></div>");
5471			var f_items = data.list.length;
5472			var f_process_index = 0;
5473
5474			$forum_items.children().imagesLoaded().progress(function(imgload, image) {
5475				f_process_index++;
5476				var $item = $(image.img).parents('.item');
5477				$item.show();
5478
5479				if(f_items == f_process_index) {
5480					var reload_forum_items = $forum_items.html();
5481					forumReloadMasonry($row,$(reload_forum_items));
5482				}
5483			});
5484		}
5485	}
5486
5487
5488	
5489	$doc.on('click', `
5490			[data-ver="1"][data-type="forum"][data-type2="faq"] tr .tpl-forum-list-title
5491		`, function(e) {
5492
5493		var isElview = ($('.elviewcss').length > 0) ? true : false;
5494		if(!isElview) {
5495			$(this).closest('tr').addClass('this');
5496			$(this).closest('[data-loop="true"]').find('tr').each(function() {
5497				var checkClick = $(this).hasClass('this'),
5498					checkClose = (!checkClick && $(this).find('.toggle').hasClass('open')) ? true : false;
5499
5500				if(checkClick || checkClose) {
5501					$(this).find('.toggle').toggleClass('open');
5502					$(this).toggleClass('open');
5503					$(this).next().toggle();
5504				}
5505			});
5506
5507			$(this).closest('[data-loop="true"]').find('tr.this').removeClass('this');
5508		}
5509	});
5510
5511	$doc.on('click', `
5512			[data-type="forum"][data-type2="faq"] .item .question .tpl-forum-list-title,
5513			[data-type="forum"][data-type2="faq"] .item .question .tpl-forum-list-faq-toggle
5514		`, function(e) {
5515
5516		var isElview = ($('.elviewcss').length > 0) ? true : false;
5517		if(!isElview) $(this).closest('.item').toggleClass('open').siblings().removeClass('open');
5518	});
5519
5520	$doc.on('click', `
5521			[data-type="forum"][data-type2="faq"] .tpl-forum-faq-edit,
5522			[data-type="forum"][data-type2="faq"] .tpl-forum-faq-del
5523		`, function(e) {
5524		var ctrlBtn = $(this),
5525			ctrlUL = ctrlBtn.closest('ul[data-id]');
5526
5527		if(ctrlBtn.hasClass('clicked')) return;
5528		ctrlBtn.addClass('clicked');
5529
5530		var pid = ctrlUL.attr('data-pid'),
5531			id = ctrlUL.attr('data-id'),
5532			mode = (ctrlBtn.is('.tpl-forum-faq-del')) ? 'del' : 'edit';
5533
5534		switch(mode) {
5535			case 'edit':
5536				ctrlBtn.removeClass('clicked');
5537				updateForumPost(id,pid);
5538				break;
5539
5540			case 'del':
5541				var faqdelModal = $(this).showModalFlat($.lang[LANG]['board.ask-permanent-delete.title'], $.lang[LANG]['board.ask-permanent-delete'], true, true, function() {
5542					faqdelModal.modal('hide');
5543					$.forum.delete(id);
5544				}, 'cancel', $.lang[LANG]['config.delete'],'cl-cmmodal cl-s-btn w560 cl-p130 cl-p0 cl-t80 cl-modal cl-none-title cl-close-btn', true, '', '', function() {
5545					ctrlBtn.removeClass('clicked');
5546				});
5547				break;
5548
5549			default:
5550				ctrlBtn.removeClass('clicked');
5551				break;
5552		}
5553
5554	// 	var view = $(this).parent('ul[data-id]').attr('data-id');
5555	// 	location.replace(forumUrl() + '/forum/view/' + view);
5556	});
5557
5558
5559}(jQuery));
5560
5561
5562var forumRow = function(row,num,page_num,pid,loop_item,config,type,$source) {
5563	var forum_row = document.createElement('div');
5564	$(forum_row).html(loop_item);
5565	$(forum_row).children().removeClass('active');
5566
5567	var checkNotice	= (row.option == 'N') ? true : false,
5568		checkSecret	= (row.option == 'S') ? true : false,
5569		checkNew	= (row.new) ? true : false,
5570		checkEmpty	= (row.title == '' && row.content == '') ? true : false,
5571		checkNamemask = (row.namemask) ? true : false;
5572
5573	var row_settings = getOrDefault(row,'settings',{})
5574		field_lang	= getOrDefault(config,'field_lang','EN'),
5575		max_title	= getOrDefault(config,'max_title',150),
5576		max_cont	= getOrDefault(config,'max_cont',300);
5577
5578	var url	= forumUrl(),
5579		href = $.inArray(type, ['faq','qna','guestbook']) > -1 ? 'javascript:void(0);' : url + '/forum/view/' + row.id,
5580		icon_notice	= (checkNotice) ? '<i class="tpl-forum-list-notice-icon cl-icon notice01" aria-hidden="true"></i>' : '',
5581		icon_secret	= (checkSecret) ? '<i class="tpl-forum-list-secret-icon cl-icon lock02" aria-hidden="true"></i>&nbsp;' : '',
5582		icon_new	= (checkNew) ? '<img src="//storage.googleapis.com/i.addblock.net/icon/icon_new_forum.png" title="new" alt="new">' : '';
5583
5584	var title_str	= (row.title) ? ((type == 'faq') ? row.title : htmlEntities(cutStrInBytes(htmlspecialchars_decode(row.title),max_title))) : '',
5585		title_href	= (title_str == '') ? '<a href="javascript:void(0);" class="deleted">' + $.lang[LANG]['board.post.deleted'] + '</a>' : '<a href="' + href + '">' + title_str + '</a> ' + icon_new,
5586		is_Masonry = ($('.element[data-id="' + pid + '"]').attr('data-msny') == 'true') ? true : false,
5587		block_lang = ($('.element[data-id="' + pid + '"]').attr('data-blocklang')) ? $('.element[data-id="' + pid + '"]').attr('data-blocklang') : LANG;
5588
5589	if($.cookie('forum_'+pid+'_type') == 'card' ||
5590		typeof $.cookie('forum_'+pid+'_type') == 'undefined' && $source.attr('data-list-type') == 'card') is_Masonry = true;
5591
5592	var icon_span_class = (typeof $source.find('.tpl-forum-list-num span').attr('class') != 'undefined') ? $(forum_row).find('.tpl-forum-list-num span').attr('class') : '';
5593	
5594	$(forum_row).find('.tpl-forum-list-num').text(num).attr('data-fm-num', num);
5595	if($(forum_row).find('.tpl-forum-list-num.two-digit-number').length){
5596		if($(forum_row).find('.tpl-forum-list-num').text() <= 9) {
5597			var two_count = $(forum_row).find('.tpl-forum-list-num').text()
5598			$(forum_row).find('.tpl-forum-list-num').text('0'+two_count)
5599		}
5600	}
5601	$(forum_row).find('.tpl-forum-list-hit').text(row.hit);
5602	$(forum_row).find('.tpl-forum-list-date').text(row.datetime);
5603	$(forum_row).find('.tpl-forum-list-name').attr('data-userid', row.fm_mb_id
5603).text(row.name);
5604	$(forum_row).find('.tpl-forum-list-title').html(icon_secret + title_href).attr('data-option',row.option).attr('data-id',row.id);
5605	if($(forum_row).find('.tpl-forum-list-title').hasClass('tpl-forum-list-notice')) $(forum_row).find('.tpl-forum-list-title').attr('class','').addClass('tpl-forum-list-title');
5606	$(forum_row).find('.sample-notice').remove();
5607
5608	if(row.fm_mb_id) $(forum_row).find('.tpl-forum-list-name').addClass('is-user');
5609	
5610	if(row.depth > 0 && !checkNotice) {
5611		if($(forum_row).find('.tpl-forum-list-name').hasClass('tpl-sync-reply')) $(forum_row).find('.tpl-forum-list-name').addClass('reply');
5612
5613		$(forum_row).find('.tpl-forum-list-title').addClass('reply');
5614		$(forum_row).find('.tpl-forum-list-title').prepend('<span class="tpl-forum-list-reply-name">' + row.reply_name + '</span>');
5615	}
5616	
5617	if(checkNamemask) {
5618		$(forum_row).find('.tpl-forum-list-name').addClass('namemask');
5619	}
5620
5621	if($(forum_row).find('.tpl-forum-list-cont').length > 0) {
5622		var row_content = row.content.replace(/<span class=\"fr-file\"[^>]*>((\n|\r|.)*?)<\/span>/gim,' ');
5623
5624		var cont_txt = (row.content.length > 0) ? row_content.replace(/(<([^>]+)>)/ig,' ') : '',
5625			cont_str = (cont_txt.length > 0) ? cutStrInBytes(cont_txt,max_cont) : '',
5626			cont_str = (type == 'guestbook' ? cont_txt : cont_str),
5627			cont_href = (title_str == '') ? '<a href="javascript:;" class="deleted"></a>' : '<a href="' + href + '">' + cont_str + '</a>';
5628		
5629		if(type == 'guestbook') {
5630			if($('.element[data-id="' + pid + '"]').find('.fr34-input-height').length) cont_str = '\"' + cont_str + '\"';
5631			cont_href = icon_secret + nl2br(cont_str);
5632		}
5633
5634		if($(forum_row).find('.tpl-forum-list-cont').find('.tpl-forum-list-more').length > 0) {
5635			var contmore_str = $(forum_row).find('.tpl-forum-list-cont').find('.tpl-forum-list-more').html();
5636			cont_href += '<div class="tpl-forum-list-more forum-contmore"><a href="' + href + '">' + contmore_str + '</a></div>';
5637			$(forum_row).find('.tpl-forum-list-cont').find('.tpl-forum-list-more').html('<a href="' + href + '">' + more_str + '</a>' ).attr('data-option',row.option).attr('data-id',row.id);
5638		} 
5639		
5640		$(forum_row).find('.tpl-forum-list-cont').html(cont_href).attr('data-option',row.option).attr('data-id',row.id);
5641	}
5642	if($(forum_row).find('.tpl-forum-list-myimg').length > 0) {
5643		if($(forum_row).find('.tpl-forum-list-myimg').hasClass('hexagon')) {
5644			var hexagon = '<svg viewbox="0 0 40 40"><pattern id="forum-list-image-' + row.id + '" patternUnits="userSpaceOnUse" width="40" height="40"><image xlink:href="' + row.myimg + '?_' + new Date().getTime() + '" x="-10" width="60" height="40" /></pattern><polygon points="20 0 37 10 37 30 20 40 3 30 3 10" fill="url(#forum-list-image-' + row.id + ')"/></svg>';
5645			$(forum_row).find('.tpl-forum-list-myimg').html(hexagon);
5646		} else {
5647			$(forum_row).find('.tpl-forum-list-myimg').html('<img src="' + row.myimg + '?_' + new Date().getTime() + '">');
5648		}
5649	}
5650
5651	if($(forum_row).find('.tpl-forum-list-category').length > 0 && $(forum_row).find('.tpl-forum-list-category').hasClass('.forum-contmore')==false) {
5652		var cate_name	= (row.category_name) ? row.category_name : '';
5653		$(forum_row).find('.tpl-forum-list-category').removeAttr('data-cate').empty();
5654		if(row.category_seq) $(forum_row).find('.tpl-forum-list-category').text(cate_name).attr('data-cate',row.category_seq);
5655	}
5656
5657	if($(forum_row).find('.tpl-forum-list-more').length > 0) {
5658		var more_str = $(forum_row).find('.tpl-forum-list-more').html();
5659		$(forum_row).find('.tpl-forum-list-more').html('<a href="' + href + '">' + more_str + '</a>' ).attr('data-option',row.option).attr('data-id',row.id);
5660	}
5661
5662	var comment_str = (row.comment > 0) ? row.comment : '';
5663	$(forum_row).find('.tpl-forum-list-comment').html(comment_str);
5664	if(!comment_str) {
5665		 $(forum_row).find('.tpl-forum-list-comment-icon').remove();
5666		 $(forum_row).find('.tpl-forum-list-comment').addClass('empty');
5667	} else {
5668		if($(forum_row).find('.tpl-forum-list-comment').length < 1) {
5669			var comment_icon = $source.find('.tpl-forum-list-comment-icon').clone();
5670			$(forum_row).find('.tpl-forum-list-comment').prev(comment_icon);
5671		}
5672		$(forum_row).find('.tpl-forum-list-comment').removeClass('empty');
5673	}
5674
5675	if(checkNotice) {
5676		var isMobileWidth = (isMobile() || (PAGE_MODE == 'r' && window.innerWidth <= 767))? true : false;
5677
5678		$(forum_row).find('.tpl-forum-list-num').addClass('n');
5679		if($(forum_row).find('[data-notice-type="text"]').length > 0) {
5680			icon_notice = '<span class="tpl-forum-list-notice">'+$.lang[block_lang]['forum.forum.notice.text']+'</span>';
5681			$(forum_row).find('.tpl-forum-list-title').addClass('tpl-forum-list-notice');
5682		}
5683		if($(forum_row).find('.tpl-forum-list-num').hasClass('notice-svg')) { //notice icon svg
5684			icon_notice = $source.find('.tpl-forum-list-num').find('.tpl-forum-list-notice-icon').outerHTML();
5685		}
5686
5687		$(forum_row).find('.tpl-forum-list-num').html(icon_notice);
5688		$(forum_row).find('.tpl-forum-list-title .tpl-forum-list-notice-icon, .tpl-forum-list-title .tpl-forum-list-notice').remove();
5689		$(forum_row).find('.tpl-forum-list-title').prepend(icon_notice);
5690	}
5691
5692	if($(forum_row).find('.tpl-forum-list-like').length > 0) {
5693
5694		var like_cnt = (row.like !== undefined && row.like.cnt !== undefined)? row.like.cnt : 0;
5695		$(forum_row).find('.tpl-forum-list-like').attr('data-id', row.id);
5696		if($(forum_row).find('.tpl-forum-list-like').is('td') && $(forum_row).find('.tpl-forum-list-like .forum-like-cnt').length == 0) {
5697			$(forum_row).find('.tpl-forum-list-like').text(like_cnt);
5698		} else {
5699			$(forum_row).find('.tpl-forum-list-like .forum-like-cnt').text(like_cnt);
5700		}
5701
5702		if(row.like !== undefined  && row.like.cnt !== undefined && row.like.own) $(forum_row).find('.tpl-forum-list-like').addClass('active');
5703		else $(forum_row).find('.tpl-forum-list-like').removeClass('active');
5704	}
5705
5706	switch(type) {
5707		case 'thumb':
5708			if($(forum_row).find('.tpl-forum-list-thumb').length > 0) {
5709				var f_color = ($('.element[data-id="' + pid + '"]').attr('data-fcolor')) ? $('.element[data-id="' + pid + '"]').attr('data-fcolor') : '#000000',
5710					ffolder = $('.element[data-id="' + pid + '"]').attr('data-width'),
5711					thumb_empty = (row.thumb == '' || row.title == '') ? true : false,
5712					content_noimage_img = (thumb_empty && row.content_noimage_img) ? setResizeImageFolder(ffolder,row.content_noimage_img) : row.content_noimage_img,
5713					thumb_src = (thumb_empty) ? ((row.content_noimage_img) ? content_noimage_img : '//storage.googleapis.com/i.addblock.net/icon/noimage_' + ffolder +'.png?' + new Date().getTime()) : row.thumb.replace('\/60\/','\/' + ffolder + '\/'),
5714					thumb_href = (title_str == '') ? '<a href="javascript:;" class="deleted"></a>' : '<a href="' + href + '"></a>';
5715
5716				$(forum_row).find('.tpl-forum-list-thumb img').attr('src',thumb_src).wrap(thumb_href).attr('alt',row.title.replace(/\s/g,'-'));
5717
5718				if(thumb_empty) {
5719					if(!is_Masonry && !row.content_noimage_img) {
5720						var text = '<p class="noimage_text">no image</p>';
5721						$(forum_row).find('.tpl-forum-list-thumb').append(text);
5722						$(forum_row).find('.tpl-forum-list-thumb').css('background-color',Coloris.getChangeColorVal(f_color,'a',0.1));
5723						$(forum_row).find('.noimage_text').css('color',Coloris.getChangeColorVal(f_color,'a',0.15));
5724					}	
5725
5726					$(forum_row).find('.tpl-forum-list-thumb,.tpl-forum-thumb-wrap').addClass('empty');
5727					$(forum_row).find('.tpl-forum-list-thumb').attr('data-option',row.option).attr('data-id',row.id);
5728				} else {
5729					$(forum_row).find('.noimage_text').remove();
5730					$(forum_row).find('.tpl-forum-list-thumb,.tpl-forum-thumb-wrap').removeClass('empty');
5731					$(forum_row).find('.tpl-forum-list-thumb').attr('data-option',row.option).attr('data-id',row.id);
5732				}
5733
5734				if(content_noimage_img) $(forum_row).find('.tpl-forum-list-thumb,.tpl-forum-thumb-wrap').addClass('empty_con_img');
5735				else $(forum_row).find('.tpl-forum-list-thumb,.tpl-forum-thumb-wrap').removeClass('empty_con_img');
5736
5737				//$(forum_row).find('.tpl-forum-list-thumb.empty.empty_con_img img').css('display','block');
5738				if(is_Masonry && $(forum_row).find('.tpl-forum-list-thumb').not('.empty_con_img').hasClass('empty')) $(forum_row).find('.item-inner').addClass('msny_10');
5739			}
5740			break;
5741
5742		case 'faq': 
5743			var colspan = $(forum_row).find('th').length,
5744				settings = (typeof row.settings == 'undefined') ? {} : row.settings,
5745				wrap = (typeof settings.wrap != 'undefined') ? 'w' + settings.wrap : '',
5746				align = (typeof settings.align != 'undefined') ? settings.align : '',
5747				align_class = (align != '') ? 'text-'+align : '',
5748				list_no = $(forum_row).find('.tpl-forum-list-num').hasClass('fl-num'),
5749				icon_wrap = $(forum_row).find('.tpl-forum-list-num').data('icon-wrap'),
5750				unit_icon = $(forum_row).find('.tpl-forum-list-etc').data('uniticon') ? clSVG($(forum_row).find('.tpl-forum-list-etc').data('uniticon'),16,16) : '',
5751				unit = ($(forum_row).find('.tpl-forum-list-num').hasClass('unit-empty')) ? { 'question':unit_icon, 'answer':'' } : { 'question':'Q', 'answer':'A' };
5752
5753			colspan = colspan + $(forum_row).find('td').length;
5754
5755			var answer_len = $source.find('.answer').length,
5756				an_class = (typeof $source.find('.answer').attr('class') != 'undefined') ? $source.find('.answer').attr('class') : '',
5757				an_th_class = 'tpl-forum-list-num tpl-forum-list-etc';
5758
5759			var $answer = $('<tr class="'+an_class+'">');
5760			if(answer_len > 0) {
5761				var an_html = $source.find('.answer:eq(0)').outerHTML();
5762				var $an_html2 = $(htmlspecialchars_decode(an_html));
5763				an_th_class = (typeof $an_html2.find('th').attr('class') != 'undefined') ? $an_html2.find('th').attr('class') : '';
5764				$an_html2.empty();
5765				$answer = $an_html2.attr('style','');
5766			}
5767
5768			var answerClass = ($source) ? (($source.find('.tpl-forum-list-cont').length > 0) ? $source.find('.tpl-forum-list-cont').attr('class').replace(/fsize\d+/gi,'') : '') : '',
5769				toggleOpenContent = ($source.find('.answer').length>0) ? '' : 'toggleOpenContent',
5770				answer_col = $source.find('.tpl-forum-list-cont').data('answer-col'),
5771				answer_colspan = (answer_col) ? colspan : colspan-1;
5772
5773			$answer.append('<th scope="row" class="'+an_th_class+'">' + unit['answer'] + '</th>');
5774			$answer.append('<td class="'+answerClass+' '+toggleOpenContent+'" colspan="' + answer_
5774colspan + '">' + ((typeof config.faq_view_msg != 'undefined' && config.faq_view_msg) ? config.faq_view_msg : row.content) + '</td>');
5775			$answer.hide();
5776
5777			if(checkNotice) {
5778				$answer.find('.tpl-forum-list-num').text('');
5779				$(forum_row).find('.question').addClass('notice');
5780			} else {
5781				var f_num = $(forum_row).find('.tpl-forum-list-num').data('fm-num');
5782				$(forum_row).find('.tpl-forum-list-num').removeClass('n').html(unit['question']);
5783				if(list_no) $(forum_row).find('.tpl-forum-list-num').append(f_num);
5784			}
5785
5786			if(icon_wrap) {
5787				$(forum_row).find('.tpl-forum-list-num').wrapInner('<span class="'+icon_span_class+'"></span>');
5788				$answer.find('.tpl-forum-list-num').wrapInner('<span class="'+icon_span_class+'"></span>');
5789			}
5790
5791			if(row_settings.fonts) {
5792				if(row_settings.fonts.color) $(forum_row).find('.tpl-forum-list-cont').css('color', row_settings.fonts.color);
5793				if(row_settings.fonts.fontFamily) $(forum_row).find('.tpl-forum-list-cont').css('font-family', row_settings.fonts.fontFamily);
5794				if(row_settings.fonts.fontSize) $(forum_row).find('.tpl-forum-list-cont').css('font-size', row_settings.fonts.fontSize);
5795			}
5796
5797			$answer.find('.tpl-forum-faq-ctrl').remove();
5798			if(row.check_ctrl) {
5799				$answer.find('.tpl-forum-list-cont').append(`
5800					<div class="tpl-forum-faq-ctrl auto">
5801						<ul data-pid="${pid}" data-id="${row.id}">
5802							<li class="tpl-forum-faq-edit">${$.lang[block_lang]['board.button.modify']}</li>
5803							<li class="tpl-forum-faq-del">${$.lang[block_lang]['board.button.delete']}</li>
5804						</ul>
5805					</div>
5806				`);
5807			}
5808			break;
5809
5810		case 'qna':
5811			$(forum_row).find('.tpl-forum-list-state').text('');
5812			if((row.reply_name == null || !row.reply_name) && $(forum_row).find('.tpl-forum-list-num.n').length == 0) {
5813				if($('.element[data-id="' + pid + '"]').hasClass('newqna')) {
5814					var state_false_fsize = ($source.find('.tpl-forum-list-state span').attr('class')) ? $source.find('.tpl-forum-list-state span').attr('class') : '',
5815						state_true_fsize = ($source.find('.tpl-forum-list-state.true span').attr('class')) ? $source.find('.tpl-forum-list-state.true span').attr('class') : '',
5816						state_fsize = (row.replied == true) ? state_true_fsize : state_false_fsize;
5817
5818					$(forum_row).find('.tpl-forum-list-state').append('<span></span>');
5819
5820					if(row.replied == true) $(forum_row).find('.tpl-forum-list-state').addClass('true').attr('data-state',true).find('span').text($.lang[block_lang]['forum.qna.state.replied']).addClass(state_fsize);
5821					else $(forum_row).find('.tpl-forum-list-state').removeAttr('data-state').find('span').text($.lang[block_lang]['forum.qna.state.waiting']).addClass(state_fsize);
5822				} else {
5823					if(row.replied == true) $(forum_row).find('.tpl-forum-list-state').attr('data-state',true).text($.lang[block_lang]['forum.qna.state.replied']);
5824					else $(forum_row).find('.tpl-forum-list-state').removeAttr('data-state').text($.lang[block_lang]['forum.qna.state.waiting']);
5825				}
5826			}
5827			
5828			$(forum_row).find('.qna-details *[class*=tpl-forum-list-]').not('.tpl-forum-list-content, .tpl-forum-list-like').html('');
5829			$(forum_row).find('.qna-details *[class*=tpl-qna-answer-]').html('');
5830			
5831			var replyBtn = '<button type="button" class="btn btn-default btn-round btn-modal btn-list tpl-forum-write" data-pid="'+pid+'" data-reply="'+row.id+'">답글</button>';
5832			var forum_img = $(forum_row).find('.qna-details img');
5833			forum_img.each(function(idx, v){
5834				var src = $(v).attr('src');
5835				$(v).wrap('<a href="'+src+'" target="_blank"></a>')
5836			});
5837
5838			
5839			if(row_settings.fonts) {
5840				if(row_settings.fonts.color) $(forum_row).find('.tpl-qna-question-content').css('color', row_settings.fonts.color);
5841				if(row_settings.fonts.fontFamily) $(forum_row).find('.tpl-qna-question-content').css('font-family', row_settings.fonts.fontFamily);
5842				if(row_settings.fonts.fontSize) $(forum_row).find('.tpl-qna-question-content').css('font-size', row_settings.fonts.fontSize);
5843			}
5844
5845			$(forum_row).find('.qna-details').hide();
5846			break;
5847		case 'guestbook':
5848			// 관리자
5849			if(PAGE_MODE == 'c' || (PAGE_MODE != 'c' && row.fm_mb_id == (RENDER.b.UMEMBER.id_type == 'creatorlink' ? '' : RENDER.b.UMEMBER.id)) || RENDER.b.UMEMBER.check_adm == true || RENDER.b.UMEMBER.check_uadm == true) {
5850				if((PAGE_MODE != 'c' && (row.fm_mb_id != (RENDER.b.UMEMBER.check_adm != true && RENDER.b.UMEMBER.check_uadm != true && RENDER.b.UMEMBER.id_type == 'creatorlink' ? '' : RENDER.b.UMEMBER.id))
5851					) || (PAGE_MODE == 'c' && row.id_type != 'A')) {
5852					$(forum_row).find('[data-oper="U"]').hide();
5853					$(forum_row).find('[data-oper="U"]').next().hide();
5854				}
5855			} else {
5856				$(forum_row).find('.tpl-guestbook-more-menu').addClass('hide');
5857				//guest book2 fm29 렌더에서 기능 동작 x
5858				$(forum_row).find('.tpl-guestbook-more-menu-area-el2').addClass('hide');
5859			}
5860			if(row.fm_mb_id == '' && row.option == 'S' && PAGE_MODE != 'c' && RENDER.b.UMEMBER.id == '') {
5861				$(forum_row).find('.list-item').addClass('blind');
5862				$(forum_row).find('.tpl-guestbook-more-menu').addClass('hide');
5863				//guest book2 fm29 렌더에서 기능 동작 x
5864				$(forum_row).find('.tpl-guestbook-more-menu-area-el2').addClass('hide');
5865			}
5866			$(forum_row).find('.tpl-forum-list-cont').attr('data-fm_mb_id', row.fm_mb_id
5866);
5867			break;
5868		default: //normal
5869			break;
5870	}
5871
5872	var forum_row_html = $(forum_row).html();
5873	$(forum_row).remove();
5874
5875	return (type == 'faq') ? forum_row_html + $answer.outerHTML() : forum_row_html;
5876}
5877
5878var forumUrl = function() {
5879	if(PAGE_MODE != 'c') {
5880		var url = (PAGE_MODE=='s') ? '' : '/render';
5881	} else {
5882		var url = '/'+CONFIG_URL+'config/page';
5883	}
5884	return url;		
5885}
5886
5887// NEW
5888var getForumListItem = function(num,data,_fu) {
5889	// console.log('getForumListItem','num',num,`data`,data,`_fu`,_fu);
5890
5891	var fields = {
5892		normal: ['title','num','category','name','date','hit','comment','like','myimg'],
5893		thumb: ['title','cont','thumb','num','category','name','date','hit','comment','like'],
5894		faq: ['title','cont','faq-icon','faq-toggle'],
5895		qna: ['title','num','category','name','date','state','cont'],
5896		guestbook: ['cont','name','date'],
5897	};
5898	fields.all = [...new Set([...fields.normal, ...fields.thumb, ...fields.qna, ...fields.faq, ...fields.guestbook])];
5899
5900	var item = {
5901		pid: _fu.pid,
5902		id: data.id,
5903		link: {
5904			active: (data.title == '') ? false : true,
5905			val: ($.inArray(_fu.eltype2, ['faq','qna','guestbook']) > -1) ? 'javascript:void(0);' : `${forumUrl()}/forum/view/${data.id}`,
5906			cls: ``,
5907			attr: {},
5908		},
5909		new: data.new ? true : false,
5910		option: {
5911			val: data.option,
5912			notice: data.option == 'N' ? true : false,
5913			secret: data.option == 'S' ? true : false,
5914		},
5915		reply: {
5916			active: data.depth > 0 && data.option != 'N' ? true : false,
5917			name: data.reply_name || '',
5918		},
5919
5920		selector: '.item',
5921
5922		// field
5923		title: {
5924			val: data.title || '',
5925			max: _fu.elsettings.max_title || 150,
5926		},
5927		cont: {
5928			val: (_fu.eltype2 == 'faq' && _fu.config.faq_view_msg) ? _fu.config.faq_view_msg : data.content,
5929			more: _fu.sampleEL.find('.tpl-forum-list-cont .forum-cont-more').length  > 0 ? _fu.sampleEL.find('.tpl-forum-list-cont .forum-cont-more').eq(0).prop('outerHTML') : '',
5930			max: _fu.elsettings.max_cont || 300,
5931		},
5932		thumb: {
5933			val: data.thumb || '',
5934			ffolder: _fu.blockEL.attr('data-width'),
5935			alt: data.title.replace(/\s/g,'-'),
5936			noimg: setResizeImageFolder(_fu.blockEL.attr('data-width'),data.content_noimage_img) || `//storage.googleapis.com/i.addblock.net/icon/noimage_${_fu.blockEL.attr('data-width')}.png?${new Date().getTime()}`,
5937		},
5938		num: {
5939			val: num,
5940			isThumb: _fu.sampleEL.find('.tpl-forum-list-thumb .tpl-forum-list-num').length > 0 ? true : false,
5941		},
5942		cateogry: {
5943			seq: data.category_seq, 
5944			name: data.category_name
5945		},
5946		name: {
5947			val: data.name || '',
5948			mask: (_fu.elsettings.namemask_display == 'ON') ? true : false,
5949		},
5950		date: data.datetime,
5951		hit: data.hit,
5952		comment: {
5953			val: Number(data.comment) || 0,
5954		},
5955		like: {
5956			val: Number(data.like.cnt) || 0,
5957			active: data.like.own || false,
5958		},
5959		myimg: {
5960			val: data.myimg,
5961		},
5962		state: data.replied || false,
5963	};
5964	// console.log('data',data,'item',item);
5965
5966	var icon = {
5967		new: `<img src="//storage.googleapis.com/i.addblock.net/icon/icon_new_forum.png" title="new" alt="new">`,
5968		notice: `<i class="tpl-forum-list-notice-icon cl-icon notice01" aria-hidden="true"></i>`,
5969		secret: `<i class="tpl-forum-list-secret-icon cl-icon lock02" aria-hidden="true"></i>&nbsp;`,
5970	};
5971
5972	var tag = _fu.sampleEL.find(item.selector).eq(0).clone();
5973	tag.removeClass('active n s w');
5974	if(item.option.notice) tag.addClass('n');
5975	if(item.option.secret) tag.addClass('s');
5976	// w - qna block (state waiting)
5977
5978	$.each(fields.all, function(i,field_k) {
5979		var field_selector = `.tpl-forum-list-${field_k}`,
5980			unused = ($.inArray(field_k, fields[_fu.eltype2]) > -1) ? false : true,
5981			htmlField = '';
5982
5983		if(unused) {
5984			tag.find(field_selector).remove();
5985			return true;
5986		}
5987
5988		switch(field_k) {
5989			// .tpl-forum-list-title
5990			case 'title': 
5991				item.title.txt = item.title.val;
5992				if(item.title.txt) {
5993					if(_fu.eltype2 != 'faq') item.title.txt = htmlEntities(cutStrInBytes(htmlspecialchars_decode(item.title.txt), item.title.max));
5994					htmlField = `<a>${item.title.txt}</a> ${item.new ? icon.new : ''}`;
5995				} else {
5996					htmlField = `<a>${$.lang[LANG]['board.post.deleted']}</a>`;
5997				}
5998				if(item.option.secret) htmlField = `${icon.secret} ${htmlField}
5998`;
5999				var titleField = tag.find(field_selector);
6000				titleField.removeClass('reply').html(htmlField);
6001				if($.inArray(_fu.eltype2, ['normal','thumb']) > -1 && item.reply.active) {
6002					titleField.addClass('reply').prepend(`<span class="tpl-forum-list-reply-name">${item.reply.name}</span>`);
6003				}
6004				break;
6005
6006			// .tpl-forum-list-cont
6007			case 'cont':
6008				if(item.cont.val) {
6009					if(_fu.eltype2 == 'qna' && item.option.secret) {
6010						htmlField = `${icon.secret} ${$.lang[LANG]['forum.qna.content.secret']}`;
6011					} else {
6012						if($.inArray(_fu.eltype2, ['faq','guestbook']) > -1) {
6013							item.cont.txt = item.cont.val.replace(/<span class=\"fr-file\"[^>]*>((\n|\r|.)*?)<\/span>/gim,' ');
6014						} else {
6015							// item.cont.txt = item.cont.val.replace(/<span class=\"fr-file\"[^>]*>((\n|\r|.)*?)<\/span>/gim,' ');
6016							// item.cont.txt = item.cont.txt.replace(/(<([^>]+)>)/ig,' ');
6017							// item.cont.txt = cutStrInBytes(item.cont.txt,item.cont.max);
6018							
6019							// 다른 폰트 적용 시 공백 생기는 문제로 인해 아래 코드로 교체
6020							item.cont.txt = item.cont.val.replace(/<span class=\"fr-file\"[^>]*>((\n|\r|.)*?)<\/span>/gim, ' ');
6021							item.cont.txt = item.cont.txt.replace(/<[^>]+>/g, '');
6022							item.cont.txt = cutStrInBytes(item.cont.txt, item.cont.max);							
6023						}
6024						if(item.cont.more) {
6025							htmlField = `
6026								<div class="forum-cont-val"><a>${item.cont.txt}</a></div>
6027								${$(item.cont.more).find('a').length == 0 ? $(item.cont.more).wrapInner('<a></a>').prop('outerHTML') : item.cont.more}
6028							`;
6029						} else {
6030							htmlField = item.cont.txt;
6031						}
6032					}
6033				}
6034				tag.find(field_selector).html(htmlField);
6035
6036				if($.inArray(_fu.eltype2, ['faq','qna']) > -1) {
6037					var tmp_style = data.settings.fonts || { fontFamily: 'Noto Sans KR', fontSize: '13px', fontWeight: '300', color: '#000000'};
6038					tag.find(field_selector).css({
6039						'font-family': tmp_style.fontFamily,
6040						'font-size': tmp_style.fontSize,
6041						'font-weight': tmp_style.fontWeight,
6042						'color': tmp_style.color,
6043					});
6044				}
6045
6046				if(_fu.eltype2 == 'faq') {
6047					if(data.check_ctrl) {
6048						var faqCtrlAuto = (tag.find('.answer .tpl-forum-faq-ctrl').length > 0) ? false : true;
6049						if(faqCtrlAuto) {
6050							tag.find('.answer').append(`
6051								<div class="tpl-forum-faq-ctrl auto">
6052									<ul data-pid="" data-id="">
6053										<li class="tpl-forum-faq-edit"></li>
6054										<li class="tpl-forum-faq-del"></li>
6055									</ul>
6056								</div>
6057							`);
6058						}
6059
6060						tag.find('.answer .tpl-forum-faq-ctrl [data-id]').attr('data-id',item.id);
6061						tag.find('.answer .tpl-forum-faq-ctrl [data-pid]').attr('data-pid',item.pid);
6062						tag.find('.answer .tpl-forum-faq-ctrl .tpl-forum-faq-edit').html($.lang[_fu.block_lang]['board.button.modify']);
6063						tag.find('.answer .tpl-forum-faq-ctrl .tpl-forum-faq-del').html($.lang[_fu.block_lang]['board.button.delete']);
6064					} else {
6065						tag.find('.answer .tpl-forum-faq-ctrl').remove();
6066					}
6067				}
6068				break;
6069
6070			// .tpl-forum-list-thumb
6071			case 'thumb':
6072				if(item.thumb.val == '' && item.cont.val) {
6073					item.thumb.val = (item.thumb.noimg.includes('noimage')) ? '' : item.thumb.noimg;
6074				}
6075
6076				if(item.thumb.val) {
6077					item.src = item.thumb.val.replace('\/60\/','\/' + item.thumb.ffolder + '\/');
6078					tag.find(`${field_selector} img`).attr({'src':item.src, 'alt':item.thumb.alt});
6079					tag.find(field_selector).wrapInner('<a></a>');
6080				} else {
6081					tag.find(field_selector).empty();
6082				}
6083				break;
6084	
6085			// .tpl-forum-list-num
6086			case 'num': 
6087				item.num.isSingle = (tag.find('.tpl-forum-list-num').length > 1) ? false : true;
6088				if(item.option.notice) {
6089					htmlField = (tag.find('.tpl-forum-list-notice').length > 0) ? `<span class="tpl-forum-list-notice">${$.lang[_fu.block_lang]['forum.forum.notice.text']}</span>` : icon.notice;
6090				} else {
6091					var tmp_num = item.num.val,
6092						tmp_digitlen = tag.find(field_selector).attr('data-digitlen') || 1;
6093
6094					htmlField = String(tmp_num).padStart(Number(tmp_digitlen), '0');
6095				}
6096				tag.find(field_selector).html(htmlField);
6097				break;
6098			
6099			// .tpl-forum-list-faq-state
6100			case 'state':
6101				// "forum.qna.state.replied":                  "답변완료",
6102				// "forum.qna.state.waiting":                  "답변대기",
6103				var tmp_state = (item.state) ? $.lang[_fu.block_lang]['forum.qna.state.replied'] : $.lang[_fu.block_lang]['forum.qna.state.waiting'];
6104				tag.find(field_selector).html(`<span>${tmp_state}</span>`);
6105
6106				if(item.state) tag.find(field_selector).addClass('active');
6107				else tag.find(field_selector).removeClass('active');
6108				
6109				if(item.option.notice) tag.find(field_selector).empty().removeClass('active');
6110				break;
6111
6112			// .tpl-forum-list-faq-icon
6113			case 'faq-icon':
6114				if(_fu.sampleEL.find(`${field_selector}.notice`).length > 0) icon.notice = _fu.sampleEL.find(`${field_selector}.notice`).html();
6115				icon.question = (_fu.sampleEL.find(`${field_selector}.question`).length > 0) ? _fu.sampleEL.find(`${field_selector}.question`).html() : false;
6116				icon.answer = (_fu.sampleEL.find(`${field_selector}.answer`).length > 0) ? _fu.sampleEL.find(`${field_selector}.answer`).html() : false;
6117
6118				tag.find(field_selector).removeClass('notice question answer');
6119				if(item.option.notice) {
6120					tag.find(`.question ${field_selector}`).addClass('notice').html(icon.notice);
6121				} else {
6122					if(icon.question === false) {
6123						tag.find(`.question ${field_selector}`).remove();
6124					} else if(icon.question) {
6125						var tmp_q = icon.question;
6126						if(_fu.sampleEL.find(`${field_selector}.question`).is('[data-num="true"]')) tmp_q = tmp_q.replace(/\d+/gi,'') + num;
6127						tag.find(`.question ${field_selector}`).addClass('question').html(tmp_q);
6128					} else {
6129						tag.find(`.question ${field_selector}`).empty();
6130					}
6131				}
6132				
6133				if(icon.answer === false) tag.find(`.answer ${field_selector}`).remove();
6134				else if(icon.answer) tag.find(`.answer ${field_selector}`).addClass('answer').html(icon.answer);
6135				else tag.find(`.answer ${field_selector}`).empty();
6136				break;
6137
6138			// .tpl-forum-list-faq-toggle
6139			case 'faq-toggle':
6140				var tmp_faqtoggle_selector = `.item${item.option.notice ? '.n' : ''} ${field_selector}`;
6141				icon.toggle = (_fu.sampleEL.find(tmp_faqtoggle_selector).length > 0) ? _fu.sampleEL.find(tmp_faqtoggle_selector).eq(0).outerHTML() : '';
6142				if(icon.toggle && tag.find(field_selector).length == 0) {
6143					if(_fu.sampleEL.find(field_selector).eq(0).next('.tpl-forum-list-content').length > 0) tag.find(`.tpl-forum-list-content`).before(icon.toggle);
6144				}
6145				break;
6146			
6147			// .tpl-forum-list-category
6148			case 'category': 
6149				if(item.cateogry.seq) {
6150					tag.find(field_selector).text(item.cateogry.name).attr('data-cate',item.cateogry.seq);
6151				} else {
6152					tag.find(field_selector).removeAttr('data-cate').empty();
6153				}
6154				break;
6155
6156			case 'name':
6157				// tpl-forum-list-name
6158				var nameField = tag.find(field_selector);
6159				nameField.removeClass('reply').text(item.name.val);
6160				if($.inArray(_fu.eltype2, ['normal','thumb']) > -1 && item.reply.active && nameField.hasClass('tpl-sync-reply')) nameField.addClass('reply');
6161				break;
6162				
6163			case 'date':
6164				// tpl-forum-list-date
6165				tag.find(field_selector).text(item.date);
6166				break;
6167				
6168			case 'hit':
6169				// tpl-forum-list-hit
6170				if(tag.find(`${field_selector} .forum-hit-cnt`).length > 0) tag.find(`${field_selector} .forum-hit-cnt`).text(item.hit);
6171				else tag.find(field_selector).text(item.hit);
6172				break;
6173				
6174			case 'comment':
6175				// tpl-forum-list-comment
6176				if(_fu.eltype2 == 'qna') tag.find(`${field_selector}, ${field_selector}-icon`).remove();
6177				else if(item.comment.val > 0) tag.find(`${field_selector} .forum-comment-cnt`).text(item.comment.val);
6178				else tag.find(field_selector).empty();
6179
6180				break;
6181				
6182			case 'like':
6183				// tpl-forum-list-like
6184				if(tag.find(`${field_selector} .forum-like-cnt`).length > 0) tag.find(`${field_selector} .forum-like-cnt`).text(item.like.val);
6185				else tag.find(field_selector).text(item.like.val);
6186
6187				if(item.like.active) tag.find(field_selector).addClass('active');
6188				else tag.find(field_selector).removeClass('active');
6189				break;
6190				
6191			case 'myimg':
6192				// tpl-forum-list-myimg
6193				if(item.myimg.val) {
6194					item.src = item.myimg.val.replace('\/60\/','\/' + item.myimg.ffolder + '\/');
6195
6196					// tag.find(`${field_selector} img`).attr({'src':item.src}); forum3은 프로필 적용 되는데 forum2만 적용 안 되어서 아래와 같이 수정
6197
6198					if (tag.find(`${field_selector} img`).length > 0) {
6199						tag.find(`${field_selector} img`).attr({'src':item.src});
6200					} else {
6201						if (tag.find(field_selector).hasClass('hexagon')) {
6202							const $hex = tag.find(field_selector);
6203							if ($hex.hasClass('hexagon')) {
6204								const $img = $hex.find('image');
6205								if ($img.length > 0) {
6206									$img.attr('xlink:href', item.src);
6207								}
6208							}
6209						} 
6210					}
6211				}
6212				break;
6213
6214			default:
6215				break;
6216		}
6217	});
6218
6219	switch(_fu.eltype2) {
6220		case 'qna':
6221			tag.find(`.tpl-forum-qna-row > *:not(.tpl-forum-qna-details):not(.tpl-forum-list-content)`).empty();
6222			tag.find(`.tpl-forum-qna-row.answer .tpl-forum-list-cont`).removeAttr('style');
6223			break;
6224		case 'faq':
6225			if(_fu.config.faq_view_msg) {
6226				if(tag.find('.answer .tpl-forum-list-cont').length > 0) {
6227					tag.find('.answer .tpl-forum-list-cont').html(_fu.config.faq_view_msg);
6228				} else if(tag.find('.answer .inner-box').length > 0) {
6229					tag.find('.answer .inner-box').html(_fu.config.faq_view_msg);
6230				} else {
6231					tag.find('.answer .tpl-forum-list-content').html(_fu.config.faq_view_msg);
6232				}
6233			}
6234			break;
6235		default:
6236			break;
6237	}
6238
6239	if(item.link.active) tag.find('a:not([rel])').attr({href:item.link.val, class:item.link.cls, ...item.link.attr});
6240	else tag.find('a:not([rel])').attr({href:'javascript:void(0);', class:'deleted'});
6241	tag.find(`.tpl-forum-list-title,.tpl-forum-list-cont,.tpl-forum-list-thumb`).attr({'data-id':item.id,'data-option':item.option.val});
6242
6243	return tag.prop('outerHTML');
6244}
6245var initForumField = function(tmpEL) {
6246    if(tmpEL.is('[data-init="true"]')) return true;
6247    tmpEL.attr('data-init','true');
6248
6249	tmpEL.find('[data-loop="true"]').removeClass('sample-loop');
6250	if(tmpEL.is('[data-list-type]')) {
6251		tmpEL.attr('data-type2', tmpEL.is('[data-list-type="card"]') ? 'thumb' : 'normal');
6252	}
6253
6254	var eltype2 = 'normal';
6255	if(tmpEL.is('[data-type2]')) eltype2 = tmpEL.attr('data-type2');
6256	else if(tmpEL.is('[data-forum-type]').length > 0) eltype2 = tmpEL.attr('data-forum-type');
6257	else if(tmpEL.find('.tpl-forum-guestbook-area').length > 0) eltype2 = 'guestbook';
6258	else if(tmpEL.find('.tpl-forum-qna').length > 0) eltype2 = 'qna';
6259	else if(tmpEL.find('.question').length > 0) eltype2 = 'faq';
6260	else if(tmpEL.find('.thumb-wrap').length > 0) eltype2 = 'thumb';
6261
6262    var verOlder = (tmpEL.is('[data-fcolor]') || tmpEL.is('[data-ver="1"]')) ? true : false;
6263    if(verOlder) {
6264    } else {
6265
6266		var fields = {
6267			normal: ['hit','comment','like'],
6268			thumb: ['hit','comment','like'],
6269			faq: ['faq-toggle'],
6270			qna: ['cont'],
6271			guestbook: [],
6272		};
6273		fields.all = [...new Set([...fields.normal, ...fields.thumb, ...fields.qna, ...fields.faq, ...fields.guestbook])];
6274
6275		var fitem_selector = '.item';
6276		if(tmpEL.find(fitem_selector).length == 0 && tmpEL.find('tbody[data-loop="true"]').length > 0) tmpEL.find('tbody > tr').addClass('item');
6277		if(tmpEL.find(fitem_selector).length == 0) return false;
6278
6279		var fitem = tmpEL.find(fitem_selector).eq(0);
6280		if(fitem.length === 0 || fitem.find('[class*="tpl-forum-list-"]').length === 0) return false;
6281        var target = fitem.find('[class*="tpl-forum-list-"]').last().attr('class').trim().replace(/ /gi,'.');
6282
6283        $.each(fields[eltype2], function(i,k) {
6284			var tmpField = (fitem.find(`.tpl-forum-list-${k}`).length > 0) ? fitem.find(`.tpl-forum-list-${k}`) : tmpEL.find(`.tpl-forum-list-${k}`);
6285            var tmp_check = (tmpField.length > 0) ? true : false;
6286			if(tmp_check) {
6287				var tmp_iconstyle = tmpField.attr('data-style'),
6288					tmp_svg = '';
6289				if(typeof tmp_iconstyle != 'undefined' && tmp_iconstyle) {
6290					tmp_svg = clSVG(`field_${k.replace(/-/gi,'_')}_${tmp_iconstyle}`,16,16);
6291				}
6292
6293				if(tmp_svg != '') {
6294					tmpEL.find(`.tpl-forum-list-${k} > svg, .tpl-forum-list-${k} > .forum-${k}-icon`).remove();
6295					tmpEL.find(`.tpl-forum-list-${k}`).attr('data-style',tmp_iconstyle).prepend(`<span class="forum-${k}-icon">${tmp_svg}</span>`);
6296				}
6297
6298				if(k == 'cont' && eltype2 == 'qna') {
6299					var $tmp_qna_view = tmpEL.find(`.tpl-forum-qna.view`).eq(0).clone();
6300					tmpEL.find(`.tpl-forum-qna.view`).remove();
6301					tmpEL.find(`.tpl-forum-qna.list`).after($tmp_qna_view);
6302				}
6303			}
6304        });
6305    }
6306}
6307var showHideForumField = function(elObj, elsettings) {
6308	// console.log('showHideForumField', elObj.attr('data-name'), elObj.attr('data-ver'));
6309    /*
6310        - 설정에서 항목 OFF → .hidden 추가
6311		- 설정에서 항목 ON + empty or 0  → :empty 처리
6312
6313        - 폰트 반응형 설정 (fsize class 추가)
6314    */
6315
6316	initForumField(elObj);
6317
6318	if (typeof elsettings == 'undefined' ||
6319		$.isEmptyObject(elsettings)
6320	) {
6321		return false;
6322	}
6323
6324	var fields = {
6325		normal: ['title','num','category','name','myimg','date','hit','comment','like'],
6326		thumb: ['title','cont','thumb','num','category','name','date','hit','comment','like'],
6327		faq: ['title','cont'],
6328		qna: ['title','num','state','category','name','date','cont'],
6329		guestbook: ['cont','name','date'],
6330	};
6331	fields.all = [...new Set([...fields.normal, ...fields.thumb, ...fields.qna, ...fields.faq, ...fields.guestbook])];
6332
6333	if(elObj.is('[data-list-type]')) {
6334		elObj.attr('data-type2', elObj.is('[data-list-type="card"]') ? 'thumb' : 'normal');
6335	}
6336
6337    var _CMODE = (PAGE_MODE == 'c') ? true : false,
6338		_VALIDTYPE = (_CMODE) ? VALIDTYPE : property.VALIDTYPE,
6339		// el_seq = elObj.attr('data-id'),
6340		elid = elObj.attr('data-id') || '',
6341		eltype2 = elObj.attr('data-type2') || 'normal',
6342		isSample = elObj.find('.sample-loop').length > 0 ? true : false,
6343		isVer = elObj.attr('data-ver') || '',
6344		like_onoff = (typeof elsettings.like_display != 'undefined' && elsettings.like_display != 'N') ? true : false,
6345		comment_onoff = (typeof elsettings.comment_display != 'undefined' && elsettings.comment_display == 'OFF') ? false : true,
6346		namemask_onoff = (typeof elsettings.namemask_display != 'undefined' && elsettings.namemask_display == 'ON') ? true : false,
6347		date = (typeof elsettings.date != 'undefined' && elsettings.date) ? elsettings.date : 'DEF';
6348
6349	var field_disable = (typeof elsettings.field_disable != 'undefined' && !$.isEmptyObject(elsettings.field_disable)) ? elsettings.field_disable : [],
6350		field_list = eltype2 ? [...fields[eltype2]] : [];
6351
6352	if((!like_onoff || !_VALIDTYPE) && field_list.indexOf('like') > -1) field_list.splice(field_list.indexOf('like'), 1);
6353	if((!comment_onoff || $.inArray(eltype2, ['faq','qna']) > -1) && field_list.indexOf('comment') > -1) field_list.splice(field_list.indexOf('comment'), 1);
6354
6355	$.each(fields.all, function(i,v) {
6356		var onoff = ($.inArray(v, field_disable) > -1) ? false : true;
6357		if (onoff && $.inArray(v, field_list) == -1) onoff = false;
6358
6359		if(`${eltype2}.${v}.${isVer}` == 'faq.num.1') return true;
6360
6361		var more_selector = [];
6362		switch(v) {
6363			case 'cont':
6364				if($.inArray(eltype2, ['faq','qna','guestbook']) > -1) elObj.find(`.tpl-forum-list-cont`).addClass('write-css');
6365				break;
6366
6367			case 'category':
6368				more_selector.push(`#scate`);
6369				if(elObj.find('#scate').closest('.input-group-btn[data-caret]').length > 0) {
6370					if(onoff) elObj.find('#scate').closest('.input-group-btn[data-caret]').removeClass('hide');
6371					else elObj.find('#scate').closest('.input-group-btn[data-caret]').addClass('hide');
6372				}
6373
6374				if(isVer == '1' && elObj.find('#scate').closest('.input-group-btn.select-arrow').length > 0) {
6375					if(onoff) elObj.find('#scate').closest('.input-group-btn.select-arrow').removeClass('hide');
6376					else elObj.find('#scate').closest('.input-group-btn.select-arrow').addClass('hide');
6377				}
6378				break;
6379
6380			case 'comment':
6381				more_selector.push(`.tpl-forum-list-comment-icon`);
6382				break;
6383
6384			case 'myimg':
6385				more_selector.push(`.myimg-wrap`);
6386				break;
6387
6388			default:
6389				break;
6390		}
6391
6392		// 일괄 적용
6393		if(onoff) {
6394			elObj.find(`.tpl-forum-${v}`).removeClass('hide');
6395			elObj.find(`.tpl-forum-list-${v}`).removeClass('hide');
6396			if(more_selector != '') elObj.find(more_selector.join(',')).removeClass('hide');
6397		} else {
6398			elObj.find(`.tpl-forum-${v}`).addClass('hide');
6399			elObj.find(`.tpl-forum-list-${v}`).addClass('hide');
6400			if(more_selector != '') elObj.find(more_selector.join(',')).addClass('hide');
6401			if(!_CMODE) elObj.find(`.tpl-forum-${v}, .tpl-forum-list-${v}`).empty();
6402		}
6403
6404		// 개별 적용
6405		elObj.find(`.tpl-forum-list-${v}`).each(function(idx, tmp) {
6406			var tmpItem = $(this).closest('.item'),
6407				tmpField = $(this);
6408
6409			if(tmpField.is(':empty')) return true;
6410			
6411			switch(v) {
6412				case 'num':
6413					if(tmpItem.hasClass('n')) {
6414						var notice_tag = $(this).html(),
6415							notice_selector = `.tpl-forum-list-title .tpl-forum-list-notice-icon, .tpl-forum-list-title .tpl-forum-list-notice`;
6416
6417						tmpItem.find(notice_selector).remove();
6418						tmpItem.find('.tpl-forum-list-title').prepend(notice_tag);
6419
6420						if(onoff) tmpItem.find(notice_selector).addSvgClass('hide');
6421						else tmpItem.find(notice_selector).removeSvgClass('hide');
6422					}
6423					break;
6424
6425				case 'state':
6426					if(tmpField.hasClass('active')) tmpItem.removeClass('w');
6427					else tmpItem.addClass('w');
6428					break;
6429
6430				case 'name':
6431					if(onoff && isSample && namemask_onoff) {
6432						var tmp_v = $(this).text().trim(),
6433							tmp_cut = tmp_v.length >= 3 ? 1 : 2;
6434
6435						$(this).text(`${tmp_v.slice(0,tmp_cut)}***`);
6436					}
6437					break;
6438
6439				default:
6440					 break;
6441			}
6442		});
6443		
6444		// fsize 반영
6445		elObj.find(`
6446			.tpl-forum-list-${v}, 
6447			.search-box .form-control, .search-btn,
6448			.tpl-forum-pagination > li > a,
6449			.tpl-forum-write
6450		`).each(function() {
6451			$(this).removeClass(function(index, className) {
6452				return (className.match(/\bfsize\S+/g) || []).join(' ');
6453			});
6454
6455			if(!_CMODE || elObj.is('.el_viewblock')) {
6456				var tmp_fsize = ($(this).css('font-size') || '').match(/\d+(\.\d+)?/);
6457				if(tmp_fsize) $(this).addClass(`fsize${tmp_fsize[0]}`);
6458			}
6459		});
6460	});
6461
6462	elObj.find(`.tpl-forum-ul, .writer-wrap`).each(function() {
6463		if($(this).find('[class*="tpl-forum-list-"]').length > 0) {
6464			var childempty = ($(this).find('[class*="tpl-forum-list-"]:not(.hide)').length > 0) ? false : true;
6465			if(childempty) $(this).addClass('hide');
6466			else $(this).removeClass('hide');
6467		}
6468	});
6469
6470	if(eltype2 == 'guestbook') {
6471		if(getOrDefault(elsettings,'default_message','') != '') elObj.find('.input-content').attr('placeholder', elsettings.default_message);
6472
6473		var secret_display = getOrDefault(elsettings,'secret_display','U'),
6474			secret_checked = (secret_display == 'A') ? true : false;
6475		elObj.find('.secret-check input[type="checkbox"]').prop('checked', secret_checked);
6476		if(secret_display == 'U') elObj.find('.secret-check').removeClass('hide');
6477		else elObj.find('.secret-check').addClass('hide');
6478
6479
6480		var checkNonmem = true;
6481		if(_CMODE) checkNonmem = false;
6482		else {
6483			var mem_data = RENDER.b.UMEMBER;
6484			if(mem_data.id && ((mem_data.check_uadm || mem_data.check_adm) || (!mem_data.check_uadm && !mem_data.check_adm && mem_data.id_type != 'creatorlink'))) {
6485				checkNonmem = false;
6486			}
6487		}
6488		if(!checkNonmem) elObj.find('.input-nonmem, .captcha').addClass('hide');
6489	}
6490
6491	if(isVer == '1') {
6492		elObj.find('.hidden').removeClass('hidden');
6493
6494		if(eltype2 == 'faq') elObj.find(`.tpl-forum-list-num`).removeClass('hide');
6495		else {
6496			if(elObj.find('.tpl-forum-list-num.hide').length > 0) {
6497				elObj.find('.tpl-forum-list-title .tpl-forum-list-notice, .tpl-forum-list-title .tpl-forum-list-notice-icon').removeSvgClass('hide');
6498			} else {
6499				elObj.find('.tpl-forum-list-title .tpl-forum-list-notice, .tpl-forum-list-title .tpl-forum-list-notice-icon').addSvgClass('hide');
6500			}
6501		}
6502
6503		elObj.find('td[colspan]').each(function() {
6504			var tmp_colspan = $(this).closest('tr').prev('tr').find('td:not(:empty):not(.hide)').length;
6505			$(this).attr('colspan',tmp_colspan);
6506		});
6507		
6508	}
6509
6510	var writebtn_onoff = (typeof elsettings.writebtn_display !='undefined' && elsettings.writebtn_display == 'OFF') ? false : true;
6511	
6512	if(!_CMODE && !writebtn_onoff) elObj.find('.tpl-forum-write').remove();
6513
6514	if(	$.inArray(eltype2, ['normal','thumb']) > -1 
6515		&& elObj.find('.layout-table').length === 0
6516		&& elObj.is('[data-msny="true"]')
6517		&& typeof elObj.find('.container').data('masonry') != 'object'
6518	) {
6519		reloadBlockMasonry('init',elObj);
6520	}
6521}

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.