mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 00:39:57 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8359 201d5d3c-b55e-5fd7-737f-ddc643e51545
60 lines
No EOL
37 KiB
JavaScript
60 lines
No EOL
37 KiB
JavaScript
/**
|
|
* @file js_app.js
|
|
* @author NHN (developers@xpressengine.com)
|
|
* @brief XE JavaScript Application Framework (JAF)
|
|
* @namespace xe
|
|
* @update 20100701
|
|
*/
|
|
(function($){var _xe_base,_app_base,_plugin_base,_apps=[];_xe_base={getName:function(){return'Core'},createApp:function(sName,oDef){var _base=getTypeBase();$.extend(_base.prototype,_app_base,oDef);_base.prototype.getName=function(){return sName};return _base},createPlugin:function(sName,oDef){var _base=getTypeBase();$.extend(_base.prototype,_plugin_base,oDef);_base.prototype.getName=function(){return sName};return _base},getApps:function(){return $.makeArray(_apps)},getApp:function(indexOrName){indexOrName=(indexOrName||'').toLowerCase();if(typeof _apps[indexOrName]!='undefined'){return _apps[indexOrName]}else return null},registerApp:function(oApp){var sName=oApp.getName().toLowerCase();_apps.push(oApp);if(!$.isArray(_apps[sName]))_apps[sName]=[];_apps[sName].push(oApp);oApp.parent=this;if($.isFunction(oApp.activate))oApp.activate()},unregisterApp:function(oApp){var sName=oPlugin.getName().toLowerCase(),nIndex=$.inArray(oApp,_apps);if(nIndex>=0)_apps.splice(nIndex,1);if($.isArray(_apps[sName])){nIndex=$.inArray(oApp,_apps[sName]);if(nIndex>=0)_apps[sName].splice(nIndex,1)};if($.isFunction(oApp.deactivate))oApp.deactivate()},broadcast:function(msg,params){this._broadcast(this,msg,params)},_broadcast:function(sender,msg,params){for(var i=0;i<_apps.length;i++)_apps[i]._cast(sender,msg,params);this._cast(sender,msg,params)}};_app_base={_plugins:[],_messages:{},getPlugin:function(sPluginName){sPluginName=sPluginName.toLowerCase();if($.isArray(this._plugins[sPluginName])){return this._plugins[sPluginName]}else return[]},registerPlugin:function(oPlugin){var self=this,sName=oPlugin.getName().toLowerCase();if($.inArray(oPlugin,this._plugins)>=0)return false;this._plugins.push(oPlugin);if(!$.isArray(this._plugins[sName]))this._plugins[sName]=[];this._plugins[sName].push(oPlugin);$.each(oPlugin._binded_fn,function(api,fn){self.registerHandler(api,fn)});oPlugin.oApp=this;if($.isFunction(oPlugin.activate))oPlugin.activate();return true},registerHandler:function(api,func){var msgs=this._messages;api=api.toUpperCase();if(!$.isArray(msgs[api]))msgs[api]=[];msgs[api].push(func)},cast:function(msg,params){return this._cast(this,msg,params||[])},broadcast:function(sender,msg,params){if(this.parent&&this.parent._broadcast)this.parent._broadcast(sender,msg,params)},_cast:function(sender,msg,params){var i,len,aMsg=this._messages;msg=msg.toUpperCase();if(aMsg['BEFORE_'+msg]||this['API_BEFORE_'+msg]){var bContinue=this._cast(sender,'BEFORE_'+msg,params);if(!bContinue)return};var vRet=[],sFn='API_'+msg;if($.isArray(aMsg[msg]))for(i=0;i<aMsg[msg].length;i++)vRet.push(aMsg[msg][i](sender,params));if(vRet.length<2)vRet=vRet[0];if(aMsg['AFTER_'+msg]||this['API_AFTER_'+msg])this._cast(sender,'AFTER_'+msg,params);if(!/^(?:AFTER|BEFORE)_/.test(msg)){return vRet}else return $.isArray(vRet)?($.inArray(false,vRet)<0):((typeof vRet=='undefined')?true:!!vRet)}};_plugin_base={oApp:null,cast:function(msg,params){if(this.oApp&&this.oApp._cast)return this.oApp._cast(this,msg,params||[])},broadcast:function(msg,params){if(this.oApp&&this.oApp.broadcast)this.oApp.broadcast(this,mag,params||[])}}
|
|
function getTypeBase(){var _base=function(){var self=this,pool=null;if($.isArray(this._plugins))this._plugins=[];if(this._messages){this._messages={}}else this._binded_fn={};$.each(this,function(key,val){if(!$.isFunction(val))return true;if(!/^API_([A-Z0-9_]+)$/.test(key))return true;var api=RegExp.$1,fn=function(sender,params){return self[key](sender,params)};if(self._messages){self._messages[api]=[fn]}else self._binded_fn[api]=fn});if($.isFunction(this.init))this.init.apply(this,arguments)};return _base};window.xe=$.extend(_app_base,_xe_base);window.xe.lang={};$(function(){xe.broadcast('ONREADY')});$(window).load(function(){xe.broadcast('ONLOAD')})})(jQuery);if(jQuery)jQuery.noConflict();(function($){var UA=navigator.userAgent.toLowerCase();$.os={Linux:/linux/.test(UA),Unix:/x11/.test(UA),Mac:/mac/.test(UA),Windows:/win/.test(UA)};$.os.name=($.os.Windows)?'Windows':($.os.Linux)?'Linux':($.os.Unix)?'Unix':($.os.Mac)?'Mac':'';window.XE={loaded_popup_menus:new Array(),addedDocument:new Array(),checkboxToggleAll:function(){var itemName='cart',options={wrap:null,checked:'toggle',doClick:false};switch(arguments.length){case 1:if(typeof (arguments[0])=="string"){itemName=arguments[0]}else $.extend(options,arguments[0]||{});break;case 2:itemName=arguments[0];$.extend(options,arguments[1]||{})};if(options.doClick==true)options.checked=null;if(typeof (options.wrap)=="string")options.wrap='#'+options.wrap;if(options.wrap){var obj=$(options.wrap).find('input[name='+itemName+']:checkbox')}else var obj=$('input[name='+itemName+']:checkbox');if(options.checked=='toggle'){obj.each(function(){$(this).attr('checked',($(this).attr('checked'))?false:true)})}else (options.doClick==true)?obj.click():obj.attr('checked',options.checked)},displayPopupMenu:function(ret_obj,response_tags,params){var target_srl=params.target_srl,menu_id=params.menu_id,menus=ret_obj.menus,html="";if(this.loaded_popup_menus[menu_id]){html=this.loaded_popup_menus[menu_id]}else{if(menus){var item=menus.item;if(typeof (item.length)=='undefined'||item.length<1)item=new Array(item);if(item.length)for(var i=0;i<item.length;i++){var url=item[i].url,str=item[i].str,icon=item[i].icon,target=item[i].target,styleText="",click_str="";if(icon)styleText=" style=\"background-image:url('"+icon+"')\" ";switch(target){case"popup":click_str=" onclick=\"popopen(this.href,'"+target+"'); return false;\"";break;case"self":break;case"javascript":click_str=" onclick=\""+url+"; return false; \"";url="#";break;default:click_str=" onclick=\"window.open(this.href); return false;\"";break};html+='<li '+styleText+'><a href="'+url+'"'+click_str+'>'+str+'</a></li> '}};this.loaded_popup_menus[menu_id]=html};if(html){var area=$('#popup_menu_area').html('<ul>'+html+'</ul>'),areaOffset={top:params.page_y,left:params.page_x};if(area.outerHeight()+areaOffset.top>$(window).height()+$(window).scrollTop())areaOffset.top=$(window).height()-area.outerHeight()+$(window).scrollTop();if(area.outerWidth()+areaOffset.left>$(window).width()+$(window).scrollLeft())areaOffset.left=$(window).width()-area.outerWidth()+$(window).scrollLeft();area.css({top:areaOffset.top,left:areaOffset.left}).show()}}}})(jQuery);jQuery(function($){if($.browser.msie)$('select').each(function(i,sels){var disabled_exists=false,first_enable=new Array();for(var j=0;j<sels.options.length;j++)if(sels.options[j].disabled){sels.options[j].style.color='#CCCCCC';disabled_exists=true}else first_enable[i]=(first_enable[i]>-1)?first_enable[i]:j;if(!disabled_exists)return;sels.oldonchange=sels.onchange;sels.onchange=function(){if(this.options[this.selectedIndex].disabled){this.selectedIndex=first_enable[i]}else if(this.oldonchange)this.oldonchange()};if(sels.selectedIndex>=0&&sels.options[sels.selectedIndex].disabled)sels.onchange()});var drEditorFold=$('.xe_content .fold_button');if(drEditorFold.size()){var fold_container=$('div.fold_container',drEditorFold);$('button.more',drEditorFold).click(function(){$(this).hide().next('button').show().parent().next(fold_container).show()});$('button.less',drEditorFold).click(function(){$(this).hide().prev('button').show().parent().next(fold_container).hide()})}});String.prototype.getQuery=function(key){var idx=this.indexOf('?');if(idx==-1)return null;var query_string=this.substr(idx+1,this.length),args={};query_string.replace(/([^=]+)=([^&]*)(&|$)/g,function(){args[arguments[1]]=arguments[2]});var q=args[key];if(typeof (q)=="undefined")q="";return q};String.prototype.setQuery=function(key,val){var idx=this.indexOf('?'),uri=this.replace(/#$/,'');if(idx!=-1){var query_string=uri.substr(idx+1,this.length),args={},q_list=[];uri=this.substr(0,idx);query_string.replace(/([^=]+)=([^&]*)(&|$)/g,function(all,key,val){args[key]=val});args[key]=val;jQuery.each(args,function(key,val){if(!jQuery.trim(val))return;q_list.push(key+'='+decodeURI(val))});query_string=q_list.join('&');uri=uri+(query_string?'?'+query_string:'')}else if(val.toString().trim())uri=uri+"?"+key+"="+val;var re=/https:\/\/([^:\/]+)(:\d+|)/i,check=re.exec(uri);if(check){var toReplace="http://"+check[1];if(typeof (http_port)!='undefined'&&http_port!=80)toReplace+=":"+http_port;uri=uri.replace(re,toReplace)};var bUseSSL=false;if(typeof (enforce_ssl)!='undefined'&&enforce_ssl){bUseSSL=true}else if(typeof (ssl_actions)!='undefined'&&typeof (ssl_actions.length)!='undefined'&&uri.getQuery('act')){var act=uri.getQuery('act');for(i=0;i<ssl_actions.length;i++)if(ssl_actions[i]==act){bUseSSL=true;break}};if(bUseSSL){var re=/http:\/\/([^:\/]+)(:\d+|)/i,check=re.exec(uri);if(check){var toReplace="https://"+check[1];if(typeof (https_port)!='undefined'&&https_port!=443)toReplace+=":"+https_port;uri=uri.replace(re,toReplace)}};return encodeURI(uri)};String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*$)/g,"")}
|
|
function xSleep(sec){sec=sec/1000;var now=new Date(),sleep=new Date();while(sleep.getTime()-now.getTime()<sec)sleep=new Date()}
|
|
function isDef(){for(var i=0;i<arguments.length;++i)if(typeof (arguments[i])=="undefined")return false;return true};var winopen_list=new Array()
|
|
function winopen(url,target,attribute){if(typeof (xeVid)!='undefined'&&url.indexOf(request_uri)>-1&&!url.getQuery('vid'))url=url.setQuery('vid',xeVid);try{if(target!="_blank"&&winopen_list[target]){winopen_list[target].close();winopen_list[target]=null}}catch(e){};if(typeof (target)=='undefined')target='_blank';if(typeof (attribute)=='undefined')attribute='';var win=window.open(url,target,attribute);win.focus();if(target!="_blank")winopen_list[target]=win}
|
|
function popopen(url,target){if(typeof (target)=="undefined")target="_blank";if(typeof (xeVid)!='undefined'&&url.indexOf(request_uri)>-1&&!url.getQuery('vid'))url=url.setQuery('vid',xeVid);winopen(url,target,"left=10,top=10,width=10,height=10,scrollbars=no,resizable=yes,toolbars=no")}
|
|
function sendMailTo(to){location.href="mailto:"+to}
|
|
function move_url(url,open_wnidow){if(!url)return false;if(typeof (open_wnidow)=='undefined')open_wnidow='N';if(open_wnidow=='N'){open_wnidow=false}else open_wnidow=true;if(/^\./.test(url))url=request_uri+url;if(open_wnidow){winopen(url)}else location.href=url;return false}
|
|
function displayMultimedia(src,width,height,options){var html=_displayMultimedia(src,width,height,options);if(html)document.writeln(html)}
|
|
function _displayMultimedia(src,width,height,options){if(src.indexOf('files')==0)src=request_uri+src;var defaults={wmode:'transparent',allowScriptAccess:'sameDomain',quality:'high',flashvars:'',autostart:false},params=jQuery.extend(defaults,options||{}),autostart=(params.autostart&¶ms.autostart!='false')?'true':'false';delete (params.autostart);var clsid="",codebase="",html="";if(/\.(gif|jpg|jpeg|bmp|png)$/i.test(src)){html='<img src="'+src+'" width="'+width+'" height="'+height+'" />'}else if(/\.flv$/i.test(src)||/\.mov$/i.test(src)||/\.moov$/i.test(src)||/\.m4v$/i.test(src)){html='<embed src="'+request_uri+'common/tpl/images/flvplayer.swf" allowfullscreen="true" autostart="'+autostart+'" width="'+width+'" height="'+height+'" flashvars="&file='+src+'&width='+width+'&height='+height+'&autostart='+autostart+'" wmode="'+params.wmode+'" />'}else if(/\.swf/i.test(src)){clsid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';if(typeof (enforce_ssl)!='undefined'&&enforce_ssl){codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0"}else codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0";html='<object classid="'+clsid+'" codebase="'+codebase+'" width="'+width+'" height="'+height+'" flashvars="'+params.flashvars+'">';html+='<param name="movie" value="'+src+'" />';for(var name in params)if(params[name]!='undefined'&¶ms[name]!='')html+='<param name="'+name+'" value="'+params[name]+'" />';html+='<embed src="'+src+'" autostart="'+autostart+'" width="'+width+'" height="'+height+'" flashvars="'+params.flashvars+'" wmode="'+params.wmode+'"></embed></object>'}else{if(jQuery.browser.mozilla||jQuery.browser.opera)autostart=(params.autostart&¶ms.autostart!='false')?'1':'0';html='<embed src="'+src+'" autostart="'+autostart+'" width="'+width+'" height="'+height+'"';if(params.wmode=='transparent')html+=' windowlessvideo="1"';html+='></embed>'};return html}
|
|
function zbxe_folder_open(id){jQuery("#folder_open_"+id).hide();jQuery("#folder_close_"+id).show();jQuery("#folder_"+id).show()}
|
|
function zbxe_folder_close(id){jQuery("#folder_open_"+id).show();jQuery("#folder_close_"+id).hide();jQuery("#folder_"+id).hide()}
|
|
function setFixedPopupSize(){var $=jQuery,$header=$('#popHeader'),$body=$('#popBody');if($body.length)if($body.height()>400)$body.css({overflow:'auto',overflowX:'hidden',height:400+'px'});var $win=$(window),$pc=$('#popup_content'),w=Math.max($pc[0].offsetWidth,600),h=$pc[0].offsetHeight,dw=$win.width(),dh=$win.height(),_w=0,_h=0;if(w!=dw)_w=w-dw;if(h!=dh)_h=h-dh;if(_w||_h)window.resizeBy(_w,_h);if(!arguments.callee.executed){setTimeout(setFixedPopupSize,300);arguments.callee.executed=true}}
|
|
function doCallModuleAction(module,action,target_srl){var params=new Array();params.target_srl=target_srl;params.cur_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()}
|
|
function doChangeLangType(obj){if(typeof (obj)=="string"){setLangType(obj)}else{var val=obj.options[obj.selectedIndex].value;setLangType(val)};location.href=location.href.setQuery('l','')}
|
|
function setLangType(lang_type){var expire=new Date();expire.setTime(expire.getTime()+(7000*24*3600000));setCookie('lang_type',lang_type,expire,'/')}
|
|
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'),content=editorGetContent(editor_sequence),win=window.open("","previewDocument","toolbars=no,width=700px;height=800px,scrollbars=yes,resizable=yes"),dummy_obj=jQuery("#previewDocument");if(!dummy_obj.length){jQuery('<form id="previewDocument" target="previewDocument" method="post" action="'+request_uri+'"><input type="hidden" name="module" value="document" /><input type="hidden" name="act" value="dispDocumentPreview" /><input type="hidden" name="content" /></form>').appendTo(document.body);dummy_obj=jQuery("#previewDocument")[0]};if(dummy_obj){dummy_obj.content.value=content;dummy_obj.submit()}}
|
|
function doDocumentSave(obj){var editor_sequence=obj.form.getAttribute('editor_sequence'),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('member','procMemberSaveDocument',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','member').setQuery('act','dispSavedDocumentList'))}
|
|
function doDocumentSelect(document_srl){if(!opener||!opener.objForSavedDoc){window.close();return};opener.location.href=opener.current_url.setQuery('document_srl',document_srl).setQuery('act','dispBoardWrite');window.close()}
|
|
function viewSkinInfo(module,skin){popopen("./?module=module&act=dispModuleSkinInfo&selected_module="+module+"&skin="+skin,'SkinInfo')};var addedDocument=new Array()
|
|
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=new Array();params.srls=addedDocument.join(",");exec_xml("document","procDocumentAddCart",params,null);addedDocument=new Array()}
|
|
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()};var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(input){var output="",chr1,chr2,chr3,enc1,enc2,enc3,enc4,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},decode:function(input){var output="",chr1,chr2,chr3,enc1,enc2,enc3,enc4,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},_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},_utf8_decode:function(utftext){var string="",i=0,c=c1=c2=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}};if(typeof (resizeImageContents)=='undefined')function resizeImageContents(){};if(typeof (activateOptionDisabled)=='undefined')function activateOptionDisabled(){};objectExtend=jQuery.extend
|
|
function toggleDisplay(objId){jQuery('#'+objId).toggle()}
|
|
function checkboxSelectAll(formObj,name,checked){var itemName=name,option={};if(typeof (formObj)!="undefined")option.wrap=formObj;if(typeof (checked)!="undefined")option.checked=checked;XE.checkboxToggleAll(itemName,option)}
|
|
function clickCheckBoxAll(formObj,name){var itemName=name,option={doClick:true};if(typeof (formObj)!="undefined")option.wrap=formObj;XE.checkboxToggleAll(itemName,option)}
|
|
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()}
|
|
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,expire,path){var s_cookie=name+"="+escape(value)+((!expire)?"":("; expires="+expire.toGMTString()))+"; path="+((!path)?"/":path);document.cookie=s_cookie}
|
|
function is_def(v){return(typeof (v)!='undefined')}
|
|
function ucfirst(str){return str.charAt(0).toUpperCase()+str.slice(1)};jQuery(function($){$('.lang_code').each(function(){var objText=$(this),targetName=objText.attr("id");if(typeof (targetName)=="undefined")targetName=objText.attr("name");if(typeof (targetName)=="undefined")return;objText.after("<a href='"+request_uri.setQuery('module','module').setQuery('act','dispModuleAdminLangcode').setQuery('target',targetName)+"' class='buttonSet buttonSetting' onclick='popopen(this.href);return false;'><span>find_langcode</span></a>")});$(document).click(function(evt){var $area=$('#popup_menu_area');if(!$area.length)$area=$('<div id="popup_menu_area" style="display:none;z-index:9999" />').appendTo(document.body);$area.hide();var $target=$(evt.target).filter('a,div,span');if(!$target.length)$target=$target.parents('a,div,span').eq(0);if(!$target.length)return;var match=$target.attr('class').match(new RegExp('(?:^| )((document|comment|member)_([1-9]\\d*))(?: |$)',''));if(!match)return;var action='get'+ucfirst(match[2])+'Menu',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},response_tags='error message menus'.split(' ');if(is_def(window.xeVid))params.vid=xeVid;if(is_def(XE.loaded_popup_menus[params.menu_id]))return XE.displayPopupMenu(params,response_tags,params)&&false;show_waiting_message=false;exec_xml('member',action,params,XE.displayPopupMenu,response_tags,params);show_waiting_message=true;return false})});var show_waiting_message=true
|
|
function xml2json(xml,tab,ignoreAttrib){var X={toObj:function(xml){var o={};if(xml.nodeType==1){if(ignoreAttrib&&xml.attributes.length)for(var i=0;i<xml.attributes.length;i++)o["@"+xml.attributes[i].nodeName]=(xml.attributes[i].nodeValue||"").toString();if(xml.firstChild){var textChild=0,cdataChild=0,hasElementChild=false;for(var n=xml.firstChild;n;n=n.nextSibling)if(n.nodeType==1){hasElementChild=true}else if(n.nodeType==3&&n.nodeValue.match(/[^ \f\n\r\t\v]/)){textChild++}else if(n.nodeType==4)cdataChild++;if(hasElementChild){if(textChild<2&&cdataChild<2){X.removeWhite(xml);for(var n=xml.firstChild;n;n=n.nextSibling)if(n.nodeType==3){o=X.escape(n.nodeValue)}else if(n.nodeType==4){o=X.escape(n.nodeValue)}else if(o[n.nodeName]){if(o[n.nodeName] instanceof Array){o[n.nodeName][o[n.nodeName].length]=X.toObj(n)}else o[n.nodeName]=[o[n.nodeName],X.toObj(n)]}else o[n.nodeName]=X.toObj(n)}else if(!xml.attributes.length){o=X.escape(X.innerXml(xml))}else o["#text"]=X.escape(X.innerXml(xml))}else if(textChild){if(!xml.attributes.length){o=X.escape(X.innerXml(xml))}else o["#text"]=X.escape(X.innerXml(xml))}else if(cdataChild)if(cdataChild>1){o=X.escape(X.innerXml(xml))}else for(var n=xml.firstChild;n;n=n.nextSibling)o=X.escape(n.nodeValue)};if(!xml.attributes.length&&!xml.firstChild)o=null}else if(xml.nodeType==9){o=X.toObj(xml.documentElement)}else alert("unhandled node type: "+xml.nodeType);return o},toJson:function(o,name,ind){var json=name?("\""+name+"\""):"";if(o instanceof Array){for(var i=0,n=o.length;i<n;i++)o[i]=X.toJson(o[i],"",ind+"\t");json+=(name?":[":"[")+(o.length>1?("\n"+ind+"\t"+o.join(",\n"+ind+"\t")+"\n"+ind):o.join(""))+"]"}else if(o==null){json+=(name&&":")+"null"}else if(typeof (o)=="object"){var arr=[];for(var m in o)arr[arr.length]=X.toJson(o[m],m,ind+"\t");json+=(name?":{":"{")+(arr.length>1?("\n"+ind+"\t"+arr.join(",\n"+ind+"\t")+"\n"+ind):arr.join(""))+"}"}else if(typeof (o)=="string"){json+=(name&&":")+"\""+o.toString()+"\""}else json+=(name&&":")+o.toString();return json},innerXml:function(node){var s="";if("innerHTML" in node){s=node.innerHTML}else{var asXml=function(n){var s="";if(n.nodeType==1){s+="<"+n.nodeName;for(var i=0;i<n.attributes.length;i++)s+=" "+n.attributes[i].nodeName+"=\""+(n.attributes[i].nodeValue||"").toString()+"\"";if(n.firstChild){s+=">";for(var c=n.firstChild;c;c=c.nextSibling)s+=asXml(c);s+="</"+n.nodeName+">"}else s+="/>"}else if(n.nodeType==3){s+=n.nodeValue}else if(n.nodeType==4)s+="<![CDATA["+n.nodeValue+"]]>";return s};for(var c=node.firstChild;c;c=c.nextSibling)s+=asXml(c)};return s},escape:function(txt){return txt.replace(/[\\]/g,"\\\\").replace(/[\"]/g,'\\"').replace(/[\n]/g,'\\n').replace(/[\r]/g,'\\r')},removeWhite:function(e){e.normalize();for(var n=e.firstChild;n;)if(n.nodeType==3){if(!n.nodeValue.match(/[^ \f\n\r\t\v]/)){var nxt=n.nextSibling;e.removeChild(n);n=nxt}else n=n.nextSibling}else if(n.nodeType==1){X.removeWhite(n);n=n.nextSibling}else n=n.nextSibling;return e}};if(xml.nodeType==9)xml=xml.documentElement;var json_obj=X.toObj(X.removeWhite(xml)),json_str;if(typeof (JSON)=='object'&&jQuery.isFunction(JSON.stringify)&&false){var obj={};obj[xml.nodeName]=json_obj;json_str=JSON.stringify(obj);return json_str}else{json_str=X.toJson(json_obj,xml.nodeName,"");return"{"+(tab?json_str.replace(/\t/g,tab):json_str.replace(/\t|\n/g,""))+"}"}};(function($){$.exec_xml=window.exec_xml=function(module,act,params,callback_func,response_tags,callback_func_arg,fo_obj){var xml_path=request_uri+"index.php";if(!params)params={};if($.isArray(params))params=arr2obj(params);params.module=module;params.act=act;if(typeof (xeVid)!='undefined')params.vid=xeVid;if(typeof (response_tags)=="undefined"||response_tags.length<1){response_tags=['error','message']}else response_tags.push('error','message');if($.isArray(ssl_actions)&¶ms.act&&$.inArray(params.act,ssl_actions)>=0){var url=default_url||request_uri,port=window.https_port||443,_ul=$('<a>').attr('href',url)[0],target='https://'+_ul.hostname.replace(/:\d+$/,'');if(port!=443)target+=':'+port;if(_ul.pathname[0]!='/')target+='/';target+=_ul.pathname;xml_path=target.replace(/\/$/,'')+'/index.php'};var _u1=$('<a>').attr('href',location.href)[0],_u2=$('<a>').attr('href',xml_path)[0];if(_u1.protocol!=_u2.protocol||_u1.port!=_u2.port)return send_by_form(xml_path,params);var xml=[],i=0;xml[i++]='<?xml version="1.0" encoding="utf-8" ?>';xml[i++]='<methodCall>';xml[i++]='<params>';$.each(params,function(key,val){xml[i++]='<'+key+'><![CDATA['+val+']]></'+key+'>'});xml[i++]='</params>';xml[i++]='</methodCall>';var _xhr=null;if(_xhr&&_xhr.readyState!=0)_xhr.abort()
|
|
function onsuccess(data,textStatus,xhr){var resp_xml=$(data).find('response')[0],resp_obj,txt='',ret=[],tags={},json_str='';waiting_obj.css('visibility','hidden');if(!resp_xml){alert(_xhr.responseText);return null};json_str=xml2json(resp_xml,false,false);resp_obj=(typeof (JSON)=='object'&&$.isFunction(JSON.parse))?JSON.parse(json_str):eval('('+json_str+')');resp_obj=resp_obj.response;if(typeof (resp_obj)=='undefined'){ret.error=-1;ret.message='Unexpected error occured.';try{if(typeof (txt=resp_xml.childNodes[0].firstChild.data)!='undefined')ret.message+='\r\n'+txt}catch(e){};return ret};$.each(response_tags,function(key,val){tags[val]=true});tags.redirect_url=true;tags.act=true;$.each(resp_obj,function(key,val){if(tags[key])ret[key]=val});if(ret.error!=0){if($.isFunction($.exec_xml.onerror))return $.exec_xml.onerror(module,act,ret,callback_func,response_tags,callback_func_arg,fo_obj);alert(ret.message||'error!');return null};if(ret.redirect_url){location.href=ret.redirect_url.replace(/&/g,'&');return null};if($.isFunction(callback_func))callback_func(ret,response_tags,callback_func_arg,fo_obj)};try{$.ajax({url:xml_path,type:'POST',dataType:'xml',data:xml.join('\n'),contentType:'text/plain',beforeSend:function(xhr){_xhr=xhr},success:onsuccess,error:function(xhr,textStatus){waiting_obj.css('visibility','hidden');var msg='';if(textStatus=='parsererror'){msg='The result is not valid XML :\n-------------------------------------\n';if(xhr.responseText=="")return;msg+=xhr.responseText.replace(/<[^>]+>/g,'')}else msg=textStatus;alert(msg)}})}catch(e){alert(e);return};var waiting_obj=$('#waitingforserverresponse');if(show_waiting_message&&waiting_obj.length){var d=$(document);waiting_obj.html(waiting_message).css({top:(d.scrollTop()+20)+'px',left:(d.scrollLeft()+20)+'px',visibility:'visible'})}}
|
|
function send_by_form(url,params){var frame_id='xeTmpIframe',form_id='xeVirtualForm';if(!$('#'+frame_id).length)$('<iframe name="%id%" id="%id%" style="position:absolute;left:-1px;top:1px;width:1px;height:1px"></iframe>'.replace(/%id%/g,frame_id)).appendTo(document.body);$('#'+form_id).remove();var form=$('<form id="%id%"></form>'.replace(/%id%/g,form_id)).attr({id:form_id,method:'post',action:url,target:frame_id});params.xeVirtualRequestMethod='xml';params.xeRequestURI=location.href.replace(/#(.*)$/i,'');params.xeVirtualRequestUrl=request_uri;$.each(params,function(key,value){$('<input type="hidden">').attr('name',key).attr('value',value).appendTo(form)});form.appendTo(document.body).submit()}
|
|
function arr2obj(arr){var ret={};for(var key in arr)if(arr.hasOwnProperty(key))ret[key]=arr[key];return ret};$.exec_json=function(action,data,func){if(typeof (data)=='undefined')data={};action=action.split(".");if(action.length==2){if(show_waiting_message)$("#waitingforserverresponse").html(waiting_message).css('top',$(document).scrollTop()+20).css('left',$(document).scrollLeft()+20).css('visibility','visible');$.extend(data,{module:action[0],act:action[1]});if(typeof (xeVid)!='undefined')$.extend(data,{vid:xeVid});$.ajax({type:"POST",dataType:"json",url:request_uri,contentType:"application/json",data:$.param(data),success:function(data){$("#waitingforserverresponse").css('visibility','hidden');if(data.error>0)alert(data.message);if($.isFunction(func))func(data)}})}};$.fn.exec_html=function(action,data,type,func,args){if(typeof (data)=='undefined')data={};if(!$.inArray(type,['html','append','prepend']))type='html';var self=$(this);action=action.split(".");if(action.length==2){if(show_waiting_message)$("#waitingforserverresponse").html(waiting_message).css('top',$(document).scrollTop()+20).css('left',$(document).scrollLeft()+20).css('visibility','visible');$.extend(data,{module:action[0],act:action[1]});$.ajax({type:"POST",dataType:"html",url:request_uri,data:$.param(data),success:function(html){$("#waitingforserverresponse").css('visibility','hidden');self[type](html);if($.isFunction(func))func(args)}})}}})(jQuery);(function($){var messages=[],rules=[],filters=[],callbacks=[],extras={},Validator=xe.createApp('Validator',{init:function(){var regEmail=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;this.cast('ADD_RULE',['email',regEmail]);this.cast('ADD_RULE',['email_address',regEmail]);var regUserid=/^[a-z]+[\w-]*[a-z0-9_]+$/i;this.cast('ADD_RULE',['userid',regUserid]);this.cast('ADD_RULE',['user_id',regUserid]);var regUrl=/^(https?|ftp|mms):\/\/[0-9a-z-]+(\.[_0-9a-z-\/\~]+)+(:[0-9]{2,4})*$/;this.cast('ADD_RULE',['url',regUrl]);this.cast('ADD_RULE',['homepage',regUrl]);var regKor=/^[가-힣]*$/;this.cast('ADD_RULE',['korean',regKor]);var regKorNum=/^[가-힣0-9]*$/;this.cast('ADD_RULE',['korean_number',regKorNum]);var regAlpha=/^[a-z]*$/i;this.cast('ADD_RULE',['alpha',regAlpha]);var regAlphaNum=/^[a-z][a-z0-9_]*$/i;this.cast('ADD_RULE',['alpha_number',regAlphaNum]);var regNum=/^[0-9]*$/;this.cast('ADD_RULE',['number',regNum])},run:function(oForm){var filter='';if(oForm._filter)filter=oForm._filter.value;var params=[oForm,filter],result=this.cast('VALIDATE',params);if(typeof result=='undefined')result=false;return result},API_ONREADY:function(){var self=this;$('form').each(function(){if(this.onsubmit){this['xe:onsubmit']=this.onsubmit;this.onsubmit=null}}).submit(function(){var legacyFn=this['xe:onsubmit'],hasLegacyFn=$.isFunction(legacyFn),bResult=hasLegacyFn?legacyFn.apply(this):self.run(this);return bResult})},API_VALIDATE:function(sender,params){var self=this,result=true,form=params[0],filter=null,callback=null;if(form.elements['_filter'])filter=form.elements['_filter'].value;if(!filter)return true;if($.isFunction(callbacks[filter]))callback=callbacks[filter];filter=$.extend({},filters[filter.toLowerCase()]||{},extras);$.each(filter,function(name){var _el=form.elements[name];if(!_el)return true;var el=$(_el),val=$.trim(get_value(el)),minlen=parseInt(this.minlength)||0,maxlen=parseInt(this.maxlength)||0,rule=(this.rule||'').split(',');if(this.required&&!val)return(result=(!!self.cast('ALERT',[form,name,'isnull'])&&false));if(!this.required&&!val)return(result=true);if((minlen&&val.length<minlen)||(maxlen&&val.length>maxlen))return(result=(!!self.cast('ALERT',[form,name,'outofrange',minlen,maxlen])&&false));if(this.equalto){var eq_val=get_value($(form.elements[this.equalto]));if(eq_val!=val)return(result=(!!self.cast('ALERT',[form,name,'equalto'])&&false))};if(rule)$.each(rule,function(i,r){if(!r)return true;var ret=self.cast('APPLY_RULE',[r,val]);if(!ret){self.cast('ALERT',[form,name,'invalid_'+this]);return(result=false)}});if(!result)return false});if(!result)return false;if($.isFunction(callback))return callback(form);return true},API_ADD_RULE:function(sender,params){var name=params[0].toLowerCase();rules[name]=params[1]},API_DEL_RULE:function(sender,params){var name=params[0].toLowerCase();delete rules[name]},API_GET_RULE:function(sender,params){var name=params[0].toLowerCase();if(rules[name]){return rules[name]}else return null},API_ADD_FILTER:function(sender,params){var name=params[0].toLowerCase(),filter=params[1];filters[name]=filter},API_DEL_FILTER:function(sender,params){var name=params[0].toLowerCase();delete filters[name]},API_GET_FILTER:function(sender,params){var name=params[0].toLowerCase();if(filters[name]){return filters[name]}else return null},API_ADD_EXTRA_FIELD:function(sender,params){var name=params[0].toLowerCase(),prop=params[1];extras[name]=prop},API_GET_EXTRA_FIELD:function(sender,params){var name=params[0].toLowerCase();return extras[name]},API_DEL_EXTRA_FIELD:function(sender,params){var name=params[0].toLowerCase();delete extras[name]},API_APPLY_RULE:function(sender,params){var name=params[0],value=params[1];if(typeof (rules[name])=='undefined')return true;if($.isFunction(rules[name]))return rules[name](value);if(rules[name] instanceof RegExp)return rules[name].test(value);return true},API_ALERT:function(sender,params){var form=params[0],field_name=params[1],msg_code=params[2],minlen=params[3],maxlen=params[4],field_msg=this.cast('GET_MESSAGE',[field_name]),msg=this.cast('GET_MESSAGE',[msg_code]);if(msg!=msg_code)msg=(msg.indexOf('%s')<0)?(field_msg+msg):(msg.replace('%s',field_msg));if(minlen||maxlen)msg+='('+(minlen||'')+'~'+(maxlen||'')+')';this.cast('SHOW_ALERT',[msg]);$(form.elements[field_name]).focus()},API_SHOW_ALERT:function(sender,params){alert(params[0])},API_ADD_MESSAGE:function(sender,params){var msg_code=params[0],msg_str=params[1];messages[msg_code]=msg_str},API_GET_MESSAGE:function(sender,params){var msg_code=params[0];return messages[msg_code]||msg_code},API_ADD_CALLBACK:function(sender,params){var name=params[0],func=params[1];callbacks[name]=func},API_REMOVE_CALLBACK:function(sender,params){var name=params[0];delete callbacks[name]}}),oValidator=new Validator();xe.registerApp(oValidator);var EditorStub=xe.createPlugin('editor_stub',{API_BEFORE_VALIDATE:function(sender,params){var form=params[0],seq=form.getAttribute('editor_sequence');if(seq&&typeof seq=='object')seq=seq.value;if(seq)try{editorRelKeys[seq].content.value=editorRelKeys[seq].func(seq)||''}catch(e){}}});oValidator.registerPlugin(new EditorStub())
|
|
function get_value(elem){var vals=[];if(elem.is(':radio')){return elem.filter(':checked').val()}else if(elem.is(':checkbox')){elem.filter(':checked').each(function(){vals.push(this.value)});return vals.join('|@|')}else return elem.val()}})(jQuery)
|
|
function filterAlertMessage(ret_obj){var error=ret_obj.error,message=ret_obj.message,act=ret_obj.act,redirect_url=ret_obj.redirect_url,url=location.href;if(typeof (message)!="undefined"&&message&&message!="success")alert(message);if(typeof (act)!="undefined"&&act){url=current_url.setQuery("act",act)}else if(typeof (redirect_url)!="undefined"&&redirect_url)url=redirect_url;if(url==location.href)url=url.replace(/#(.*)$/,'');location.href=url}
|
|
function procFilter(form,filter_func){filter_func(form);return false}
|
|
function legacy_filter(filter_name,form,module,act,callback,responses,confirm_msg,rename_params){var v=xe.getApp('Validator')[0],$=jQuery,args=[];if(!v)return false;if(!form.elements['_filter'])$(form).prepend('<input type="hidden" name="_filter" />');form.elements['_filter'].value=filter_name;args[0]=filter_name;args[1]=function(f){var params={},res=[],elms=f.elements,data=$(f).serializeArray();$.each(data,function(i,field){var v=$.trim(field.value),n=field.name;if(!v||!n)return true;if(rename_params[n])n=rename_params[n];if(/\[\]$/.test(n))n=n.replace(/\[\]$/,'');if(params[n]){params[n]+='|@|'+v}else params[n]=field.value});if(confirm_msg&&!confirm(confirm_msg))return false;exec_xml(module,act,params,callback,responses,params,form)};v.cast('ADD_CALLBACK',args);v.cast('VALIDATE',[form,filter_name]);return false} |