📄 main.js
字号:
var X={
go:function(action,options){
if(window.event)Event.stop(window.event);
this.options ={
autotab:false,
params:{},
toMask:''
};
Object.extend(this.options, options || {});
X.mask(this.options.toMask);
if(action.getAttribute){
X.toObj(action);
return;
}
if(this.options.autotab){
this.options.target = this.options.target?this.options.target:action.ctl+':'+action.act;
}else{
this.options.target = this.options.target?this.options.target:X.runtime.currentTab;
}
if(this.options.target!='__BG__' && this.options.target!='__F_WIN__'){
var e = X.tab.$(this.options.target);
if(!e){
e = X.tab.create(this.options.target);
}
X.tab.fg(this.options.target);
}
if(typeof(action)=='string'){
X.ajax(X.url(action,this.options),this.options);
}else{
if(!action.pkg)delete(action.pkg);
p_arg='';
if(action.p){
action.p.each(
function(v,k){
p_arg+='&p['+k+']='+encodeURIComponent(v);
}
)
delete(action.p);
}
X.ajax(X.url($H(action).toQueryString()+p_arg,this.options),this.options);
}
},
ui:{
button:function(label){
Builder.node('b',{className:'button',onclick:'cform.submit(this)'},[
Builder.node('label',{},label)
]);
}
},
toObj:function(obj){
o = {ctl:obj.getAttribute('ctl'),act:obj.getAttribute('act')};
if(obj.getAttribute('pkg')!=='null'){
o.pkg = obj.getAttribute('pkg');
}
t = obj.getAttribute('tab');
t = (t && t!=='null')?t:obj.getAttribute('ctl')+':'+obj.getAttribute('act');
if(X.currentTab=='cpanel')
X.tab.ren('cpanel',t)
X.go(o,{target:t});
},
ajax:function(pars, options){
var myAjax = new Ajax.Request(
'core.php',
{method:'get',parameters: pars,onSuccess: X.callback,onFailure:X.error,onException:X.dbg.ajaxError}
)
},
error:function(a,k){
X.messager.show({string:__("Service not Availabel!!"),type:X.messager.code.error});
},
notAuth:function(priName){
X.messager.show({string:(priName?'['+priName+'] ':'')+__('Not Auth'),type:X.messager.code.error});
},
url:function(s,options){
var _options={
target:X.runtime.currentTab,
reqType:1,
page_id:(X.tab.$(X.runtime.currentTab).body?X.tab.$(X.runtime.currentTab).body.getAttribute('page-id'):null),
params:{}
}
Object.extend(_options, options || {});
s += '&_lang='+Setting.lang;
s+='&_='+_options.reqType+'&tab=' + _options.target;
if($('_debugger'))s+='&_debugger=1';
if(_options.page_id)s+='&_page_id='+_options.page_id;
return s+'&'+$H(_options.params).toQueryString();
},
runtime:{
tabidx:0,
currentTab:'dashboard',
js:{},
fseq:0
},
compact:{
obj:function(obj){
if(window.event)Event.stop(window.event);
X.compact.go(obj.getAttribute('href'),obj.getAttribute('target'),obj.innerHTML);
return false;
},
go:function(url,target,label){
if(target!=='__INPAGE__'){
window.open(url,target);
return;
}
var e = X.tab.$('compact');
if(!e){
e = X.tab.create('compact');
}
X.tab.setLabel('compact',(label||__('compact')));
e.body.innerHTML='';
e.body.appendChild(Builder.node('iframe',{border:0,frameborder:"no",allowtransparency:"true",framespacing:0,style:'margin-top:22px;width:100%;border:none;',onload:'X.compact.resize(this)',onresize:'X.compact.resize(this)',src:url}));
X.tab.fg('compact');
},
resize:function(obj){
try{
if(obj.contentDocument){
obj.style.height = obj.contentDocument.body.offsetHeight+30+'px';
}else{
obj.style.height = obj.contentWindow.document.body.scrollHeight+10+'px';
}
}catch(e){;}
}
},
wget:{
go:function(url,options){
_options = {
onSuccess:function(){},
onFailure:function(){}
};
Object.extend(_options, options || {});
X.wget.instances[X.wget.seq] = _options;
_options.base = Builder.node('script',{type:'text/javascript',src:url+(url.indexOf('?')>0?'&':'?')+'_CALL_ID_='+X.wget.seq});
document.body.appendChild(_options.base);
X.wget.seq++;
},
callback:function(data,i){
X.wget.instances[i].onSuccess(data,X.wget.instances[i]);
removeElement(X.wget.instances[i].base);
delete(X.wget.instances[i]);
},
seq:0,
instances:[]
},
form:{
onsubmit:function(e){
f = Event.findElement(e,'form');
Event.stop(e);
X.form.submit(f);
},
onValidate:function(r,f){
if(r){
X.form.submit(f,true);
}
},
submit:function(f,validated){
if(validated){
// o = f.getElementsByClassName('button')
// o[0].removeAttribute('onclick');
// o[0].className = 'buttondisabled';
Editor.triggerSave(f);
var method = f.getAttribute('method');
method = method?method:'post';
e = f.getElementsByTagName('input');
for(i=0;i<e.length;i++){
if('file' == e[i].type){
if(!$('_F_POST_'+X.runtime.fseq)){
document.body.appendChild(
Builder.node('iframe',{id:'_F_POST_'+X.runtime.fseq,name:'_F_POST_'+X.runtime.fseq,style:'display:none',onload:'X.fload(this)'})
);
}
f.action = X.url(f.action,{reqType:2});
f.method = 'post';
f.enctype='multipart/form-data';
f.target = '_F_POST_'+X.runtime.fseq;
f.submit();
return;
}
}
var myAjax = new Ajax.Request(
X.url(f.getAttribute('action')),
{'method': f.getAttribute('method'),parameters: Form.serialize(f)+'&_',onSuccess: X.callback}
);
}else{
new Validation(f,{immediate : true, onFormValidate : X.form.onValidate}).validate();
}
}
}
,
fload:function(obj){
if(obj.contentDocument){
X.callback({responseText:obj.contentDocument.documentElement.textContent},{code:200});
}else{
X.callback({responseText:obj.contentWindow.document.body.innerText},{code:200});
}
},
siderMenu:{
toggle:function(handle){
e = handle.parentNode.getElementsByTagName('UL')[0];
if(e){
if(e.style.display==''){
handle.className='close';
e.style.display='none';
}else{
handle.className='open';
e.style.display='';
}
}
}
},
messager:{
alert:function(msg,msgid){
$('messager').className='alert';
X.messager.exec(msg,msgid,7000);
},
show:function(msg,msgid){
switch(msg.type){
case X.messager.code.error:
$('messager').className='error';
break;
case X.messager.code.warning:
$('messager').className='warning';
break;
default:
break;
}
$('messager').innerHTML ='';
$('messager').appendChild(
Builder.node('span',{},[
msg.string,
// Builder.node('span',{className:'link',onclick:'X.messager.close('+msgid+')'},['[x]'])
])
);
if(msg.links){
for(label in msg.links){
if(typeof(msg.links[label])=='string'){
$('messager').appendChild(
Builder.node('a',{className:'link',target:'_blank',href:msg.links[label]},label)
)
}else{
$('messager').appendChild(
Builder.node('span',{className:'link',link:$H(msg.links[label]).toQueryString(),onclick:"X.go(this.getAttribute('link'))"},label)
)
}
}
}
$('messager').style.left = ($('workground').offsetWidth - $('messager').offsetWidth )/2+200 +'px';
$('messager').style.visibility = '';
X.runtime.lastMsgId = msgid;
Event.observe(window, 'scroll', this.position, false);
/* if ($('messageListOutPut')) {
d = new Date();
dt = d.getFullYear() + '/' + (d.getMonth()+1) + '/' + d.getDate() + ' ' + d.getHours()+':' + d.getMinutes() + ':' + d.getSeconds();
div = Builder.node('div', {style:'clear:both;'}, [
Builder.node('li', {}, [msg.string,dt])
]);
$('messageListOutPut').appendChild(div);
if ($('messageListOutPut').childNodes.length > 20) {
removeElement($('messageListOutPut').firstChild);
}
}*/
setTimeout('X.messager.close('+msgid+')',5000);
},
position : function() {
if(document.documentElement && document.documentElement.scrollTop) {
$('messager').style.top = document.documentElement.scrollTop+'px';
} else if (document.body) {
$('messager').style.top = document.body.scrollTop+'px';
}
},
close:function(msgid){
if(msgid==X.runtime.lastMsgId){
$('messager').style.visibility='hidden';
}
},
code:{ok:0,warning:1,error:2}
},
callback:function(ret,json){
if(json && json.code!='200'){
X.messager.show({string:__('System error: code ') +' <a href="#" target="_blank">'+json.code+'</a>',type:X.messager.code.error},json.id);
return;
}
try{
jsonObj = eval('('+ret.responseText+')');
}catch(err){
X.messager.show({string:__('Parse error: Wrong response!'),type:X.messager.code.error},json?json.id:Math.random());
X.dbg.show(err.description||err.message);
X.dbg.append('<hr />');
X.dbg.append('<div style="height:300px;overflow:scroll;border:1px solid #ccc;padding:10px">'+ret.responseText+'</div>');
X.dbg.onError(err);
return ;
}
try{
if(jsonObj.debug)X.dbg.show(jsonObj.debug.output);
if(jsonObj.message){
X.messager.show(jsonObj.message,json.id);
}
if(jsonObj.tab){
if(jsonObj.tab=='__BG__'){
e={};
}else if(jsonObj.tab=='__F_WIN__'){
e={body:fbox.content}
}else{
e = X.tab.$(jsonObj.tab);
if(!e){
e = X.tab.create(jsonObj.tab);
}
}
if(jsonObj.tab!='__BG__' && jsonObj.tab!='__F_WIN__'){
if(jsonObj.title){
X.tab.setLabel(jsonObj.tab,jsonObj.title);
}else if(jsonObj.body){
X.tab.setLabel(jsonObj.tab,__('No Named'));
}
}
if(jsonObj.body || jsonObj.tabs){
$('history').contentWindow.location="blank.html?"+jsonObj.tab;
if(json.id)
e.body.setAttribute('page-id',json.id);
e.body.innerHTML='';
var h = Builder.node('div',{},[
Builder.node('span',{className:'link closeBtn',title:__('Close this tab'),onclick:'X.tab.close(X.runtime.currentTab)'},__('Close this tab'))
]);
var b = Builder.node('div',{className:'toolbar'});
if(CR && Helper.shopEx){
uri = 'ctl='+jsonObj._get.ctl+'&act='+jsonObj._get.act;
if(jsonObj._get.pkg)
uri += '&pkg='+jsonObj._get.pkg;
h.insertBefore(
Builder.node('a',{className:'helpLnk',target:'_blank',href:Helper.shopEx.lnk+uri,title:__('Find bug and submit to shopex bbs.')},__('Find Bug?'))
,h.firstChild);
}
if(jsonObj.toReturn){
var s=[];
for(var i in jsonObj.toReturn){
s.push(i+':\''+jsonObj.toReturn[i]+"'");
}
h.insertBefore(
Builder.node('span',{className:'link toReturn',title:__('Return to list'),onclick:'X.go({'+s.join(',')+'})'},jsonObj.toReturn.label?jsonObj.toReturn.label:__('Return')),h.firstChild);
delete(s);
}
if(!jsonObj.noHeader){
if(jsonObj.headerHtml)h.innerHTML = jsonObj.headerHtml;
if (jsonObj.desc) {
var desc = Builder.node('p',{className:'desc'})
desc.innerHTML = jsonObj.desc;
} else {
var desc = '';
}
e.body.appendChild(Builder.node('div',{className:'c-header'},[
desc,
Builder.node('div',{className:'block'},[h,b])
]));
delete desc;
}
c = Builder.node('div',{className:'content'});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -