Google Maps API 2.0解析(16-GLog进行输出和调试的类)

        这是API2.0的新类,这次2.0对开发过程进行了许多优化,这个是其中一个功能。
None.gif        //实际就是GLog类的底层实现
None.gif
        function GLogBase()
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            
var a=CreateElement("div",document.body);
InBlock.gif            
var b=a.style;
InBlock.gif            b.position
="absolute";
InBlock.gif            b.left
=GetPixelValue(7);
InBlock.gif            b.bottom
=GetPixelValue(4);
InBlock.gif            b.zIndex
=10000;
InBlock.gif            
var c=CreateLogDiv(a,new GPoint(2,2));
InBlock.gif            
var d=CreateElement("div",a);
InBlock.gif            b
=d.style;
InBlock.gif            b.position
="relative";
InBlock.gif            b.zIndex
=1;
InBlock.gif            b.fontFamily
="VerdaGEvent_moveend,Arial,sans-serif";
InBlock.gif            b.fontSize
="small";
InBlock.gif            b.border
="1px solid black";
InBlock.gif            
var e=[["Clear",this.clear],["Close",this.close]];//定义按钮名称和点击事件
InBlock.gif
            var f=CreateElement("div",d);
InBlock.gif            b
=f.style;
InBlock.gif            b.position
="relative";
InBlock.gif            b.zIndex
=2;
InBlock.gif            b.backgroundColor
="#979797";
InBlock.gif            b.color
="white";
InBlock.gif            b.fontSize
="85%";
InBlock.gif            b.padding
=GetPixelValue(2);
InBlock.gif            setCursor(f,
"default");
InBlock.gif            SetUnSelectable(f);
InBlock.gif            CreateTextNode(
"Log",f);
InBlock.gif            
for(var g=0;g<e.length;g++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
var h=e[g];
InBlock.gif                CreateTextNode(
" - ",f);
InBlock.gif                
var i=CreateElement("span",f);
InBlock.gif                i.style.textDecoration
="underline";
InBlock.gif                CreateTextNode(h[
0],i);//按钮名称
InBlock.gif
                bindClick(i,this,h[1]);//按钮事件
InBlock.gif
                setCursor(i,"pointer")
ExpandedSubBlockEnd.gif            }

InBlock.gif            bindDom(f,GEvent_mousedown,
this,this.onMouseDown);
InBlock.gif            
var l=CreateElement("div",d);
InBlock.gif            b
=l.style;
InBlock.gif            b.backgroundColor
="white";
InBlock.gif            b.width
=GetEMValue(24);
InBlock.gif            b.height
=GetEMValue(10);
InBlock.gif            
if(browser.isFirefox())
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                b.overflow
="-moz-scrollbars-vertical"
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                b.overflow
="auto"
ExpandedSubBlockEnd.gif            }

InBlock.gif            addDomListener(l,GEvent_mousedown,CancelEventBubble);
InBlock.gif            
this.contentDiv=l;
InBlock.gif            
this.container=a;
InBlock.gif            
this.logDiv=c
ExpandedBlockEnd.gif        }

None.gif        
//通过静态函数来创建GLogBase或获得已创建的GLogBase
None.gif
        GLogBase.instance=function()
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            
var a=GLogBase.object;
InBlock.gif            
if(!a)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                a
=new GLogBase();
InBlock.gif                GLogBase.object
=a
ExpandedSubBlockEnd.gif            }

InBlock.gif            
return a
ExpandedBlockEnd.gif        }
;
None.gif        
//将指定的内容输出
None.gif
        GLogBase.prototype.write=function(message,color)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            
var c=this.createLogItem();
InBlock.gif            
if(b)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                c
=CreateElement("span",c);
InBlock.gif                c.style.color
=color
ExpandedSubBlockEnd.gif            }

InBlock.gif            CreateTextNode(message,c);
InBlock.gif            
this.reDraw()
ExpandedBlockEnd.gif        }
;
None.gif        
//输出指定的URL
None.gif
        GLogBase.prototype.writeUrl=function(a)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            
var b=CreateElement("a",this.createLogItem());
InBlock.gif            CreateTextNode(a,b);
InBlock.gif            b.href
=a;
InBlock.gif            
this.reDraw()
ExpandedBlockEnd.gif        }
;
None.gif        
//输出指定的HTML内容
None.gif
        GLogBase.prototype.writeHtml=function(a)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            
var b=CreateElement("span",this.createLogItem());
InBlock.gif            b.innerHTML
=a;
InBlock.gif            
this.reDraw()
ExpandedBlockEnd.gif        }
;
None.gif        
//清空所有的输出
None.gif
        GLogBase.prototype.clear=function()
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            removeNodeChildren(
this.contentDiv)
ExpandedBlockEnd.gif        }
;
None.gif        
//删除GLogBase
None.gif
        GLogBase.prototype.close=function()
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            deposeNode(
this.container)
ExpandedBlockEnd.gif        }
;
None.gif        
//点击的时候开始拖动层
None.gif
        GLogBase.prototype.onMouseDown=function(a)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            
if(!this.dragObject)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.dragObject=new GDragPanel(this.container);
InBlock.gif                
this.container.style.bottom=""
ExpandedSubBlockEnd.gif            }

ExpandedBlockEnd.gif        }
;
None.gif        
//创建一个输出项目层
None.gif
        GLogBase.prototype.createLogItem=function()
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            
var a=CreateElement("div",this.contentDiv);
InBlock.gif            
var b=a.style;
InBlock.gif            b.fontSize
="85%";
InBlock.gif            b.whiteSpace
="nowrap";
InBlock.gif            b.borderBottom
="1px solid silver";
InBlock.gif            a.style.paddingBottom
=GetPixelValue(2);
InBlock.gif            
var c=CreateElement("div",a);
InBlock.gif            c.style.color
="gray";
InBlock.gif            c.style.fontSize
="75%";
InBlock.gif            CreateTextNode(
this.getlogTime(),c);
InBlock.gif            
return a
ExpandedBlockEnd.gif        }
;
None.gif        
//内容变化之后调整显示内容
None.gif
        GLogBase.prototype.reDraw=function()
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            
this.contentDiv.scrollTop=this.contentDiv.scrollHeight;
InBlock.gif            
this.keepSize()
ExpandedBlockEnd.gif        }
;
None.gif        
//获取疏剪输出字符串
None.gif
        GLogBase.prototype.getlogTime=function()
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            
var a=new Date();
InBlock.gif            
return this.lb(a.getHours(),2)+":"+this.lb(a.getMinutes(),2)+":"+this.lb(a.getSeconds(),2)+":"+this.lb(a.getMilliseconds(),3)
ExpandedBlockEnd.gif        }
;
None.gif        
//将事件中的8转化为08输出
None.gif
        GLogBase.prototype.lb=function(a,b)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            
var c=a.toString();
InBlock.gif            
while(c.length<b)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                c
="0"+c
ExpandedSubBlockEnd.gif            }

InBlock.gif            
return c
ExpandedBlockEnd.gif        }
;
None.gif        
//调整窗口,自适应大小
None.gif
        GLogBase.prototype.keepSize=function()
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif            SetSize(
this.logDiv,new GSize(this.container.offsetWidth,this.container.offsetHeight))
ExpandedBlockEnd.gif        }
;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值