').css({visibility: 'hidden', width: 100, overflow: 'scroll'}).appendTo('body'),
widthWithScroll = $('
').css({width: '100%'}).appendTo($outer).outerWidth();
$outer.remove();
scbw = 100 - widthWithScroll;
offset = $pc.css({overflow:'scroll'}).offset();
w = $pc.width(10).height(10000).get(0).scrollWidth + offset.left*2;
if(w < 800) w = 800 + offset.left*2;
// Window 의 너비나 높이는 스크린의 너비나 높이보다 클 수 없다. 스크린의 너비나 높이와 내용의 너비나 높이를 비교해서 최소값을 이용한다.
w = Math.min(w, window.screen.availWidth);
h = $pc.width(w - offset.left*2).height(10).get(0).scrollHeight + offset.top*2;
dw = $win.width();
dh = $win.height();
h = Math.min(h, window.screen.availHeight - 100);
window.resizeBy(w - dw, h - dh);
$pc.width('100%').css({overflow:'',height:'','box-sizing':'border-box'});
}
/**
* @brief 추천/비추천,스크랩,신고기능등 특정 srl에 대한 특정 module/action을 호출하는 함수
**/
function doCallModuleAction(module, action, target_srl) {
var params = {
target_srl : target_srl,
cur_mid : current_mid,
mid : current_mid
};
exec_xml(module, action, params, completeCallModuleAction);
}
function completeCallModuleAction(ret_obj, response_tags) {
if(ret_obj.message!='success') alert(ret_obj.message);
location.reload();
}
function completeMessage(ret_obj) {
alert(ret_obj.message);
location.reload();
}
/* 언어코드 (lang_type) 쿠키값 변경 */
function doChangeLangType(obj) {
if(typeof(obj) == "string") {
setLangType(obj);
} else {
var val = obj.options[obj.selectedIndex].value;
setLangType(val);
}
if(location.href.match(/[?&]l=[a-z]+/)) {
location.href = location.href.setQuery('l', '');
} else {
location.reload();
}
}
function setLangType(lang_type) {
var baseurl = XE.URI(default_url).pathname();
if (baseurl !== '/') {
XE.cookie.remove('lang_type', { path: '/' });
}
XE.cookie.set('lang_type', lang_type, { path: baseurl, expires: 365 });
}
/* 색상 테마 변경 */
function getColorScheme() {
if ($('body').hasClass('color_scheme_dark')) {
return 'dark';
} else {
return 'light';
}
}
function setColorScheme(color_scheme) {
if (color_scheme === 'dark' || color_scheme === 'light') {
$('body').addClass('color_scheme_' + color_scheme).removeClass('color_scheme_' + (color_scheme === 'dark' ? 'light' : 'dark'));
XE.cookie.set('rx_color_scheme', color_scheme, { path: window.XE.URI(default_url).pathname(), expires: 365 });
} else {
XE.cookie.remove('rx_color_scheme', { path: window.XE.URI(default_url).pathname() });
color_scheme = (window.matchMedia && window.matchMedia('(prefers-color-scheme:dark)').matches) ? 'dark' : 'light';
$('body').addClass('color_scheme_' + color_scheme).removeClass('color_scheme_' + (color_scheme === 'dark' ? 'light' : 'dark'));
}
}
function detectColorScheme() {
// Return if a color scheme is already selected.
var body_element = $('body');
if(body_element.hasClass('color_scheme_light') || body_element.hasClass('color_scheme_dark')) {
return;
}
// Detect the cookie.
var color_scheme = XE.cookie.get('rx_color_scheme');
// Detect the device color scheme.
var match_media = window.matchMedia ? window.matchMedia('(prefers-color-scheme:dark)') : null;
if (color_scheme !== 'light' && color_scheme !== 'dark') {
color_scheme = (match_media && match_media.matches) ? 'dark' : 'light';
}
// Set the body class according to the detected color scheme.
body_element.addClass('color_scheme_' + color_scheme);
// Add an event listener to detect changes to the device color scheme.
match_media && match_media.addListener && match_media.addListener(function(e) {
if (e.matches) {
body_element.removeClass('color_scheme_light').addClass('color_scheme_dark');
} else {
body_element.removeClass('color_scheme_dark').addClass('color_scheme_light');
}
});
}
/* 미리보기 */
function doDocumentPreview(obj) {
var fo_obj = obj;
while(fo_obj.nodeName != "FORM") {
fo_obj = fo_obj.parentNode;
}
if(fo_obj.nodeName != "FORM") return;
var editor_sequence = fo_obj.getAttribute('editor_sequence');
var content = editorGetContent(editor_sequence);
var win = window.open("", "previewDocument","toolbars=no,width=700px;height=800px,scrollbars=yes,resizable=yes");
var dummy_obj = jQuery("#previewDocument");
if(!dummy_obj.length) {
jQuery(
''
).appendTo(document.body);
dummy_obj = jQuery("#previewDocument")[0];
} else {
dummy_obj = dummy_obj[0];
}
if(dummy_obj) {
dummy_obj.content.value = content;
dummy_obj.submit();
}
}
/* 게시글 저장 */
function doDocumentSave(obj) {
var editor_sequence = obj.form.getAttribute('editor_sequence');
var prev_content = editorRelKeys[editor_sequence].content.value;
if(typeof(editor_sequence)!='undefined' && editor_sequence && typeof(editorRelKeys)!='undefined' && typeof(editorGetContent)=='function') {
var content = editorGetContent(editor_sequence);
editorRelKeys[editor_sequence].content.value = content;
}
var params={}, responses=['error','message','document_srl'], elms=obj.form.elements, data=jQuery(obj.form).serializeArray();
jQuery.each(data, function(i, field){
var val = jQuery.trim(field.value);
if(!val) return true;
if(/\[\]$/.test(field.name)) field.name = field.name.replace(/\[\]$/, '');
if(params[field.name]) params[field.name] += '|@|'+val;
else params[field.name] = field.value;
});
exec_xml('document','procDocumentTempSave', params, completeDocumentSave, responses, params, obj.form);
editorRelKeys[editor_sequence].content.value = prev_content;
return false;
}
function completeDocumentSave(ret_obj) {
jQuery('input[name=document_srl]').eq(0).val(ret_obj.document_srl);
alert(ret_obj.message);
}
/* 저장된 게시글 불러오기 */
var objForSavedDoc = null;
function doDocumentLoad(obj) {
// 저장된 게시글 목록 불러오기
objForSavedDoc = obj.form;
popopen(request_uri.setQuery('module','document').setQuery('act','dispTempSavedList'));
}
/* 저장된 게시글의 선택 */
function doDocumentSelect(document_srl, module) {
if(!opener || !opener.objForSavedDoc) {
window.close();
return;
}
if(module===undefined) {
module = 'document';
}
// 게시글을 가져와서 등록하기
switch(module) {
case 'page' :
var url = opener.current_url;
url = url.setQuery('document_srl', document_srl);
if(url.getQuery('act') === 'dispPageAdminMobileContentModify')
{
url = url.setQuery('act', 'dispPageAdminMobileContentModify');
}
else
{
url = url.setQuery('act', 'dispPageAdminContentModify');
}
opener.location.href = url;
break;
default :
opener.location.href = opener.current_url.setQuery('document_srl', document_srl).setQuery('act', 'dispBoardWrite');
break;
}
window.close();
}
/* 스킨 정보 */
function viewSkinInfo(module, skin) {
popopen("./?module=module&act=dispModuleSkinInfo&selected_module="+module+"&skin="+skin, 'SkinInfo');
}
/* 관리자가 문서를 관리하기 위해서 선택시 세션에 넣음 */
var addedDocument = [];
function doAddDocumentCart(obj) {
var srl = obj.value;
addedDocument[addedDocument.length] = srl;
setTimeout(function() { callAddDocumentCart(addedDocument.length); }, 100);
}
function callAddDocumentCart(document_length) {
if(addedDocument.length<1 || document_length != addedDocument.length) return;
var params = [];
params.srls = addedDocument.join(",");
exec_xml("document","procDocumentAddCart", params, null);
addedDocument = [];
}
/* ff의 rgb(a,b,c)를 #... 로 변경 */
function transRGB2Hex(value) {
if(!value) return value;
if(value.indexOf('#') > -1) return value.replace(/^#/, '');
if(value.toLowerCase().indexOf('rgb') < 0) return value;
value = value.replace(/^rgb\(/i, '').replace(/\)$/, '');
value_list = value.split(',');
var hex = '';
for(var i = 0; i < value_list.length; i++) {
var color = parseInt(value_list[i], 10).toString(16);
if(color.length == 1) color = '0'+color;
hex += color;
}
return hex;
}
/* 보안 로그인 모드로 전환 */
function toggleSecuritySignIn() {
var href = location.href;
if(/https:\/\//i.test(href)) location.href = href.replace(/^https/i,'http');
else location.href = href.replace(/^http/i,'https');
}
function reloadDocument() {
location.reload();
}
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/
var Base64 = {
// private property
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding
encode : function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
input = Base64._utf8_encode(input);
while (i < input.length) {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
}
return output;
},
// public method for decoding
decode : function (input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
output = Base64._utf8_decode(output);
return output;
},
// private method for UTF-8 encoding
_utf8_encode : function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
},
// private method for UTF-8 decoding
_utf8_decode : function (utftext) {
var string = "";
var i = 0;
var c = 0, c1 = 0, c2 = 0, c3 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
};
/* ----------------------------------------------
* DEPRECATED
* 하위호환용으로 남겨 놓음
* ------------------------------------------- */
window.ssl_actions = [];
if(typeof(resizeImageContents) == 'undefined') {
window.resizeImageContents = function() {};
}
if(typeof(activateOptionDisabled) == 'undefined') {
window.activateOptionDisabled = function() {};
}
objectExtend = jQuery.extend;
/**
* @brief 특정 Element의 display 옵션 토글
**/
function toggleDisplay(objId) {
jQuery('#'+objId).toggle();
}
/**
* @brief 에디터에서 사용하되 내용 여닫는 코드 (zb5beta beta 호환용으로 남겨 놓음)
**/
function svc_folder_open(id) {
jQuery("#_folder_open_"+id).hide();
jQuery("#_folder_close_"+id).show();
jQuery("#_folder_"+id).show();
}
function svc_folder_close(id) {
jQuery("#_folder_open_"+id).show();
jQuery("#_folder_close_"+id).hide();
jQuery("#_folder_"+id).hide();
}
/**
* @brief 날짜 선택 (달력 열기)
**/
function open_calendar(fo_id, day_str, callback_func) {
if(typeof(day_str)=="undefined") day_str = "";
var url = "./common/tpl/calendar.php?";
if(fo_id) url+="fo_id="+fo_id;
if(day_str) url+="&day_str="+day_str;
if(callback_func) url+="&callback_func="+callback_func;
popopen(url, 'Calendar');
}
var loaded_popup_menus = XE.loaded_popup_menus;
function createPopupMenu() {}
function chkPopupMenu() {}
function displayPopupMenu(ret_obj, response_tags, params) {
XE.displayPopupMenu(ret_obj, response_tags, params);
}
function GetObjLeft(obj) {
return jQuery(obj).offset().left;
}
function GetObjTop(obj) {
return jQuery(obj).offset().top;
}
function replaceOuterHTML(obj, html) {
jQuery(obj).replaceWith(html);
}
function getOuterHTML(obj) {
return jQuery(obj).html().trim();
}
function setCookie(name, value, expires, path) {
var options = {
path: path ? path : "/",
secure: cookies_ssl ? true : false
};
if (expires) {
options.expires = expires;
}
XE.cookie.set(name, value, options);
}
function getCookie(name) {
return XE.cookie.get(name);
}
function is_def(v) {
return typeof(v) != 'undefined' && v !== null;
}
function ucfirst(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
function get_by_id(id) {
return document.getElementById(id);
}
jQuery(function($){
// display popup menu that contains member actions and document actions
$(document).on('click', function(evt) {
var $area = $('#popup_menu_area');
if(!$area.length) $area = $('').appendTo(document.body);
// 이전에 호출되었을지 모르는 팝업메뉴 숨김
$area.hide();
var $target = $(evt.target).filter('a,div,span');
if(!$target.length) $target = $(evt.target).closest('a,div,span');
if(!$target.length) return;
// 객체의 className값을 구함
var cls = $target.attr('class'), match;
if(cls) match = cls.match(new RegExp('(?:^| )((document|comment|member)_([1-9]\\d*))(?: |$)',''));
if(!match) return;
// mobile에서 touchstart에 의한 동작 시 pageX, pageY 위치를 구함
if(evt.pageX===undefined || evt.pageY===undefined)
{
var touch = evt.originalEvent.touches[0];
if(touch!==undefined || !touch)
{
touch = evt.originalEvent.changedTouches[0];
}
evt.pageX = touch.pageX;
evt.pageY = touch.pageY;
}
var module = match[2];
var action = 'get'+ucfirst(module)+'Menu';
var params = {
mid : current_mid,
cur_mid : current_mid,
menu_id : match[1],
target_srl : match[3],
cur_act : current_url.getQuery('act'),
page_x : evt.pageX,
page_y : evt.pageY
};
var response_tags = 'error message menus'.split(' ');
// prevent default action
evt.preventDefault();
evt.stopPropagation();
if(is_def(XE.loaded_popup_menus[params.menu_id])) {
return XE.displayPopupMenu(params, response_tags, params);
}
show_waiting_message = false;
exec_json(module + '.' + action, params, function(data) {
XE.displayPopupMenu(data, response_tags, params);
show_waiting_message = true;
});
});
/**
* Create popup windows automatically.
* Find anchors that have the '_xe_popup' class, then add popup script to them.
*/
$('body').on('click', 'a._xe_popup', function(event) {
var $this = $(this);
var name = $this.attr('name');
var href = $this.attr('href');
if (!name) name = '_xe_popup_' + Math.floor(Math.random() * 1000);
event.preventDefault();
winopen(href, name, 'left=10,top=10,width=10,height=10,resizable=no,scrollbars=no,toolbars=no');
});
// date picker default settings
if($.datepicker) {
$.datepicker.setDefaults({
dateFormat : 'yy-mm-dd'
});
}
});