📄 box.js
字号:
var _box=[];var _boxFocus=null;var _boxTab={ table: ['Fields', 'Indices', 'Triggers', 'Dependencies', 'Data', 'DDL'], view: ['Fields', 'Triggers', 'Dependencies', 'Data', 'DDL'], index: ['Index', 'Dependencies', 'DDL'], trigger:['Script', 'Dependencies', 'DDL'], query: ['SQL', 'Explain', 'Result']};var _boxSkel=null;function boxInit() { addEvent(document, 'mousemove', boxMoveSwitch); /* _boxSkel init */ _boxSkel=document.createElement('DIV'); _boxSkel.className='box'; _boxSkel.id="box"; _boxSkel.innerHTML='\<table class="full">\<tr>\ <td style="height:29px">\ <table class="full">\ <tr>\ <td style="width:27px;height:29px;background-image:url(img/box_lt.gif);background-repeat:no-repeat;vertical-align:middle"><img style="width:21px;height:21px;margin:0px 3px" /></td>\ <td id="box_title"></td>\ <td style="width:27px;height:29px"><a href="javascript:;" onclick="boxHide(this)"><img src="img/box_rt.gif" border="0"></a></td>\ </tr>\ </table>\ </td>\</tr>\<tr>\ <td style="width:100%;height:100%;background-color:white;border-left:1px solid white;border-right:1px solid white;">\ <table class="full" id="box_body" style="table-layout:fixed;border-left:4px solid #686868;border-right:4px solid #686868;height:100%;">\ <tr>\ <td style="padding:0px 3px 5px 3px;"></td>\ </tr>\ <tr>\ <td style="width:100%;height:100%;border:1px solid #C0C0C0;"></td>\ </tr>\ <tr>\ <td class="box_tab_menu"></td>\ </tr>\ </table>\ </td>\</tr>\<tr>\ <td>\ <table class="full">\ <tr>\ <td style="width:9px;height:9px;background-image:url(img/box_lb.gif);background-repeat:no-repeat;"><img style="width:9px;height:1px"></td>\ <td style="width:100%;height:9px;background-color:white;border-bottom:1px solid white;vertical-align:bottom"><img style="width:100%;height:4px;background-color:#686868;border:none;"></td>\ <td id="resizer" onselectstart="return false;" style="width:9px;height:9px;background-image:url(img/box_rb.gif);background-repeat:no-repeat;cursor:se-resize;-moz-user-select:none;"><img style="width:9px;height:1px"></td>\ </tr>\ </table>\ </td>\</tr>\</table>';}function box(data) { this.data=data; this.title=(data && data.name)?data.name:'New'; this.type=(data && data.type)?data.type:'query'; this.outer=null; this.div=null; this.icon=null; this.divTitle=null; this.divResizer=null; this.redraw=false; this.tab={}; this.selectedTab=''; this.divTab=null; this.divTabBody=null; this.divTabMenu=null; this.db=null; this.grid=null; this.gridDataset=null; this.fields=[]; this.lastSQL=''; this.initDataset=function() { if (!this.grid) this.grid=new boxGrid(); if (!this.gridDataset) this.gridDataset=this.grid.initDataset(this); };}box.prototype.draw = function() { if (!_boxSkel) return; this.outer=_boxSkel.cloneNode(true); this.outer.box=this; _inspector['canvas'].appendChild(this.outer); var table=this.outer.firstChild; if (!table) return; this.div=table.rows[1].cells[0]; this.icon=oFindChildByTagName(table.rows[0].cells[0], 'IMG'); if (this.icon) this.icon.src='img/box_icon_'+this.type+'.gif'; this.divTitle=oFindChild(table.rows[0].cells[0], 'TD', 'box_title'); if (this.divTitle) { innerText(this.divTitle, this.title); addEvent(this.divTitle, 'mousedown', boxMoveStart); } var tab=oFindChild(table.rows[1].cells[0], 'TABLE', 'box_body'); this.divTab=tab.rows[0].cells[0]; this.divTabBody=tab.rows[1].cells[0]; this.divTabMenu=tab.rows[2].cells[0]; this.divResizer=oFindChild(table.rows[2].cells[0], 'TD', 'resizer'); if (this.divResizer) addEvent(this.divResizer, 'mousedown', boxResizeStart); with (this.outer.style) { height='300px'; width='450px'; top=(_box.length%15)*20; left=((_box.length%15)*20)+(Math.floor(_box.length/15)*150); zIndex=1001; } addEvent(this.outer, 'click', boxClickFocus); if (_boxTab[this.type]) { for (var i=0; i < _boxTab[this.type].length; i++) { if (i != 0) { var sep=appendNew(this.divTab, 'SPAN'); sep.className='box_tab_sep'; sep.innerHTML='|'; } var link=appendNew(this.divTab, 'A'); link.className='box_tab'; link.onclick=new Function('boxTabSelect(this, "'+_boxTab[this.type][i]+'")'); link.innerHTML=_boxTab[this.type][i]; var tabBody=appendNew(this.divTabBody, 'DIV'); tabBody.className='tab_body'; if (_boxTab[this.type][i] == 'DDL') addEvent(tabBody, 'selectstart', _eventBubble); this.tab[_boxTab[this.type][i]]=tabBody; } } boxTabSelect(this.divTab.firstChild, _boxTab[this.type][0]); /* if (this.type == 'query') { this.db=new dbConn('', boxResponse, boxErrResponse); this.db.setBox(this); this.db.persistent=true; } */};function boxTabSelect(link, tab) { if (!link) return; var div=oFindParentById(link, 'box'); if (!div) return; var mdi=div.box; for (var i=mdi.divTab.childNodes.length; i--;) { if (mdi.divTab.childNodes[i].className == 'box_tab_select') mdi.divTab.childNodes[i].className='box_tab'; } link.className='box_tab_select'; for (var key in mdi.tab) { if (key == tab) { mdi.tab[key].style.display='block'; }else mdi.tab[key].style.display='none'; } mdi.selectedTab=tab; boxTabProc(mdi);}var _boxModeBox=null;var _boxModeBoxMode='';var _boxModeBoxDiv=null;var _boxModeBoxPos={x:0, y:0};function boxMoveSwitch(e) { if (!e || !_boxModeBoxDiv) return; switch (_boxModeBoxMode) { case 'move': boxMove(e); break; case 'resize': boxResize(e); break; }}function boxMoveStart(e) { if (!e) return; var eventSrc=(_isIE)?e.srcElement:e.target; var div=oFindParentById(eventSrc, 'box'); if (!div) return; var mdi=div.box; //addEvent(document, 'mousemove', boxMove); addEvent(document, 'mouseup', boxMoveEnd); //addEvent(document, 'selectstart', _eventCancel); _boxModeBoxPos.y=e.clientY-lY(div); _boxModeBoxPos.x=e.clientX-lX(div); _boxModeBoxDiv=div; _boxModeBoxMode='move'; /* if (_isIE) { _boxModeBoxDiv.style.border='1px dashed gray'; _boxModeBoxDiv.firstChild.style.visibility='hidden'; } */ _boxModeBox=mdi;} function boxMove(e) { _boxModeBoxDiv.style.top=Math.max(0, e.clientY-_boxModeBoxPos.y-lY(_inspector['canvas'])); _boxModeBoxDiv.style.left=Math.max(0, e.clientX-_boxModeBoxPos.x-lX(_inspector['canvas'])); } function boxMoveEnd() { /* if (_boxModeBoxDiv && _isIE) { _boxModeBoxDiv.style.border=''; _boxModeBoxDiv.firstChild.style.visibility='visible'; } */ _boxModeBoxMode=''; _boxModeBox=null; _boxModeBoxDiv=null; //removeEvent(document, 'mousemove', boxMove); //removeEvent(document, 'mousemove', boxResize); removeEvent(document, 'mouseup', boxMoveEnd); //removeEvent(document, 'selectstart', _eventCancel); }function boxResizeStart(e) { if (!e) return; var eventSrc=(_isIE)?e.srcElement:e.target; var div=oFindParentById(eventSrc, 'box'); if (!div) return; var mdi=div.box; //addEvent(document, 'mousemove', boxResize); addEvent(document, 'mouseup', boxMoveEnd); //addEvent(document, 'selectstart', _eventCancel); _boxModeBoxPos.y=lY(div); _boxModeBoxPos.x=lX(div); _boxModeBoxDiv=div; _boxModeBoxMode='resize'; /* if (_isIE) { _boxModeBoxDiv.style.border='1px dashed gray'; _boxModeBoxDiv.firstChild.style.visibility='hidden'; } */ _boxModeBox=mdi;} function boxResize(e) { _boxModeBoxDiv.style.height=Math.max(1, e.clientY-_boxModeBoxPos.y); _boxModeBoxDiv.style.width=Math.max(1, e.clientX-_boxModeBoxPos.x); }var _boxShowFocus=null;function boxShow(data) { if (!data || !data.type || !data.name) return; if (data.type != 'query') { for (var i=_box.length; i--;) { if (_box[i].type == data.type && _box[i].title == data.name) { _box[i].outer.style.display=''; _boxShowFocus=_box[i]; setTimeout('boxFocus(_boxShowFocus)', 10); return; } } } var mdi=new box(data); mdi.draw(); _box.push(mdi); _boxShowFocus=mdi; setTimeout('boxFocus(_boxShowFocus)', 10); if (data.type == 'query' && data.sql) _dbShowSQL_FFBug=data.sql;}function boxClickFocus(e) { if (!e) return; var eventSrc=(_isIE)?e.srcElement:e.target; var div=oFindParentById(eventSrc, 'box'); if (!div) return; boxFocus(div.box);}function boxFocus(mdi) { if (!mdi || _boxFocus == mdi) return; var maxZIndex=0; if (_boxFocus) maxZIndex=_boxFocus.outer.style.zIndex; else{ for (var i=_box.length; i--;) maxZIndex=Math.max(maxZIndex, _box[i].outer.style.zIndex); } if (_isIE) mdi.outer.firstChild.style.visibility='hidden'; mdi.outer.style.zIndex=(parseInt(maxZIndex)+1); if (_isIE) mdi.outer.firstChild.style.visibility='visible'; _boxFocus=mdi;}function boxSync(type) { for (var i=_box.length; i--;) { if (_box[i].type == type) { _box[i].outer.parentNode.removeChild(_box[i].outer); _box.splice(i, 1); break; } }}function boxHide(link) { var div=oFindParentById(link, 'box'); if (!div) return; div.style.display='none'; if (div.box && div.box.type == 'query') { //div.box.db.con.abort(); //delete div.box.db; for (var i=_box.length; i--;) { if (_box[i] == div.box) { _box.splice(i, 1); break; } } div.parentNode.removeChild(div); }}function boxTabProc(mdi) { if (!mdi) return; var data=mdi.data; if (!data) return; var type=data.type; var name=data.name; var div=mdi.tab[mdi.selectedTab]; if (!div) return; switch (mdi.selectedTab) { case 'Fields': if (type == 'table' || type == 'view') { if (div.childNodes.length <= 0) boxDbExec(mdi, 'desc '+name); } break; case 'Indices': boxTabIndex(mdi, name); break; case 'Triggers': boxTabTrigger(mdi, name); break; case 'Dependencies': boxTabDepend(mdi, name); break; case 'Data': if (type == 'table' || type == 'view') mdi.initDataset(); break; case 'DDL': boxTabDDL(mdi, inspectorGetDDL(data)); break; case 'Script': boxTabScript(mdi, data.ddl); break; case 'Index': boxTabIndexDesc(mdi); /* if (div.childNodes.length <= 0) boxDbExec(mdi, 'desc '+data.table); */ break; case 'SQL': boxTabSQL(mdi); break; case 'Explain': var tab=mdi.tab['SQL']; if (!tab || !tab.firstChild || tab.firstChild.tagName != 'IFRAME') return; var sql=innerText(tab.firstChild.contentWindow.document.body); syntaxSQL(tab.firstChild.contentWindow.document.body); if (sql) boxDbExec(mdi, 'EXPLAIN '+(sql.replace(/^\s*EXPLAIN\s+/i, '')), 'execute'); break; case 'Result': if (div.childNodes.length <= 0) { var tab=mdi.tab['SQL']; if (!tab || !tab.firstChild || tab.firstChild.tagName != 'IFRAME') return; var sql=innerText(tab.firstChild.contentWindow.document.body); syntaxSQL(tab.firstChild.contentWindow.document.body); if (sql && mdi.lastSQL != sql) boxDbExec(mdi, sql, 'execute'); } break; } boxTabMenuProc(mdi, type, mdi.selectedTab);}loadJs('boxTab.js');loadJs('boxTabMenu.js');loadJs('boxRequest.js');loadJs('boxGrid.js');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -