//Copyright 2006, Grazr Corporation
 var loadURL = location.href; var isIE=false; if(document.all && !window.opera) { isIE=true; }; var handler = new Array(); function cleanTransfer(num) { var appBlock = document.getElementById("grazr"); if( handler[num]) { var target = document.getElementById("xid"+num); target.parentNode.removeChild(target); handler[num]=null; }; }; function nullTransfer(num) { var target = document.getElementById("xid"+num); target.src=null; target.parentNode.removeChild(target); handler[num].callback = function() { }; }; function xdReceive(num,data) { if(handler[num]) { handler[num].callback(data,handler[num].arg); data = null; setTimeout(function(){ cleanTransfer(num); },100); } else { }; }; var grazrEventListener = new Array(0); var grazrEventTarget = new Array(0); function getTarget(e,domnode) { if(domnode["gzon"+e.type]) { return domnode; } else { if(domnode.parentNode && !domnode.parentNode.bypass) { return getTarget(e,domnode.parentNode); }; }; return null; }; function grazrEvent(e) { var e = e || window.event; if(!e.target) { e.target = e.srcElement;}; var target = e.target; if(window.gzHookEvent && window.gzHookEvent(e) ) { e.gzbubble=false; } else { (target.bypass)?target=null:target = getTarget(e,target); if(target) { e.gztarget = grazrEventTarget[target["gzon"+e.type]]; grazrEventListener[target["gzon"+e.type]](e); if(!e.gzbubble) { if(e.preventDefault){e.preventDefault();}; if(e.stopPropagation){e.stopPropagation();}; e.bubble = false; return false; }; }; }; }; function Grazr() { var eid=1; function regEvent(obj,type,method) { var scrub=false; if(eid==1) { scrub=true; }; while(grazrEventListener[eid]) { eid++; }; if(scrub) { var scrb=grazrEventListener.length+1; while(!grazrEventListener[scrb] && scrb > 1) { scrb--; }; grazrEventListener=grazrEventListener.slice(0,scrb+1); }; grazrEventListener[eid] = method; grazrEventTarget[eid] = obj; obj.getDisplay()["gz"+type] = eid; obj.getDisplay()[type] = grazrEvent; return eid; }; function FXengine(fps) { var local = this; var timeInt = 1; var running = false; var effects = new Array(); function construct() { timeInt = ((1/fps) * 1000).toFixed(0); }; function Iterator() { running = true; var iscomplete = false; var nextQueue = new Array(); for(var i=0; i<effects.length; i++) { iscomplete = effects[i].step(); if(!iscomplete) { nextQueue.push(effects[i]); }; }; effects = nextQueue; if(effects.length > 0) { setTimeout(Iterator,timeInt); } else { running = false; }; }; this.start = function() { if(!running) { Iterator(); }; }; this.addAction = function(action) { action.setInterval(timeInt); action.setEngine(local); effects.push(action); if(!running) { local.start(); }; }; construct(); }; function FXaction(duration) { var local = this; var interval = 0; var engine = null; var frames = 0; var totalframes = 0; var value = 0; var valueInterval = 0; var trigger = null; var pauseVal = false; this.animFunction = function(frac) { }; this.chainTo = function(action) { trigger = action; }; this.pause = function() { pauseVal = true; }; this.unpause = function() { pauseVal = false; }; this.step = function() { if(!pauseVal) { value+=valueInterval; var rounded = value.toFixed(5); local.animFunction(rounded); frames++; if(frames >= totalframes) { if(trigger) { engine.addAction(trigger); }; return true; } else { return false; }; }; return false; }; this.setEngine = function(ineng) { engine = ineng; }; this.setInterval = function(timeint) { frames = 0; value = 0; if(duration == 0) { totalframes = 0; } else { interval = timeint; totalframes = Math.round(1000*duration / interval); valueInterval = 1 / totalframes; }; }; this.reset = function() { }; }; function registerHandler(num,handlerFunction,argument) { handler[num] = {callback:handlerFunction,arg:argument}; }; function XDataPipe() { var local = this; var appBlock = null; var sblock = null; var address = null; var options = ""; var xid = -1; this.setupPipe = function(inadd) { local.initPipe(); address = inadd; }; this.setOptions = function(inoptions) { options=inoptions; }; this.getData = function(uri,handler,passarg,trans) { xid++; handler[xid] = 1; trans[passarg].xid=xid; if(handler) { registerHandler(xid,handler,passarg); } else { throw(new Error("getData method requires 'handler' callback")); }; sblock = document.createElement("script"); var target = address+"?xid="+xid+"&rnd="+Math.round(Math.random()*100000)+"&url="+uri; sblock.setAttribute('id',"xid"+xid); sblock.setAttribute('type','text/javascript'); sblock.setAttribute('defer','defer'); sblock.setAttribute('src',target); var appBlock=null; appBlock = document.getElementById("grazr"); if(appBlock) { appBlock.appendChild(sblock); } else { local.initPipe(); }; return xid; }; this.initPipe = function() { ehandler = new Array(); handler = new Array(); var appBlock=null; appBlock = document.getElementById("grazr"); if(!appBlock) { throw(new Error("No head element for XD transfer")); }; }; local.initPipe(); }; function EventObject() { this.getDisplay = function() { return this.display; }; this.addEventListener = function(type,inMethod) { return regEvent(this,type,inMethod); }; }; var eventproto = new EventObject(); function GrazrObject() { this.setHW = function(inH,inW) { this.display.style.height=inH+"px"; this.display.style.width=inW+"px"; }; this.setXY = function(inX,inY) { this.display.style.left=inX+"px"; this.display.style.top=inY+"px"; }; this.setRect = function(inX,inY,inX2,inY2) { if(isIE) { this.display.style.borderLeft=0+"px"; this.display.style.borderTop=0+"px"; this.display.style.borderRight=inX2+"px solid #FFFFFF"; this.display.style.borderBottom=inY2+"px solid #FFFFFF"; this.display.style.width="100%"; } else { this.display.style.left=inX+"px"; this.display.style.top=inY+"px"; this.display.style.right=inX2+"px"; this.display.style.bottom=inY2+"px"; }; }; this.setStyle = function(stname,value) { this.display.style[stname]=value; }; this.setClass = function(classname) { this.display.className=classname; }; this.add = function(obj) { this.display.appendChild(obj.display); }; this.remove = function(obj) { this.display.removeChild(obj.display); }; }; GrazrObject.prototype = eventproto; var grazrproto = new GrazrObject(); function DomObj(dom) { var temp = new Object; temp.getDisplay = function() { return dom; }; return temp; }; function GrazrPanel() { var scrollpos = 0; var local=this; this.display = document.createElement("div"); this.setStyle("position","absolute"); this.storeScroll = function() { scrollpos = local.display.scrollTop; }; this.reStoreScroll = function() { local.display.scrollTop = scrollpos; }; this.anchorTo = function(inid) { inid.appendChild(this.display); }; }; GrazrPanel.prototype = grazrproto; function Mouseable() { var local = this; var startpos = {X:0,Y:0}; this.target = null; this.setStart = function(pos) { startpos = pos; }; this.getDelta = function(Position) { var xdelt = Position.X - startpos.X; var ydelt = Position.Y - startpos.Y; return {X:xdelt, Y:ydelt}; }; this.getPosition = function(e) { var posx = 0; var posy = 0; if (!e) var e=window.event; if (e.pageX || e.pageY) { posx = e.pageX; posy = e.pageY; } else if (e.clientX || e.clientY) { posx = e.clientX + document.body.scrollLeft; posy = e.clientY + document.body.scrollTop; }; return {X:posx,Y:posy}; }; this.moveListener = function(e) { if(!e) { var e = window.event; }; if(e.preventDefault){e.preventDefault();}; if(e.stopPropagation){e.stopPropagation();}; e.bubble = false; var mpos = local.getPosition(e); var delta = local.getDelta(mpos); local.target.moveInc(delta.X, delta.Y); }; }; var mouse = new Mouseable(); function Vslider(initPosX,initPosY,frame) { var local = this; var vpos = initPosY; var newpos = 0; var maxmove = 0; this.display = document.createElement("div"); this.display.style.position="absolute"; this.display.style.height="8px"; this.display.style.top=initPosY+"px"; if(isIE) { this.display.style.width="100%"; } else { this.display.style.left=initPosX+8+"px"; this.display.style.right="1px"; this.display.style.top=initPosY+"px"; }; this.display.className="vslider"; this.display.id="vslide"; this.display.style.cursor="n-resize"; this.display.style.overflow="hidden"; this.setPos = function(val) { vpos=val; frame.toppanel.style.height=val+"px"; this.display.style.top=val+"px"; if(isIE) { frame.botpanel.style.paddingTop=val+8+"px"; } else { frame.botpanel.style.top=val+8+"px"; }; }; this.moveInc = function(dX, dY) { newpos=vpos+dY; if(newpos < 16) { newpos = 16}; if(newpos > maxmove) { newpos = maxmove }; frame.toppanel.style.height=newpos+"px"; this.display.style.top=newpos+"px"; if(isIE) { frame.botpanel.style.paddingTop=newpos+8+"px"; } else { frame.botpanel.style.top=newpos+8+"px"; }; }; this.stopMove = function() { App.frame.unwait(); vpos=newpos; document.onmousemove = null; document.onmouseup = null; mouse.target = null; }; this.startMove = function(e) { App.frame.wait(); var mpos = mouse.getPosition(e); mouse.setStart({X:mpos.X,Y:mpos.Y}); mouse.target = local; if(isIE) { maxmove = mpos.Y-44+frame.botpanelIE.clientHeight-16; } else { maxmove = mpos.Y-44+frame.botpanel.clientHeight-16; }; document.onmousemove = mouse.moveListener; document.onmouseup = local.stopMove; }; this.getPos = function() { return vpos; }; this.extendGrazr = function(s1, p1, p2) { return eval(s1); }; }; Vslider.prototype=eventproto; function Hslider(initPos,frame) { var local = this; var hpos = initPos; var newpos = 0; this.display = document.createElement("div"); if(isIE) { this.display.style.cssFloat="left"; this.display.style.styleFloat="left"; } else { this.display.style.position="absolute"; this.display.style.left=initPos+"px"; }; this.display.style.height="110%"; this.display.style.width="8px"; this.display.style.overflow="hidden"; this.display.className="hslider";  this.setPos = function(val) { hpos=val; frame.leftpanel.style.width=val+"px"; if(!isIE) { this.display.style.left=val+"px"; frame.vcontrol.style.left=val+8+"px"; frame.toppanel.style.left=val+"px"; frame.botpanel.style.left=val+"px"; }; }; this.moveInc = function(dX, dY) { newpos=hpos+dX; if(newpos < 16) { newpos = 16}; if(newpos > maxmove) { newpos = maxmove }; frame.leftpanel.style.width=newpos+"px"; if(!isIE) { this.display.style.left=newpos+"px"; frame.vcontrol.style.left=newpos+8+"px"; frame.toppanel.style.left=newpos+8+"px"; frame.botpanel.style.left=newpos+8+"px"; }; }; this.stopMove = function() { App.frame.unwait(); hpos=newpos; document.onmousemove = null; document.onmouseup = null; mouse.target = null; }; this.startMove = function(e) { App.frame.wait(); var mpos = mouse.getPosition(e); mouse.setStart({X:mpos.X,Y:mpos.Y}); maxmove = mpos.X+frame.botpanel.clientWidth-16; mouse.target = local; document.onmousemove = null; document.onmouseup = local.stopMove; }; this.getPos = function() { return hpos; }; }; Hslider.prototype=eventproto; function ThreePaneFrame() { var local = this; var viewport = App.frame.getViewport(); var hpos = (viewport.display.clientWidth) * .325; var vpos = (viewport.display.clientHeight * .5)-4; if(hpos <= 0) { var hpos = 40; var vpos = 22; }; var base = document.createElement("div"); var originX = 0; var originY = 0; var newpos = hpos; var newvpos = vpos; base.style.height="100%"; base.style.width="100%"; base.style.position="absolute"; var leftpanel = document.createElement("div"); this.leftpanel = leftpanel; var rightpanel = document.createElement("div"); this.rightpanel = rightpanel; var toppanel = document.createElement("div"); this.toppanel = toppanel; var botpanel = document.createElement("div"); this.botpanel = botpanel; var botpanelIE = document.createElement("div"); botpanelIE.style.height="100%"; botpanelIE.style.width="100%"; botpanelIE.style.overflow="auto"; this.botpanelIE = botpanelIE; var control = new Hslider(hpos,this); var vcontrol = new Vslider(hpos,vpos,this); this.vcontrol = vcontrol.display; base.appendChild(leftpanel); if(isIE) { leftpanel.style.cssFloat="left"; leftpanel.style.styleFloat="left"; leftpanel.style.width=235+"px"; base.appendChild(control.display); control.display.style.marginRight="-3px"; rightpanel.appendChild(botpanel); rightpanel.appendChild(vcontrol.display); rightpanel.appendChild(toppanel); base.appendChild(rightpanel); } else { base.appendChild(botpanel); base.appendChild(toppanel); base.appendChild(vcontrol.display); base.appendChild(control.display); }; var event1 = control.addEventListener("onmousedown",control.startMove); var event2 = vcontrol.addEventListener("onmousedown",vcontrol.startMove); if(isIE) { rightpanel.style.width="100%"; } else { leftpanel.style.position="absolute"; leftpanel.style.width=hpos+"px"; }; leftpanel.style.height="100%"; leftpanel.style.cssFloat="left"; leftpanel.style.styleFloat="left"; leftpanel.style.overflow="auto"; rightpanel.style.height="100%"; rightpanel.style.overflow="hidden"; toppanel.style.position="absolute"; toppanel.style.top="1px"; toppanel.style.height=vpos+"px"; toppanel.style.overflow="auto"; if(isIE) { toppanel.style.width="100%"; } else { toppanel.style.left=hpos+8+"px"; toppanel.style.right="1px"; }; botpanel.style.position="absolute"; if(isIE) { botpanel.style.width="100%"; botpanel.style.height="100%"; botpanel.style.paddingTop=0+"px"; botpanel.appendChild(botpanelIE); } else { botpanel.style.left=hpos+8+"px"; botpanel.style.right="1px"; botpanel.style.top=vpos+8+"px"; botpanel.style.bottom="1px"; }; botpanel.style.overflow="auto"; this.getSplits = function() { return {H:control.getPos(),V:vcontrol.getPos()}; }; this.setSplits = function(obj) { control.setPos(obj.H); vcontrol.setPos(obj.V); }; this.clear = function() { grazrEventListener[event1] = null; grazrEventListener[event2] = null; }; this.getLeftPanel = function() { return leftpanel; }; this.getTopPanel = function() { return toppanel; }; this.getBotPanel = function() { if(isIE) { return botpanelIE; } else { return botpanel; }; }; this.getRightPanel = function() { return rightpanel; }; this.getPanel = function() { return base; }; this.extendGrazr = function(s1, p1, p2) { return eval(s1); }; }; function titleButton(type,text) { this.display = document.createElement("span"); this.display.className = "gz"+type+"button"; this.display.style.position="absolute"; this.display.style.height="21px"; this.display.style.width="21px"; this.display.title=text; this.display.alt=text; this.display.style.cursor="pointer"; }; titleButton.prototype = eventproto; function AddressBar() { this.display = document.createElement("form"); this.display.style.display="inline"; this.display.style.fontFamily="calibri,myriad,helvetica,sans-serif"; this.display.style.fontSize="8pt"; this.display.setAttribute('autocomplete','off'); this.display.style.marginTop = "0px"; var minput = document.createElement("input"); minput.style.fontFamily="calibri,myriad,helvetica,sans-serif"; if(isIE) { minput.style.fontSize="8pt"; } else { minput.style.marginTop="1px"; minput.style.fontSize="8pt"; }; minput.name="file"; minput.value=unescape(App.config.file); this.display.appendChild(document.createTextNode("Address ")); this.display.appendChild(minput); this.display.style.marginLeft="10px"; this.display.style.marginTop="0px"; this.display.style.padding="0px"; this.setText = function(txt) { minput.value = txt; }; this.go=function() { if(!App.frame.isWaiting()) { var newurl = minput.value; newurl = "http://"+newurl.replace(/^\s*\w+\:[\/]{2,2}/,""); minput.value=newurl; App.confManager.set("file",minput.value); App.frame.wait(); App.frame.setActive(); App.viewer.clear(); App.viewer.init(minput.value); }; return true; }; minput.style.width="35%"; }; AddressBar.prototype = eventproto; function ToolBar() { this.display = document.createElement("div"); var local = this; var boxwidth = 0; this.display.style.fontSize="7.5pt"; var nodeclass = "gztoolbar"; this.display.className = nodeclass; this.height=0; this.display.style.height="0"; this.display.style.overflow = "hidden"; this.display.style.position = "absolute"; var buttonbox = document.createElement("div"); buttonbox.style.position="absolute"; buttonbox.style.width=boxwidth+"px"; buttonbox.style.height="100%"; buttonbox.style.marginLeft="7px"; buttonbox.style.marginRight="7px"; buttonbox.style.display="none"; var addr = new AddressBar(); addr.addEventListener("onsubmit",addr.go); this.display.bypass=true; this.display.appendChild(addr.display); this.display.appendChild(buttonbox); this.reload = function() { addr.go(); }; this.setAddress = function(string) { addr.setText(string); }; this.removeButton = function(gzbutton) { var next = gzbutton.display.nextSibling; buttonbox.removeChild(gzbutton.display); boxwidth-=21; (next)?next.style.left=boxwidth-21+"px":null; buttonbox.style.width=boxwidth+"px"; }; this.addButton = function(gzbutton) { gzbutton.display.style.top="0px"; gzbutton.display.style.left=boxwidth+"px"; buttonbox.appendChild(gzbutton.display); boxwidth=boxwidth+0; buttonbox.style.width=boxwidth+"px"; }; }; ToolBar.prototype = grazrproto; function TitleBar() { this.display = document.createElement("div"); var local = this; var boxwidth = 0; var curtext = null; var text = ""; this.height=0; var nodeclass = "gztitlebar"; this.display.className = nodeclass; this.display.style.overflow = "hidden"; this.display.style.position = "absolute"; this.display.style.height = this.height+"px"; this.display.style.height = this.height+"px"; var textbox = document.createElement("div"); textbox.style.overflow="hidden"; textbox.className="gztitletext"; var buttonbox = document.createElement("div"); buttonbox.className = "gztitlebuttons"; buttonbox.style.position="absolute"; buttonbox.style.width=boxwidth+"px"; buttonbox.style.height="100%"; this.getText = function() { return text; }; this.setText = function(intxt) { text = intxt; textbox.innerHTML = unescape(text); }; this.display.appendChild(buttonbox); this.display.appendChild(textbox); this.addButton = function(gzbutton) { gzbutton.display.style.top="0px"; gzbutton.display.style.left=boxwidth+"px"; buttonbox.appendChild(gzbutton.display); boxwidth=boxwidth+31; buttonbox.style.width=boxwidth+"px"; textbox.style.marginRight=boxwidth+5+"px"; }; this.setNodeClass = function(classtype) { nodeclass = classtype; local.display.className = nodeclass; }; }; TitleBar.prototype = grazrproto; function BackButton() { this.display = document.createElement("div"); this.setStyle("position","absolute"); this.setClass("gzbackbuttonoff"); this.activate = function() { this.setClass("gzbackbuttonon"); }; this.deactivate = function() { this.setClass("gzbackbuttonoff"); }; }; BackButton.prototype = grazrproto; function AboutNode() { var local = this; this.display = document.createElement("div"); this.height=22; var nodeclass = "gzabout"; this.display.className = nodeclass; var tooltip = ""; var myUri = "http://grazr.com/config.html"; try{ (privatelabel)?null:privatelabel = null; } catch(er) { privatelabel = null; }; if(privatelabel) { var logorsrc = "./images/poweredby4.png"; var logosrc = "./pl/"+privatelabel.id+"/"+privatelabel.logo; if(privatelabel.urlExt) { var logoUri = privatelabel.urlExt(); } else { var logoUri = privatelabel.url; }; var textVal= privatelabel.text; (privatelabel.tooltip)?tooltip=privatelabel.tooltip:null; } else { var logosrc = "./images/gzlogo.png?v=014"; var textVal=""; }; textVal = "  "+textVal.replace(/\s+/g," ")+"  "; var leftPanel = document.createElement("div"); leftPanel.className="gzabouttxtleft"; leftPanel.style.cssFloat="left"; leftPanel.style.styleFloat=""; var centerPanel = document.createElement("div"); centerPanel.className="gzabouttxtcnt"; var rightPanel = document.createElement("div"); rightPanel.className="gzabouttxtright"; rightPanel.style.textAlign="right"; rightPanel.style.cssFloat="right"; rightPanel.style.styleFloat="right"; var maxw = 0; function addLogo(panel,logourl,targeturl,side) { var tmplogo = document.createElement("img"); tmplogo.src=logourl; function addNow() { var delta=tmplogo.width - maxw; if (delta > 0) { var pside = "Left"; var oside = "Right"; } else { var pside = "Right"; var oside = "Left"; delta = delta * -1; }; switch(side) { case "only": centerPanel.style.paddingRight=delta+"px"; break; case "right": centerPanel.style["padding"+pside]=delta+"px"; centerPanel.style["padding"+oside]="0px"; break; }; if(tmplogo.width > maxw) { maxw = tmplogo.width; }; if(isIE) { var logo = document.createElement("div"); logo.style.height=tmplogo.height+"px"; logo.style.width=tmplogo.width+"px"; logo.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+logourl+"',sizingMethod='scale')"; } else { var logo = tmplogo; }; tmplogo=null; if(targeturl) { var link = document.createElement("a"); logo.style.border="none"; link.bypass=true; link.href=targeturl; link.target="_BLANK"; link.appendChild(logo); link.title=targeturl; link.alt=targeturl; panel.appendChild(link); } else { panel.appendChild(logo); }; }; if(tmplogo.width == 0) { tmplogo.onload = addNow; } else { addNow(); }; }; if(privatelabel) { addLogo(leftPanel,logosrc,logoUri); addLogo(rightPanel,logorsrc,null,"right"); } else { addLogo(leftPanel,logosrc,null,"only"); }; if(!App.config.dis) { centerPanel.innerHTML=textVal; this.display.title = tooltip; this.display.alt = tooltip; }; this.setStyle("position","absolute"); this.display.appendChild(rightPanel); this.display.appendChild(leftPanel); if(!App.config.dis) { centerPanel.innerHTML=textVal; this.display.title = tooltip; this.display.alt = tooltip; this.display.appendChild(centerPanel); } else { this.display.style.cursor="default"; this.getData = null; }; this.getData = function(e) { var child = window.open(myUri+App.confManager.getURLstring(),App.config.linktarget); setTimeout(function() { child.focus() }, 100 ); }; }; AboutNode.prototype = grazrproto; function MappedElement() { this.getNextSibling = function() { return this.parent.index[this.index+1]; }; this.getPrevSibling = function() { return this.parent.index[this.index-1]; }; this.getParent = function() { if(this.parent && this.parent.parent) { return this.parent.parent; }; }; this.getChild = function() { if(this.child) { return this.child.index[0]; } else { return this; }; }; this.getLastChild = function() { if(this.child) { var last = this.child.index.length-1; return this.child.index[last]; } else { return this; }; }; }; MappedElement.prototype = grazrproto; var mapElementProto = new MappedElement(); function Node() { this.nodeclass = "gznode"; this.setNodeClass = function(classtype) { this.nodeclass = classtype; try { this.display.className = classtype; } catch(er) { alert(this.setNodeClass.caller); alert(er); }; }; this.getData = function(e) { if(e.altKey && e.gztarget.htmlUri) { window.open(e.gztarget.htmlUri,App.config.linktarget); e.stopPropagation(); } else { App.viewer.nodeAction(e.gztarget); }; }; this.highlight = function(e) { App.viewer.highlight(e.gztarget); return 1; }; this.unhighlight = function(e) { e.gztarget.display.className = e.gztarget.nodeclass; }; }; Node.prototype = mapElementProto; var nodeproto = new Node(); function makeIcon(name) { var iconimg=document.createElement("span"); iconimg.className = "gz"+name+"icon"; return iconimg; }; function makePostIcon(name) { var iconimg=document.createElement("span"); iconimg.className = name; return iconimg; }; function processResult(outlineNode) { var tempData = App.forms.getResults(outlineNode.attribute.formname); if(tempData) { App.datamanager.setID(tempData, this.outline.id); this.outline.childNodes = tempData.childNodes; App.datamanager.state[outlineNode.id]={loaded:true,expanded:true}; } else { if(!App.datamanager.state[outlineNode.id]) { App.datamanager.state[outlineNode.id]={loaded:false,expanded:false}; }; }; App.forms.addResultNode(outlineNode.attribute.formname,this); }; function ResultNode(outlineNode) { var local = this; var enabled = false; var iconimg=null; this.display = document.createElement("div"); this.display.className="gznode"; var textVal = ""; this.myUri = null; this.display.style.cursor="default"; this.outline = outlineNode; outlineNode.attribute.subtype="result"; this.proc = processResult; this.proc(outlineNode); this.enable = function() { enabled = true; }; var superclass = new Node(); for(var prop in superclass) { this[prop] = superclass[prop]; }; this.getData = function(e) { if(enabled) { return superclass.getData(e) }; }; this.highlight = function(e) { if(enabled) { return superclass.highlight(e) }; }; this.unhighlight = function(e) { if(enabled) { return superclass.highlight(e) }; }; outlineNode.attribute.type="gzresult"; var tempData = App.forms.getResults(outlineNode.attribute.formname); if(tempData) { var type = tempData.attribute.type; outlineNode.attribute.type = type; enabled = true; }; iconimg=makeIcon("result"); if(outlineNode.attribute.title) { var textVal=outlineNode.attribute.title; } else { var textVal = outlineNode.attribute.text; }; if(outlineNode.attribute.xmlUrl) { this.myUri = outlineNode.attribute.xmlUrl; } else { this.myUri = outlineNode.attribute.url; }; if(outlineNode.attribute.htmlUrl) { this.htmlUri = outlineNode.attribute.htmlUrl; }; var textnode = document.createElement("span"); textnode.innerHTML=unescape(textVal); this.display.appendChild(iconimg); this.display.appendChild(textnode); this.display.href = this.myUri; }; function FormNode(outlineNode) { var local = this; this.display = document.createElement("div"); this.display.bypass = true; this.display.className="gztext gzform"; var textVal = ""; this.outline = outlineNode; var textVal = outlineNode.attribute.text; var textnode = document.createElement("span"); textnode.innerHTML=unescape(textVal); this.display.appendChild(textnode); var form = this.display.getElementsByTagName("form")[0]; var myname = form.name; var elems = App.forms.getFormVals(myname); if(elems) { for(var i=0; i<elems.length; i++) { if(elems[i].multiple) { for(var j=0; j<elems[i].length; j++) { form.elements[i][j].selected = elems[i][j].selected; }; } else { form.elements[i].value = elems[i].value; (elems[i].checked)?form.elements[i].checked = elems[i].checked:null; }; }; }; this.highlight = function() { return false; }; this.unhighlight = function() { return false; }; }; FormNode.prototype = mapElementProto; function IncludeNode(outlineNode,listIndex) { var local = this; this.display = document.createElement("a"); this.display.style.display = "block"; this.display.target=App.config.linktarget; this.display.className="gznode"; var textVal = ""; this.myUri = null; var iconimg=null; this.outline = outlineNode; if(!App.datamanager.state[outlineNode.id]) { App.datamanager.state[outlineNode.id]={loaded:false,expanded:false}; }; if(outlineNode.attribute.type.match(/(feed)|(rss)|(atom)/i)) { iconimg=makeIcon("feed"); outlineNode.attribute.type="rss"; } else{ iconimg=makeIcon("include"); outlineNode.attribute.type="include"; }; if(outlineNode.attribute.title) { var textVal=outlineNode.attribute.title; } else { var textVal = outlineNode.attribute.text; }; if(outlineNode.attribute.xmlUrl) { this.myUri = outlineNode.attribute.xmlUrl; } else { this.myUri = outlineNode.attribute.url; }; if(outlineNode.attribute.htmlUrl) { this.htmlUri = outlineNode.attribute.htmlUrl; }; var textnode = document.createElement("span"); if(outlineNode.attribute.subtype=="result") { this.proc = processResult; this.proc(outlineNode); iconimg=makeIcon("result"); }; if(outlineNode.attribute.subtype=="autodiscovered") { this.autodiscovered=true; }; textnode.innerHTML=unescape(textVal); this.display.appendChild(iconimg); this.display.appendChild(textnode); this.display.href = this.myUri; }; IncludeNode.prototype = nodeproto; function TextNode(outlineNode,listIndex) { var local = this; this.nodeclass = "gztext"; this.index = listIndex; this.display = document.createElement("div"); this.outline = outlineNode; var nodeclass = "gztext"; this.display.className = nodeclass; var textVal = unescape(outlineNode.attribute.text); switch(outlineNode.attribute.type) { case "gz-title": if(App.viewer.type == "outline") { this.display.style.display="none"; } else { if(outlineNode.attribute.htmlURL) { var textVal = unescape("<a href='../../stage/script/grazr/"+outlineNode.attribute.htmlURL+"'>"+outlineNode.attribute.text+"</a>"); }; this.display.className="posttitle"; }; break; case "gz-author": this.display.className="postauthor"; break; case "gz-date": this.display.className="postdate"; break; case "gz-enclosure": this.display.className="postenclosure"; break; case "gz-postclear": this.display.className="postclear"; break; case "gz-content": this.display.className="gztext postcontent"; break; default: break; }; this.display.innerHTML = textVal; var links = this.display.getElementsByTagName("a"); for(var i=0; i<links.length; i++) { links[i].setAttribute("target",App.config.linktarget); }; this.highlight = function() { return; }; this.addEventListener = function() { return 0; }; this.unhighlight = function() { return; }; }; TextNode.prototype = mapElementProto; function FolderNode(outlineNode,listIndex) { var local = this; this.index = listIndex; this.display = document.createElement("div"); this.outline = outlineNode; var textVal = ""; var myUri = null; var nodeclass = "gznode"; var expanded = false; var rendered = null; if(!App.datamanager.state[outlineNode.id]) { App.datamanager.state[outlineNode.id]={loaded:true,expanded:false}; }; this.display.className = nodeclass; var myChildNodes = outlineNode.childNodes; if(outlineNode.attribute.title) { var textVal=outlineNode.attribute.title; } else { var textVal = outlineNode.attribute.text; }; if(!textVal) { var textVal = "No title"; }; var gzList = {data:outlineNode.childNodes,title:textVal,scrollPos:0}; if(outlineNode.attribute.htmlUrl) { this.htmlUri = unescape(outlineNode.attribute.htmlUrl); }; var textnode = document.createElement("span"); textnode.innerHTML=unescape(textVal); var iconimg; if(outlineNode.attribute.type == "rss-story") { iconimg=makeIcon("story"); } else { iconimg=makeIcon("folder"); }; iconimg.style.display = "inline"; this.display.appendChild(iconimg); this.display.appendChild(textnode); if(this.htmlUri) { var linktext = document.createElement("a"); linktext.appendChild(makePostIcon("folder")); linktext.className="gznodelink"; linktext.href=this.htmlUri; linktext.target=App.config.linktarget; linktext.bypass = true; linktext.alt="Open this item in a new window"; linktext.title="Open this item in a new window"; this.display.appendChild(linktext); }; }; FolderNode.prototype = nodeproto; function LinkNode(outlineNode,listIndex) { var local = this; this.index = listIndex; this.display = document.createElement("a"); this.display.style.display = "block"; this.outline = outlineNode; var nodeclass = "gznode"; if(outlineNode.attribute.title) { var textVal=outlineNode.attribute.title; } else { var textVal = outlineNode.attribute.text; }; this.display.className = nodeclass; if(!App.datamanager.state[outlineNode.id]) { App.datamanager.state[outlineNode.id]={loaded:true}; }; var myUri = ""; if(outlineNode.attribute.htmlUrl) { myUri = outlineNode.attribute.htmlUrl; } else if (outlineNode.attribute.url) { myUri = outlineNode.attribute.url; } else if (outlineNode.attribute.xmlUrl) { myUri = outlineNode.attribute.url; }; this.display.href = myUri; this.htmlUri=myUri; var iconimg=makeIcon("link"); var textnode = document.createElement("div"); textnode.innerHTML=unescape(textVal); textnode.style.marginRight="15px"; textnode.style.marginLeft="25px"; this.display.appendChild(iconimg); this.display.appendChild(textnode); var myChildNodes = outlineNode.childNodes; this.activateLink = function() { window.open(myUri,App.config.linktarget); }; }; LinkNode.prototype = nodeproto; function List(outlineNode,gzNode) { this.extendGrazr = function(s1, p1, p2) { return eval(s1); }; var local = this; var textVal; this.display = document.createElement("div"); var node = null; this.display.style.overflow="visible"; this.outline = outlineNode; if(gzNode) { this.parent = gzNode; gzNode.child = this; }; this.index = new Array(0); var eventList = new Array(0); if(!outlineNode.title) { if(outlineNode.attribute.title) { outlineNode.title = outlineNode.attribute.title; } else if(outlineNode.attribute.text) { outlineNode.title = outlineNode.attribute.text; }; }; if(outlineNode.childNodes) { for(var i=0, j=outlineNode.childNodes.length; i<j; i++) { node = null; if(outlineNode.childNodes[i] && outlineNode.childNodes[i].outline) { var type = outlineNode.childNodes[i].outline.attribute.type; if(type) { switch(type) { case "rss": node = new IncludeNode(outlineNode.childNodes[i].outline,i); break; case "rss-story": node = new FolderNode(outlineNode.childNodes[i].outline,i); break; case "link": if(outlineNode.childNodes[i].outline.attribute.url) { var test = outlineNode.childNodes[i].outline.attribute.url; if(outlineNode.childNodes[i].outline.attribute.url.match(/\.opml$/)){ node = new IncludeNode(outlineNode.childNodes[i].outline,i); } else { node = new LinkNode(outlineNode.childNodes[i].outline,i); }; } else { if(outlineNode.childNodes[i].outline.attribute.xmlUrl &&outlineNode.childNodes[i].outline.attribute.xmlUrl.match(/\.opml$/)){ node = new IncludeNode(outlineNode.childNodes[i].outline,i); } else { node = new LinkNode(outlineNode.childNodes[i].outline,i); }; }; break; case "include": node = new IncludeNode(outlineNode.childNodes[i].outline,i); break; case "gzform": node = new FormNode(outlineNode.childNodes[i].outline,i); break; case "gzresult": node = new ResultNode(outlineNode.childNodes[i].outline,i); break; default: node = new TextNode(outlineNode.childNodes[i].outline,i); break; }; } else { if(outlineNode.childNodes[i].outline.childNodes) { node = new FolderNode(outlineNode.childNodes[i].outline,i); } else { node = new TextNode(outlineNode.childNodes[i].outline,i); }; }; node.display.id="node"; eventList.push(node.addEventListener("onclick",node.getData)); eventList.push(node.addEventListener("onmouseover",node.highlight)); eventList.push(node.addEventListener("onmouseout",node.unhighlight)); node.parent=this; node.index = i; this.display.appendChild(node.display); this.index.push(node); }; }; }; function clearFlash(node) { var objs = node.display.getElementsByTagName("object"); for (var i=objs.length;i;i--){ objs[i-1].parentNode.removeChild(objs[i-1]); }; }; function killDOM(n) { if(n && n.childNodes) { for(var i=n.childNodes.length-1; i>=0; i--) { killDOM(n.childNodes[i]); n.removeChild(n.childNodes[i]); }; }; }; this.destroy = function() { clearFlash(local); for(var i=eventList.length-1; i>0; i--) { grazrEventListener[eventList[i]] = null; grazrEventTarget[eventList[i]] = null; }; eid=1; if(this.index) { for(var i=this.index.length-1; i>=0; i--) { if(this.index[i].child) { this.index[i].child.destroy(); this.index[i].child=null; }; this.index[i].display=null; this.index[i]=null; }; this.index = null; }; if(this.display.parentNode) { this.display.parentNode.removeChild(this.display); }; if(this.parent) { this.parent.child=null; this.parent=null; }; }; }; function Selector(num) { this.display=document.createElement("div"); this.action = function() { App.viewmanager.showViewMenu(); App.viewmanager.changeViewNum(num); }; }; Selector.prototype=eventproto; function LightBox(viewtext) { text = viewtext; text.unshift("Select View:"); var viewitems = new Array(0); this.display=document.createElement("div"); this.display.style.fontFamily="calibri,myriad,helvetica,sans-serif"; this.display.style.fontSize="9pt"; this.display.style.position="absolute"; this.display.style.zIndex="100"; this.display.style.height="100%"; this.display.style.width="100%"; this.shadow = document.createElement("div"); this.shadow.style.position="absolute"; this.shadow.style.height="100%"; this.shadow.style.width="100%"; this.shadow.style.opacity=".55"; this.shadow.style.filter = "alpha(opacity=55)"; this.shadow.style.background="#000"; this.menu = document.createElement("div"); this.menu.style.position="absolute"; this.menu.style.height="75%"; this.menu.style.width="75%"; this.menu.style.top="12.5%"; this.menu.style.left="12.5%"; this.menu.style.opacity="1"; this.menu.style.filter = "alpha(opacity=100)"; this.menu.style.background="#000"; this.menu.style.color="#FFF"; this.menu.style.overflow="auto"; var item = document.createElement("div"); item.appendChild(document.createTextNode(text[0])); item.style.fontWeight="bold"; this.menu.appendChild(item); this.menu.appendChild(document.createElement("br")); for(var i=1; i<text.length; i++) { var item = new Selector(i-1); item.display.style.width="44px"; item.display.style.height="64px"; item.display.style.cursor="pointer"; item.display.style.padding="10px"; item.display.style.textAlign="center"; var myimage = document.createElement("img"); var img=text[i].replace(/\s/g,"-"); myimage.src="./theme/images/"+img+"_icon.png"; item.display.appendChild(myimage); item.display.appendChild(document.createElement("br")); item.display.appendChild(document.createTextNode(text[i])); item.display.style.cssFloat="left"; item.display.style.styleFloat="left"; item.addEventListener("onclick",item.action); this.menu.appendChild(item.display); viewitems.push(item); }; var cancelor = document.createElement("div"); cancelor.style.width="75%"; cancelor.style.width="75%"; cancelor.style.top="88%"; var item = new Selector(-1); item.display.style.padding="10px"; item.display.style.position="absolute"; item.display.style.margin="20px"; item.display.style.right="0px"; item.display.style.bottom="0px"; item.display.style.right="0px"; item.display.style.cursor="pointer"; item.display.appendChild(document.createTextNode("Cancel")); item.addEventListener("onclick",function() { App.viewmanager.showViewMenu() }); this.menu.appendChild(item.display); this.display.appendChild(this.shadow); this.display.appendChild(this.menu); this.clearhighlight = function(last) { viewitems[last].display.style.background="#000"; viewitems[last].display.style.border="none"; }; this.highlight = function(num,last) { viewitems[num].display.style.background="#333"; viewitems[num].display.style.border="1px solid #FFF"; if(last+1) { viewitems[last].display.style.background="#000"; viewitems[last].display.style.border="none"; }; }; this.show = function(obj) { obj.appendChild(this.display); }; this.remove = function() { this.display.parentNode.removeChild(this.display); }; }; function AppFrame(base) { this.extendGrazr = function(s1, p1, p2) { return eval(s1); }; var local = this; this.waiting = false; var viewer = null; var drawer = null; var animEngine = new FXengine(30); var shield = new Object(); shield.display = document.createElement("div"); shield.display.className = "noselectpane wait"; var loadshield = new Object(); loadshield.display = document.createElement("div"); var framepanel = new GrazrPanel(); framepanel.anchorTo(base); var basepanel = new GrazrPanel(); basepanel.anchorTo(base); basepanel.setStyle("height","100%"); basepanel.setStyle("width","100%"); basepanel.setClass("gzbasepanel"); this.setFont = function(fontFam) { basepanel.setStyle("fontFamily",fontFam+",calibri,myriad,helvetica,sans-serif,sans-serif"); }; this.setFontSize = function(fntsize) { try { basepanel.setStyle("fontSize",fntsize); } catch(er) { basepanel.setStyle("fontSize","10pt"); }; }; this.setFont(App.config.font); this.setFontSize(App.config.fontsize); var hdrH=0; var ftrH=0; var viewport = new GrazrPanel(); viewport.setStyle("overflow","hidden"); viewport.setClass("gzcontentpanel"); function setPort(panel,inTop,inBot) { if(isIE) { panel.setStyle("borderTop",0+"px"); panel.setStyle("borderBottom",0+"px"); panel.setStyle("height","100%"); panel.setStyle("width","100%"); } else { panel.setRect(0,5,0,5); }; }; setPort(viewport,hdrH,ftrH); basepanel.add(viewport); this.removeHeader = function(hobj) { hdrH-=hobj.height; if(isIE){ hdrH++; }; setPort(viewport,hdrH,ftrH); basepanel.remove(hobj); }; this.addHeader = function(hobj) { hdrH+=hobj.height; if(isIE){ hdrH--; }; setPort(viewport,hdrH,ftrH); basepanel.add(hobj); }; this.addFooter = function(fobj) { ftrH+=fobj.height; setPort(viewport,hdrH,ftrH); fobj.display.style.height=fobj.height+"px"; basepanel.add(fobj); }; this.getBasePanel = function() { return basepanel; }; this.getViewport = function() { return viewport; }; this.getDrawer = function() { return drawerpanel; }; var about = new AboutNode(App); about.setStyle("position","absolute"); if(!App.config.dis) { about.addEventListener("onclick",about.getData); }; about.setStyle("bottom","0px"); about.setStyle("left","0px"); if(isIE) { about.display.style.width="100%"; } else { about.setStyle("right","0px"); }; var titlebar = new TitleBar(); titlebar.setXY(0,0); var toolbar = new ToolBar(); toolbar.setXY(0,0); if(isIE) { toolbar.setXY(0,0); } else { toolbar.setXY(0,0); }; if(App.config.title) { titlebar.setText(App.config.title); }; this.setTitle = function(intxt) { if(!App.config.title) { (intxt)?null:intxt="..."; titlebar.setText(intxt); try { intxt = unescape(intxt); intxt=intxt.replace(/\&\#([^\;]*)\;/g,function(input) { var code = input.match(/\&\#([^\;]*)\;/); return String.fromCharCode(code[1]); }); intxt = intxt.replace(/\<[^\>]*\>/g," "); document.title=intxt; } catch(er) { }; }; }; if(isIE) { titlebar.setXY(0,0); titlebar.setStyle("width","auto"); toolbar.setStyle("width","100%"); } else { titlebar.setXY(0,0); toolbar.setStyle("right","0px"); titlebar.setStyle("right","0px"); }; var configpanel; var currentpanel; var drawerActive = 0; function openDrawer(panel) { var openDR = new FXaction(.5); var max; if(drawerActive) { openDR.animFunction = function(frac) { frac = 1-(Math.pow(1-frac,3.5)); perc = 22+Math.round(0.5 * frac * 100); content.setStyle("width",perc+"%"); slidein.setStyle("left",perc+"%"); }; animEngine.addAction(openDR); panel=null; drawerActive=0; } else { if(base.clientWidth < 200) { max = 100; } else { max = 22; }; slidein.setStyle("width",max+"%"); currentpanel=panel; openDR.animFunction = function(frac) { frac = 1-(Math.pow(1-frac,3.5)); perc = 100-Math.round((max/100) * frac * 100); content.setStyle("width",perc+"%"); slidein.setStyle("left",perc+"%"); }; animEngine.addAction(openDR); drawerActive=1; }; }; var maxbutton = new titleButton("launch",""); var viewbutton = new titleButton("view","Change Grazr View"); var homebutton = new titleButton("home","Home"); var helpbutton = new titleButton("help","Help"); var stopbutton = new titleButton("stop","Stop"); var freshbutton = new titleButton("refresh","Refresh"); var helppanel = null; freshbutton.addEventListener("onclick",toolbar.reload); stopbutton.addEventListener("onclick",App.datamanager.stop); toolbar.addButton(homebutton); toolbar.addButton(freshbutton); titlebar.addButton(helpbutton); titlebar.addButton(viewbutton); titlebar.addButton(maxbutton); this.addButton = toolbar.addButton; this.removeButton = toolbar.removeButton; helpbutton.addEventListener("onclick", function() { var child = window.open("./gzpanel.html?view=o,-s,-3p&toolbar=off&file=http://docs.grazr.com/manual/help.xml","_blank","width=300,height=600,resizable=yes,status=yes"); }); viewbutton.addEventListener("onclick", function() { App.viewmanager.showViewMenu(); }); maxbutton.addEventListener("onclick", function() { loadURL = loadURL.replace(/\?.*$/,App.confManager.getURLstring()); var child = window.open(loadURL,"_blank","width="+base.clientWidth+",height="+base.clientHeight+",resizable=yes,status=yes"); App.childlaunch=true; }); viewbutton.addEventListener("onclick", function() { App.viewmanager.showViewMenu(); }); homebutton.addEventListener("onclick", function() { if(location.href.match(/file/)) { var homeURL = location.href.match(/file=(.*)$/)[1]; } else { var homeURL = App.config.file; }; toolbar.setAddress(homeURL); App.viewer.init(homeURL); }); this.addHeader(titlebar); stopbutton.display.style.position="absolute"; var hastoolbar=false; this.addToolBar = function() { if(!hastoolbar) { this.addHeader(toolbar); loadshield.display.appendChild(stopbutton.display); hastoolbar=true; }; }; this.removeToolBar = function() { if(hastoolbar) { this.removeHeader(toolbar); loadshield.display.removeChild(stopbutton.display); hastoolbar=false; }; }; if(App.config.toolbar!="off") { this.addToolBar(); hastoolbar=true; }; this.addFooter(about); this.setAddress = function(value) { toolbar.setAddress(value); }; this.setActive = function() { this.active=true; about.setClass("gzactivity"); }; this.loading = function() { stopbutton.display.style.left=freshbutton.display.offsetLeft + freshbutton.display.parentNode.offsetLeft + "px"; stopbutton.display.style.top=freshbutton.display.offsetTop + freshbutton.display.parentNode.offsetTop + freshbutton.display.parentNode.parentNode.offsetTop + "px"; local.wait(); basepanel.add(loadshield); local.isloading = true; }; this.wait = function() { if(App.keymanager) { App.keymanager.enable(false); }; local.waiting=true; basepanel.add(shield); }; this.unwait = function() { if(local.waiting) { local.waiting=false; if(App.keymanager) { App.keymanager.enable(true); }; about.setClass("gzabout"); basepanel.display.removeChild(shield.display); }; if(local.isloading) { loadshield.display.parentNode.removeChild(loadshield.display); local.isloading = false; }; }; this.isWaiting = function() { return local.waiting; }; var mouseblock = new Object(); mouseblock.display = document.createElement("div"); mouseblock.display.className = "noselectpane"; this.keymode = function(bool) { if(!bool && this.inkeymode) { mouseblock.onmousemove = null; basepanel.remove(mouseblock); this.inkeymode = false; } else { if(bool) { basepanel.add(mouseblock); this.inkeymode = true; App.keymanager.typemode = true; mouseblock.display.onmousemove = function() { local.keymode(false); }; }; }; }; }; function GZid(outline,pnum) { if(outline) { pid = pnum; outline.id = pnum; (App.datamanager.state[pnum])?App.datamanager.state[pnum] = null:null; if(outline.childNodes) { for(var i=0, j=outline.childNodes.length; i<j; i++) { GZid(outline.childNodes[i].outline,pnum+"."+i); }; }; }; }; function stripTags(outline) { if(outline && outline.childNodes) { var newChild = new Array(0); for(var i=0, j=outline.childNodes.length; i<j; i++) { if(outline.childNodes[i].outline) { stripTags(outline.childNodes[i].outline); newChild.push(outline.childNodes[i]); }; }; if(newChild.length>0) { outline.childNodes = newChild; } else { outline.childNodes = null; }; }; }; function DataManager(App) { var local=this; var pipearray = ["api1.grazr.com","api2.grazr.com","api3.grazr.com","api4.grazr.com","api5.grazr.com"]; var pipehome="http://"+pipearray[Math.round(Math.random()*(pipearray.length-1))]+"/"; var Xd = new XDataPipe(); Xd.setupPipe(pipehome+"xdgraze"); var tid = -1; var trans = new Array(0); this.setID = GZid; this.rootNode = null; this.activeNode = null; this.state = {}; this.getData = function(uri,callback,rootid,target) { App.frame.setActive(); App.frame.loading(); tid++; var ret = local.receiveData; trans[tid]={cb:callback,rid:rootid,tgt:target}; Xd.getData(uri,ret,tid,trans); }; function timeOut(tid) { alert("Transaction Timed Out on "+tid); local.cancel(tid); App.frame.unwait(); App.frame.setTitle("Timed out"); }; this.stop = function() { for(var i=0; i<trans.length; i++) { if(trans[i]) { local.cancel(i); }; }; App.frame.unwait(); }; this.cancel = function(tid) { cleanTransfer(trans[tid].xid); trans[tid]=null; }; this.preprocess = function(data,rootid) { try { var title = data.opml.childNodes[0].head.childNodes[0].title.nodeValue; } catch(er) { var title = "..."; }; var receivedOutline = {title:title,attribute:{title:title},childNodes:data.opml.childNodes[1].body.childNodes}; stripTags(receivedOutline); if(!receivedOutline.childNodes) { receivedOutline.childNodes=[{outline:{attribute:{type:"rss-story",text:"No Posts"},childNodes:[{outline:{attribute:{type:"gz-title",text:"(no posts)"}}}]}}]; }; if(receivedOutline.childNodes[0].outline.attribute.type=="rss-story") { receivedOutline.attribute.type="rss"; }; GZid(receivedOutline,rootid); return receivedOutline; }; this.receiveData = function(data,intid) { var receivedOutline = local.preprocess(data,trans[intid].rid); var tmptarget = trans[intid].tgt; var datacall = trans[intid].cb; trans[intid]=null; datacall(receivedOutline,tmptarget); }; function resetState(outline) { var id = outline.id; (App.datamanager.state[id])?App.datamanager.state[id] = null:null; if(outline.childNodes) { for(var i=0; i<outline.childNodes.length; i++) { resetState(outline.childNodes[i].outline); }; }; }; this.resetState = resetState; }; function ConfigManager() { var configpanel = null; App.config = new Object(); App.config.file="http://www.jasonbentley.org/feeds/jasonbentleydotorg.opml.xml"; App.config.font="calibri,myriad,helvetica,sans-serif,sans-serif"; App.config.fontsize="10pt"; App.config.linktarget="grazrwin"; if(window.privatelabel) { for(prop in privatelabel.config) { App.config[prop] = privatelabel.config[prop]; }; }; urlOpt = new Object(); changeOpt = new Object(); var inputURL = location.href; inputURL = inputURL.replace(/\&amp\;/g,"&"); App.config.child = false; var arg1 = inputURL.split(/[?|&]file=/); if(arg1[1]) { arg1[1]=arg1[1].replace(/\&endfile.*/,""); App.config.file=arg1[1]; urlOpt.file=arg1[1]; }; var split=arg1[0].split("?"); if(split[1]) { var options = split[1].split("&"); var pair; for (var i=0; i<options.length;i++) { pair = options[i].split("="); var id = pair[0].toLowerCase(); var val = unescape(pair[1]); App.config[id]=val; if(id != "dis") { urlOpt[id]=val; }; }; }; loadURL = inputURL; this.set = function(parameter,value) { App.config[parameter]=value; changeOpt[parameter]=value; }; this.getURLstring = function() { var opt = "?"; var tObj = new Object(); for(var prop in urlOpt) { tObj[prop] = urlOpt[prop]; }; for(var prop in changeOpt) { if(tObj[prop] != changeOpt[prop]) { tObj[prop] = changeOpt[prop]; }; }; for(prop in tObj) { if(prop != "file") { opt+=prop+"="+tObj[prop]+"&"; }; }; opt = opt.replace(/\&$/,""); if(opt != "?") { opt+="&"; }; if(tObj["file"]) { opt+="file="+tObj["file"]; }; return opt; }; this.configurator = function() { if(configpanel) { } else { configpanel = new GrazrPanel(); configpanel.setStyle("height","100%"); configpanel.setStyle("width","100%"); var newf=document.createElement("iframe"); newf.marginwidth="0"; newf.marginheight="0"; newf.frameborder="0"; newf.style.height="100%"; newf.style.width="100%"; newf.src="./config/config.html"; configpanel.display.appendChild(newf); App.frame.getDrawer().add(configpanel); }; }; }; function StyleManager() { this.setTheme = function(theme) { App.confManager.set("theme",escape(theme)); if(theme.match(/^[^\/]*$/)) { theme = "grazr.com/theme/"+theme+"/grazr.css"; }; var styleinfo = document.createElement("link"); styleinfo.setAttribute("rel","stylesheet"); styleinfo.setAttribute("href","http://"+unescape(theme)); var hd = document.getElementsByTagName("head")[0]; var current = document.getElementById("gzskin"); if(current) { hd.removeChild(current); }; styleinfo.id = "gzskin"; hd.appendChild(styleinfo); }; if(App.config.theme) { this.setTheme(App.config.theme); }; }; function ViewManager(App,inKey) { var local = this; var viewtext = new Array(0); var views = new Array(0); var defaultlist = ["s","o","3p"]; var availViews = {o:["outline",Outline],s:["slider",Slider],"3p":["three pane",ThreePane]}; var total=0; function setView(key) { if(key.match(/^\-.*/)) { key=key.replace(/\-/,""); (availViews[key])?availViews[key].block=true:null; } else { if(availViews[key] && !availViews[key].used) { viewtext.push(availViews[key][0]); views.push(key); availViews[key].used=true; total++; }; }; }; if(App.config.view) { var setviews = App.config.view.split(","); for (var i=0; i<setviews.length; i++) { setView(setviews[i]); }; }; for(var i=0; i<defaultlist.length; i++) { if(!availViews[defaultlist[i]].used && !availViews[defaultlist[i]].block) { setView(defaultlist[i]); }; }; if(total<1) { setView("s"); }; if(inKey) { var viewindex = -1; for(var x=0;x<views.length;x++) { (views[x]==inKey)?viewindex=x:null; }; var lastview= viewindex; } else { var viewindex = 0; var lastview=0; }; App.viewer = new availViews[views[viewindex]][1](App); App.frame.getViewport().add(App.viewer); var animEngine2 = new FXengine(20); var indicate = new FXaction(.45); var stopbox = new FXaction(0); var fadein = new FXaction(.25); var fadeout = new FXaction(.25); var removeMenu = new FXaction(0); var LB = new LightBox(viewtext); this.LB = LB; LB.highlight(viewindex); var menu=false; fadein.animFunction = function(frac) { LB.display.style.opacity=1; LB.display.style.filter = "alpha(opacity="+frac*100+")"; }; fadeout.animFunction = function(frac) { LB.display.style.opacity=0; LB.display.style.filter = "alpha(opacity="+(1-frac)*100+")"; }; var anim=false; removeMenu.animFunction = function() { LB.remove(); menu=false; anim=false; }; fadeout.chainTo(removeMenu); this.getViewIndex = function() { return views[viewindex]; }; this.showViewMenu = function() { if(menu && !anim) { LB.remove(); menu=false; } else { LB.show(App.frame.getViewport().display); menu=true; }; }; this.changeViewNum = function(index) { local.changeView(views[index]); }; this.changeView = function(key) { App.confManager.set("view",key); var vi = -1; for(var x=0;x<views.length;x++) { (views[x]==key)?vi=x:null; }; viewindex = vi; if(viewindex == lastview) { return; }; if(viewindex >= 0) { LB.highlight(viewindex,lastview); } else { LB.clearhighlight(lastview); }; lastview = viewindex; App.frame.wait(); var tmp = new availViews[key][1](App); App.viewer.type = tmp.type; App.frame.getViewport().add(tmp); (App.datamanager.rootNode)?tmp.transition(App.datamanager.rootNode):null; var olddim = App.viewer.getNodeDim(); var newdim = tmp.getNodeDim(); var halfway = newdim.Y - (tmp.display.clientHeight/2); tmp.display.scrollTop=halfway; if(tmp.type == "outline") { tmp.setScrollPos({X:0,Y:halfway}); }; olddim.Y = olddim.Y - App.viewer.display.scrollTop; newdim.Y = newdim.Y - tmp.display.scrollTop; App.frame.wait(); App.viewer.clearView(); App.viewer = tmp; var box = document.createElement("div"); box.className="gzghost"; box.style.position="absolute"; box.style.height=olddim.H+"px"; box.style.width=olddim.W+"px"; box.style.top=olddim.Y+"px"; box.style.left=olddim.X+"px"; App.frame.getViewport().display.appendChild(box); indicate.animFunction = function(frac) { frac = 1-(Math.pow(1-frac,3.5)); box.style.height=(olddim.H+(newdim.H-olddim.H)*frac)+"px"; box.style.width=(olddim.W+(newdim.W-olddim.W)*frac)+"px"; box.style.left=(olddim.X+(newdim.X-olddim.X)*frac)+"px"; box.style.top=(olddim.Y+(newdim.Y-olddim.Y)*frac)+"px"; }; stopbox.animFunction = function(frac) { box.parentNode.removeChild(box); App.frame.unwait(); }; indicate.chainTo(stopbox); animEngine2.addAction(indicate); }; }; function FormManager() { var local = this; var results = {}; var formvals = {}; var storedData = {}; this.clearForms = function() { results = {}; formvals = {}; storedData = {}; }; this.getResultNode = function(name) { if(results[name]) { return results[name]; } else { return null; }; }; this.addResultNode = function(name,node) { results[name]=node; }; this.storeFormVals = function(name,elements) { formvals[name] = new Array(); for(var i=0; i<elements.length; i++) { if(elements[i].multiple) { var selectarray = new Array(); selectarray.multiple=true; for(var j=0; j<elements[i].length; j++) { selectarray.push({selected:elements[i][j].selected}); }; formvals[name].push(selectarray); } else { formvals[name].push({value:elements[i].value,checked:elements[i].checked}); }; }; }; this.getFormVals = function(name) { return formvals[name]; }; this.getFormStateObj = function() { return formvals; }; this.storeResults = function(name,data,uri) { storedData[name]=data; }; this.getResults = function(name) { return storedData[name]; }; this.getValues = function(name) { var uri=""; var myForm = document[name]; var elems = myForm.elements; App.forms.storeFormVals(name,elems); var delim="?"; for(var i=0; i<elems.length; i++) { var inputname = elems[i].name; var inputvalue = encodeURIComponent(elems[i].value); inputvalue = inputvalue.replace(/\%20/g,"+"); switch(elems[i].type) { case "radio": if(elems[i].checked == true) { uri+=delim+inputname+"="+inputvalue; delim = "&"; }; break; case "submit": break; case "checkbox": if(elems[i].checked == true) { uri+=delim+inputname+"="+inputvalue; delim = "&"; }; break; default: if(elems[i].multiple) { for(var j=0; j<elems[i].length; j++) { if(elems[i][j].selected) { inputvalue = encodeURI(elems[i][j].value); inputvalue = inputvalue.replace(/\+/g,"%2B"); inputvalue = inputvalue.replace(/\%20/g,"+"); uri+=delim+inputname+"="+inputvalue; delim = "&"; }; }; } else { uri+=delim+inputname+"="+inputvalue; delim = "&"; }; break; }; }; if(results[name] && results[name].display) { App.viewer.resetNode(results[name]); }; uri="grazrscript"+uri; App.datamanager.getData(uri,dataReceive); function dataReceive(receivedOutline,target) { if(results[name] && results[name].display) { var outline = results[name].outline; App.datamanager.setID(receivedOutline,outline.id); App.datamanager.state[outline.id]={}; var state=App.datamanager.state[outline.id]; if(outline.attribute.type=="gzresult") { if(receivedOutline.childNodes[0].outline.attribute.type == "rss-story") { outline.attribute.type="rss"; results[name].enable(); } else { outline.attribute.type="include"; results[name].enable(); }; }; outline.childNodes = receivedOutline.childNodes; state.loaded = true; App.viewer.nodeAction(results[name]); } else { if(receivedOutline.childNodes[0].outline.attribute.type == "rss-story") { receivedOutline.attribute.type="rss"; } else { receivedOutline.attribute.type="include"; }; App.forms.storeResults(name,receivedOutline,uri); }; App.frame.unwait(); }; }; }; function haltBubble(e) { if(e.stopPropagation) { e.stopPropagation(); }; e.cancelBubble=true; }; function keyread(e) { if(!e){var e = window.event}; var code = e.keyCode; if(e.keyCode == 0) { code = e.charCode; }; switch(code) { case 43: code = "plus"; break; case 107: code = "plus"; break; case 187: code = "plus"; break; case 109: code = "minus"; break; case 189: code = "minus"; break; case 45: code = "minus"; break; case 38: code = "up"; break; case 63232: code = "up"; break; case 40: code = "down"; break; case 63233: code = "down"; break; case 39: code = "right"; break; case 63235: code = "right"; break; case 37: code = "left"; break; case 63234: code = "left"; break; case 13: code = "enter"; break; case 33: code = "pgup"; break; case 34: code = "pgdn"; break; default: code = null; break; }; if(code) { if(!App.frame.inkeymode) { App.frame.keymode(true); }; App.viewer.key(code,e); } else { e.gzbubble = true; }; }; function KeyManager(App) { this.typemode = false; var local = this; this.enable= function(arg) { }; function start(arg) { if(arg) { var targ = keyread; } else { var targ = null; }; if(isIE) { regEvent(DomObj(document),"onkeydown",targ); } else { regEvent(DomObj(document),"onkeypress",targ); }; }; start(true); }; function Outline(App) { this.extendGrazr = function(s1, p1, p2) { return eval(s1); }; var local=this; this.display = document.createElement("div"); this.display.style.position="absolute"; this.display.style.height = "100%"; this.display.style.width = "100%"; this.display.style.overflow="auto"; this.type = "outline"; this.currentHL = null; var currentView = null; var currentNode = null; var toplist = null; function expandAll(list) { if(list && list.index) { for(var i=0; i<list.index.length; i++) { var node = list.index[i]; var state = App.datamanager.state[node.outline.id]; var type = node.outline.attribute.type; if(state && !state.expanded && state.loaded && type != "link") { expand(node); }; (node.child)?expandAll(node.child):null; }; }; }; function collapseAll(list) { if(list && list.index) { for(var i=0; i<list.index.length; i++) { var node = list.index[i]; (node.child)?collapseAll(node.child):null; var state = App.datamanager.state[node.outline.id]; var type = node.outline.attribute.type; if(state && state.expanded && type != "link") { collapse(node); }; }; }; }; var exp=false; this.toggleExpansion = function() { if(exp) { setActive(); collapseAll(toplist); local.currentHL=null; currentNode=null; exp = false; } else { expandAll(toplist); exp = true; }; }; this.getNodeDim = function() { if(currentView) { return {X:currentView.display.offsetLeft,Y:currentView.display.offsetTop,H:currentView.display.offsetHeight,W:currentView.display.offsetWidth}; } else { return {X:0,Y:0,H:0,W:0}; }; }; this.setScrollPos = function(obj) { setTimeout(function() { local.display.scrollLeft = obj.X; local.display.scrollTop = obj.Y; }, 22); }; this.getScrollPos = function() { return {X:local.display.scrollLeft,Y:local.display.scrollTop}; }; this.clearView = function() { App.frame.removeButton(expandcollapsebutton); local.clear(); this.display.parentNode.removeChild(this.display); }; this.clear = function() { (toplist)?toplist.destroy():null; (currentView)?currentView=null:null; toplist=null; local.currentHL=null; currentNode=null; }; this.highlight = function(node) { if(local.currentHL && local.currentHL.display) { local.currentHL.display.className = local.currentHL.nodeclass; }; node.display.className="gznodehl"; local.currentHL=node; }; function renderList(gzOutline,target) { var list = new List(gzOutline,target); if(App.datamanager.activeNode == gzOutline) { currentView = list; setActive(list.parent); }; if(App.datamanager.rootNode == gzOutline) { toplist = list; }; for(var i=0, j=gzOutline.childNodes.length; i<j; i++) { if(App.datamanager.state[gzOutline.childNodes[i].outline.id]) { var state = App.datamanager.state[gzOutline.childNodes[i].outline.id]; } else { var state = {}; }; if( state.expanded ) { renderList(gzOutline.childNodes[i].outline,list.index[i]); }; }; if(target) { list.display.className="outline"; target.display.parentNode.insertBefore(list.display,target.display.nextSibling); } else { local.display.appendChild(list.display); }; return list; }; this.resetNode = function(node) { setActive(); var state = App.datamanager.state[node.outline.id]; var type = node.outline.type; if(state && state.expanded && type != "link") { collapse(node); }; }; this.showContent = function(gzOutline,target) { if(!App.datamanager.activeNode) { setActive(); }; (target)?null:target=null; renderList(gzOutline,target); }; var currentNode=null; function setActive(gzNode) { (currentNode)?currentNode.setNodeClass("gznode"):null; if(gzNode) { gzNode.setNodeClass("gznodeactive"); currentNode=gzNode; App.datamanager.activeNode = gzNode.outline; if(gzNode.outline.title) { App.frame.setTitle(gzNode.outline.title); } else { App.frame.setTitle(gzNode.outline.attribute.text); }; } else { App.datamanager.activeNode = App.datamanager.rootNode; App.frame.setTitle(App.datamanager.rootNode.title); currentNode=null; }; }; function load(node) { App.frame.setActive(); App.datamanager.getData(node.myUri,local.insert,node.outline.id,node); }; function expand(node) { var state=App.datamanager.state[node.outline.id]; if(!state.expanded) { local.showContent(node.outline,node); state.expanded=true; }; }; function collapse(node) { var state=App.datamanager.state[node.outline.id]; if(state.expanded) { node.child.destroy(); node.child = null; state.expanded=false; }; }; this.insert = function(outline,target) { var state=App.datamanager.state[outline.id]; if(!state){ App.datamanager.state[outline.id] = {}; state=App.datamanager.state[outline.id]; }; target.outline.childNodes=outline.childNodes; expand(target); state.loaded = true; App.frame.unwait(); }; this.nodeAction = function(gzNode) { var outline = gzNode.outline; var state=App.datamanager.state[outline.id]; var type = gzNode.outline.attribute.type; setActive(gzNode); if(!type) { type = "normal text"; }; if(type == "link") { gzNode.activateLink(); return; }; if(type.match(/^include|rss$/) && !state.loaded ) { load(gzNode); } else { if(state.expanded) { setActive(gzNode.parent.parent); collapse(gzNode); } else { expand(gzNode); }; }; }; this.initReceive = function(outline) { App.datamanager.rootNode = outline; App.datamanager.activeNode = outline; local.showContent(outline); setActive(); App.frame.unwait(); }; this.transition = function(data) { local.clear(); if(typeof data == "object") { App.frame.wait(); App.datamanager.rootNode = data; local.showContent(data); App.frame.unwait(); } else { App.datamanager.state={}; App.frame.setTitle("Loading..."); var uri = data; App.confManager.set("file",uri); App.datamanager.getData(uri,local.initReceive,-1); }; }; this.init = function(data) { App.forms.clearForms(); local.transition(data); }; var expandcollapsebutton = new titleButton("expandcollapse","Expand All / Collapse All"); expandcollapsebutton.addEventListener("onclick",function() { App.viewer.toggleExpansion() }); App.frame.addButton(expandcollapsebutton); this.blinkNode = function(node) { var animEngine = new FXengine(20); var indicate = new FXaction(1.5); var end = new FXaction(0); end.animFunction = function() { node.display.style.background=null; }; indicate.chainTo(end); indicate.animFunction = function(frac) { node.display.style.marginLeft=Math.round(20*Math.sin(Math.PI*frac))+"%"; node.display.style.fontSize=Math.round(100+100*Math.sin(Math.PI*frac))+"%"; node.display.style.background="rgb(255,255,"+Math.round(255*frac)+")"; }; animEngine.addAction(indicate); }; function scrollIntoView(node) { var pos = node.display.offsetTop; var bnd = local.getBoundary(); var margin = 5; var nodebottom = pos+node.display.offsetHeight; if(pos < bnd.min) { local.display.scrollTop=pos-margin; }; if(nodebottom > bnd.max) { local.display.scrollTop=local.display.scrollTop + (nodebottom-bnd.max+margin); }; }; function setHL(node) { var tmpe = {gztarget:node}; return node.highlight(tmpe); }; function useItem(e) { if(local.currentHL) { e.gztarget=local.currentHL; local.currentHL.getData(e); setHL(local.currentHL); }; }; function getPrevActive(tgt) { var node = tgt.getPrevSibling(); while(node && node.outline && App.datamanager.state[node.outline.id] && App.datamanager.state[node.outline.id].expanded && node.child) { node = node.getLastChild(); }; if(!node) { node = tgt.getParent(); }; return node; }; function getNextActive(node) { if(node && node.outline && App.datamanager.state[node.outline.id] && App.datamanager.state[node.outline.id].expanded && node.child) { var target = node.getChild(); } else { var target = node.getNextSibling(); while(!target) { node = node.getParent(); if(!node) { return node; }; target = node.getNextSibling(); }; }; return target; }; function prevItem() { if(!App.viewer.currentHL) { if(this.child) { var target = this.child.index[0]; }; while(target && (target != "end") && !setHL(target)) { target = getNextActive(target); }; } else { setHL(App.viewer.currentHL); var target = getPrevActive(App.viewer.currentHL); while(target && (target != "end") && !setHL(target)) { target = getPrevActive(target); }; if(target) { scrollIntoView(target); }; }; }; function nextItem() { if(!App.viewer.currentHL) { var target = toplist.index[0]; while(target && (target != "end") && !setHL(target)) { target = getNextActive(target); }; } else { setHL(App.viewer.currentHL); var target = App.viewer.currentHL.getNextSibling(); var target = getNextActive(App.viewer.currentHL); while(target && (target != "end") && !setHL(target)) { target = getNextActive(target); }; if(target) { scrollIntoView(target); }; }; }; this.getBoundary = function() { var min = this.display.scrollTop; var max = min + this.display.clientHeight; return {min:min,max:max}; }; this.key = function(code,e) { switch(code) { case "minus": useItem(e); return false; break; case "plus": useItem(e); return false; break; case "enter": useItem(e); return false; break; case "right": useItem(e); return false; case "left": useItem(e); return false; break; case "up": prevItem(); return false; break; case "down": nextItem(); return false; break; default: break; }; }; }; function Slider(App) { this.extendGrazr = function(s1, p1, p2) { return eval(s1); }; var local = this; this.type="slider"; var currentView = null; this.currentHL = null; var list = null; var btnH=16; var outer = new GrazrPanel(); outer.setStyle("height","100%"); outer.setStyle("width","100%"); outer.setStyle("overflow","hidden"); var viewFrame = new GrazrPanel(); viewFrame.setStyle("overflow","hidden"); outer.add(viewFrame); var sliderpanel = new GrazrPanel(); sliderpanel.setStyle("height","100%"); sliderpanel.setStyle("width","100%"); if(isIE) { viewFrame.setStyle("borderLeft",btnH+"px solid #FFFFFF"); viewFrame.setStyle("height","100%"); viewFrame.setStyle("width","100%"); } else { viewFrame.setRect(btnH,0,0,0); }; this.backbutton = new BackButton(); var button = this.backbutton; button.setStyle("height","100%"); button.setStyle("width",btnH+"px"); viewFrame.add(sliderpanel); outer.add(viewFrame); outer.add(button); this.getTopList = function() { return currentView; }; function setHL(node) { var tmpe = {gztarget:node}; if(node.highlight(tmpe)) { local.currentHL = node; return true; } else { return false; }; }; this.useItem = function() { if(local.currentHL) { local.nodeAction(local.currentHL); setHL(local.currentHL); }; }; this.highlight = function(node) { if(local.currentHL) { local.currentHL.display.className = local.currentHL.nodeclass; }; node.display.className="gznodehl"; local.currentHL=node; }; this.insert = function(outline,target) { var state=App.datamanager.state[outline.id]; if (!state) { App.datamanager.state[outline.id]={}; var state=App.datamanager.state[outline.id]; }; state.loaded=true; state.expanded=true; target.outline.childNodes=outline.childNodes; local.showContent(target.outline,1); }; this.nodeAction = function(gzNode) { var outlineNode = gzNode.outline; var state=App.datamanager.state[outlineNode.id]; var type = gzNode.outline.attribute.type; if(type == "link") { gzNode.activateLink(); return; }; if(state.loaded) { App.frame.wait(); state.expanded=true; local.showContent(gzNode.outline,1); } else { App.frame.wait(); App.frame.setActive(); App.datamanager.getData(gzNode.myUri,local.insert,outlineNode.id,gzNode); }; gzNode=null; outlineNode=null; }; function getParent(id) { var map = id.split(/\./); var out=App.datamanager.rootNode; for(var i=1; i<map.length - 1; i++) { (map[i]<0)?out=App.datamanager.rootNode:out = out.childNodes[map[i]].outline; }; return out; }; this.backup = function() { if(currentView.outline != App.datamanager.rootNode) { App.frame.wait(); var lastViewindex = currentView.outline.id.match(/\d+$/); local.showContent(getParent(currentView.outline.id),-1); currentView.index[lastViewindex].setNodeClass("gznodelast"); setHL(currentView.index[lastViewindex]); }; }; var animEngine = new FXengine(40); var slide = new FXaction(.25); var stopWait = new FXaction(0); this.resetNode = function() { return; }; this.showContent = function(outline,direction,target) { if(outline.id == "-1" || outline.id == "-1.-1") { this.backbutton.deactivate(); } else { this.backbutton.activate(); }; if(currentView) { var temp = currentView.container; currentView.destroy(); sliderpanel.remove(temp); local.currentHL=null; currentView=null; temp=null; }; var listdisp = new List(outline,target); var list = new GrazrPanel(); list.add(listdisp); listdisp.container = list; currentView=listdisp; App.datamanager.activeNode=outline; App.frame.setTitle(outline.title); width = sliderpanel.display.clientWidth; height = sliderpanel.display.clientHeight; if(direction != 0 && direction != -1){ direction = 1; }; list.setXY(direction*width,0); list.setHW(height,width); sliderpanel.add(list); list.setStyle("overflow","auto"); var pre = list.display.clientWidth; pre = list.display.clientWidth; list.setStyle("overflow","hidden"); var scroll = sliderpanel.display.scrollTop; sliderpanel.remove(list); list.setHW(height,pre); sliderpanel.add(list); list.display.scrollTop = outline.scrollPos; list.display.scrollTop = outline.scrollPos; slide.animFunction = function(frac) { frac = 1-(Math.pow(1-frac,3.5)); list.setXY(direction*width+(-1*direction)*width*frac,0); }; stopWait.animFunction = function() { list.setStyle("height","100%"); list.setStyle("width","100%"); list.setStyle("overflow","auto"); setTimeout(App.frame.unwait,10); }; slide.chainTo(stopWait); if(direction == 0) { list.setStyle("height","100%"); list.setStyle("width","100%"); list.setStyle("overflow","auto"); } else { animEngine.addAction(slide); }; }; this.display = outer.display; button.addEventListener("onclick",local.backup); this.setScrollPos = function(obj) { setTimeout(function() { currentView.display.parentNode.scrollLeft = obj.X; currentView.display.parentNode.scrollTop = obj.Y; currentView.outline.scrollPos = obj.Y; }, 22); }; this.getScrollPos = function() { if(currentView) { return {X:currentView.display.parentNode.scrollLeft,Y:currentView.display.parentNode.scrollTop}; }; return {X:0,Y:0}; }; this.getNodeDim = function() { if(currentView) { return {X:currentView.display.offsetLeft+btnH,Y:currentView.display.offsetTop,H:currentView.display.parentNode.offsetHeight,W:currentView.display.parentNode.offsetWidth}; } else { return {X:0,Y:0,H:0,W:0}; }; }; this.clear = function() { if(currentView) { currentView.destroy(); }; currentView=null; }; this.clearView = function() { if(currentView) { currentView.destroy(); }; this.display.parentNode.removeChild(this.display); }; function resetId(outline,id) { outline.id = id; if(outline.childNodes) { for(var i=0, j=outline.childNodes.length; i<j; i++) { GZid(outline.childNodes[i].outline,id+"."+i); }; }; }; this.initReceive = function(outline) { App.datamanager.rootNode = outline; App.datamanager.activeNode = outline; local.showContent(outline,1); }; this.transition = function(data) { if(currentView) { currentView.destroy(); currentView = null; }; local.currentHL=null; if(typeof data == "object") { App.frame.wait(); App.datamanager.rootNode = data; if(!App.datamanager.activeNode) { App.datamanager.activeNode = data; }; local.showContent(App.datamanager.activeNode,0); App.frame.unwait(); } else { App.datamanager.state={}; this.backbutton.deactivate(); App.frame.setTitle("Loading..."); var uri = data; App.confManager.set("file",uri); App.frame.wait(); App.frame.setActive(); App.datamanager.getData(uri,local.initReceive,-1); }; }; this.init = function(data) { App.forms.clearForms(); local.transition(data); }; function scrollIntoView(node) { var pos = node.display.offsetTop; var bnd = local.getBoundary(); var margin = 5; var nodebottom = pos+node.display.offsetHeight; if(pos < bnd.min) { currentView.display.parentNode.scrollTop=pos-margin; }; if(nodebottom > bnd.max) { currentView.display.parentNode.scrollTop=currentView.display.parentNode.scrollTop + (nodebottom-bnd.max+margin); }; }; function goBack() { this.backup(); if(local.currentHL) { local.currentHL=null; }; }; function useItem(e) { if(local.currentHL) { e.gztarget=local.currentHL; local.currentHL.getData(e); local.currentHL=null; }; }; function prevItem() { if(!local.currentHL) { var target = currentView.index[0]; while(target && (target != "end") && !setHL(target)) { target = target.getNextSibling(); }; } else { setHL(local.currentHL); var target = local.currentHL.getPrevSibling(); while(target && (target != "end") && !setHL(target)) { target = target.getPrevSibling(); }; if(target) { scrollIntoView(target); }; }; }; function nextItem() { if(!local.currentHL) { var target = currentView.index[0]; while(target && (target != "end") && !setHL(target)) { target = target.getNextSibling(); }; } else { setHL(local.currentHL); var target = local.currentHL.getNextSibling(); while(target && (target != "end") && !setHL(target)) { target = target.getNextSibling(); }; if(target) { scrollIntoView(target); }; }; }; this.getBoundary = function() { var min = currentView.display.parentNode.scrollTop; var max = min + currentView.display.parentNode.clientHeight; return {min:min,max:max}; }; this.key = function(code,e) { switch(code) { case "minus": this.backup(); return false; break; case "plus": useItem(e); return false; break; case "enter": useItem(e); return false; break; case "left": this.backup(); return false; break; case "right": useItem(e); return false; break; case "up": prevItem(); return false; break; case "down": nextItem(); return false; break; default: break; }; }; }; function Viewer() { this.currentHL = null; this.highlight = function(node) { if(this.currentHL) { this.currentHL.unhighlight(currentHL); }; node.display.className="gznodehl"; }; }; function ThreePane(App) { this.extendGrazr = function(s1, p1, p2) { return eval(s1); }; var local=this; this.type="threepane"; this.currentHL = null; var currentView = null; var currentNode = null; var toplist = null; var myRootNode = null; var panel = new ThreePaneFrame(); this.display = panel.getPanel(); var hpanel = panel.getTopPanel(); var spanel = panel.getBotPanel(); var headlineanchor = document.createElement("div"); var headlines = {display:headlineanchor}; hpanel.appendChild(headlineanchor); var storyanchor = document.createElement("div"); var stories = {display:storyanchor}; spanel.appendChild(storyanchor); function expandAll(list) { if(list && list.index) { for(var i=0; i<list.index.length; i++) { var node = list.index[i]; var state = App.datamanager.state[node.outline.id]; var type = node.outline.attribute.type; if(state && !state.expanded && state.loaded && type != "link" && type != "rss") { expand(node); }; (node.child)?expandAll(node.child):null; }; }; }; function collapseAll(list) { if(list && list.index) { for(var i=0; i<list.index.length; i++) { var node = list.index[i]; (node.child)?collapseAll(node.child):null; var state = App.datamanager.state[node.outline.id]; var type = node.outline.attribute.type; if(state && state.expanded && type != "link" && type != "rss") { collapse(node); }; }; }; }; var exp=false; this.toggleExpansion = function() { if(exp) { setActive(); if(currentHeadlines) { if(currentStory) { currentStory.destroy(); currentStory=null; }; local.clearHeadlines(); }; collapseAll(toplist); local.currentHL=null; currentNode=null; exp = false; } else { expandAll(toplist); exp = true; }; }; this.getTopList = function() { return toplist; }; this.highlight = function(node) { if(local.currentHL && local.currentHL.display) { local.currentHL.display.className = local.currentHL.nodeclass; }; node.display.className="gznodehl"; local.currentHL=node; }; this.getNodeDim = function() { var size=null; var p = null; var offset=0; var sp = panel.getSplits(); if(App.datamanager.activeNode) { var type = App.datamanager.activeNode.attribute.type; (type)?null:type="plain"; if(type.match(/rss/)) { p = panel.getBotPanel(); (isIE)?offset=sp.H:null; } else { p = panel.getLeftPanel(); }; return {X:p.offsetLeft+offset,Y:p.offsetTop,H:p.offsetHeight,W:p.offsetWidth}; } else { return {X:0,Y:0,H:0,W:0}; }; }; var currentNodeLeft=null; var currentNodeTop=null; function setActive(gzNode) { if(gzNode) { gzNode.setNodeClass("gznodeactive"); var type = gzNode.outline.attribute.type; (type)?null:type="text"; switch(type) { case "rss-story": if(currentNodeTop!=gzNode) { (currentNodeTop && currentNodeTop.display)?currentNodeTop.setNodeClass("gznode"):null; currentNodeTop=gzNode; if(gzNode.child) { currentView = gzNode.child; }; }; break; case "rss": if(currentNodeLeft!=gzNode) { (currentNodeLeft)?currentNodeLeft.setNodeClass("gznode"):null; currentNodeLeft=gzNode; }; break; default: (currentNodeLeft)?currentNodeLeft.setNodeClass("gznode"):null; currentNodeLeft=gzNode; break; }; App.datamanager.activeNode = gzNode.outline; if(gzNode.outline.title) { App.frame.setTitle(gzNode.outline.title); } else { App.frame.setTitle(gzNode.outline.attribute.text); }; } else { (currentNodeLeft)?currentNodeLeft.setNodeClass("gznode"):null; App.datamanager.activeNode = App.datamanager.rootNode; App.frame.setTitle(App.datamanager.rootNode.title); currentNodeLeft=null; }; }; function renderList(gzOutline,target) { var list = null; var type = gzOutline.attribute.type; (type)?null:type = "normaltext"; if(gzOutline.attribute.text=="Comment Feed") { type="comment"; }; if(target) { if(target.parent.outline.attribute.text=="Comment Feed") { type="comment"; }; }; var tmp = RegExp("^"+gzOutline.id); if(type.match(/^rss|rss-story|comment$/) && App.datamanager.activeNode && !App.datamanager.activeNode.id.toString().match(tmp)) { } else { switch(type) { case "rss": var x = App.datamanager.activeNode; list=local.showHeadlines(gzOutline,target); setActive(target); App.datamanager.activeNode = x; break; case "rss-story": var x = App.datamanager.activeNode; list = local.showStory(gzOutline,target); App.datamanager.activeNode = x; break; case "comment": var x = App.datamanager.activeNode; list = local.showComment(gzOutline,target); App.datamanager.activeNode = x; break; default: if(target) { list = new List(gzOutline,target); list.display.className="outline"; target.display.parentNode.insertBefore(list.display,target.display.nextSibling); if(App.datamanager.activeNode == gzOutline) { (currentNodeLeft!=target)?setActive(target):null; }; } else { list = new List(gzOutline); toplist = list; panel.getLeftPanel().appendChild(list.display); }; }; if(App.datamanager.activeNode == gzOutline) { currentView = list; }; if(myRootNode == gzOutline) { toplist = list; }; if(gzOutline && gzOutline.childNodes) { for(var i=0, j=gzOutline.childNodes.length; i<j; i++) { if(App.datamanager.state[gzOutline.childNodes[i].outline.id]) { var state = App.datamanager.state[gzOutline.childNodes[i].outline.id]; } else { var state = {}; }; if( state.expanded ) { renderList(gzOutline.childNodes[i].outline,list.index[i]); }; }; }; }; return list; }; this.showComment = function(gzOutline,target) { var list = new List(gzOutline,target); if(target) { list.display.className="outline"; target.display.parentNode.insertBefore(list.display,target.display.nextSibling); }; App.datamanager.activeNode = gzOutline; currentView = list; return list; }; var currentStory=null; this.showStory = function(gzOutline,target) { var list = new List(gzOutline,target); if(currentStory) { currentStory.destroy(); currentStory = null; }; list.display.className="botpane"; stories.display.parentNode.insertBefore(list.display,stories.display.nextSibling); stories.display.parentNode.scrollTop = gzOutline.scrollPos+"px"; (currentNodeTop!=list.parent)?setActive(list.parent):null; currentStory = list; return list; }; var currentHeadlines=null; this.showHeadlines = function(gzOutline,target) { var list = null; if((currentHeadlines && currentHeadlines.outline != gzOutline) || !currentHeadlines) { list = new List(gzOutline,target); if(currentHeadlines) { currentHeadlines.destroy(); if(currentStory) { currentStory.destroy(); currentStory=null; }; currentHeadlines = null; }; list.display.className="toppane"; headlines.display.parentNode.insertBefore(list.display,headlines.display.nextSibling); headlines.display.parentNode.scrollTop = gzOutline.scrollPos+"px"; currentHeadlines = list; } else { list = currentHeadlines; }; if(!currentStory) { if(currentStory) { currentStory.destroy(); currentStory=null; }; if(gzOutline.childNodes[0].outline.childNodes) { App.datamanager.state[gzOutline.childNodes[0].outline.id]={loaded:true,expanded:true}; this.showStory(gzOutline.childNodes[0].outline,list.index[0]); }; } else { setActive(currentStory.parent); }; return list; }; var blankoutline={attribute:{title:"dummy",text:"dummy",type:"folder"},childNodes:[{outline:{attribute:{title:"welcome to jasonbentley.org",text:"welcome to jasonbentley.org "}}}]}; this.clearHeadlines = function() { if(currentHeadlines) { currentHeadlines.destroy(); }; var list = new List(blankoutline); currentHeadlines = list; headlines.display.parentNode.insertBefore(list.display,headlines.display.nextSibling); }; this.resetNode = function(node) { setActive(node); var state = App.datamanager.state[node.outline.id]; var type = node.outline.type; if(state && state.expanded && type != "link") { collapse(node); }; }; this.showContent = function(gzOutline,target) { var list; var type = gzOutline.attribute.type; if(gzOutline.attribute.text=="Comment Feed") { type="comment"; }; if(target) { if(target.parent.outline.attribute.text=="Comment Feed") { type="comment"; }; }; switch(type) { case "rss": list = local.showHeadlines(gzOutline,target); break; case "rss-story": list = local.showStory(gzOutline,target); break; case "comment": list = local.showComment(gzOutline,target); break; default: list = renderList(gzOutline,target); break; }; currentView=list; return list; }; this.insert = function(outline,target) { var state=App.datamanager.state[outline.id]; if(!state){ App.datamanager.state[outline.id] = {}; state=App.datamanager.state[outline.id]; }; target.outline.childNodes=outline.childNodes; state.loaded = true; state.expanded = true; if(outline.childNodes && outline.childNodes[0].outline && outline.childNodes[0].outline.attribute.text.match(/Feed file\(s\) found/)) { target.outline.attribute.type="include"; }; if(outline.childNodes && outline.childNodes[0].outline && outline.childNodes[0].outline.attribute.type!="rss-story") { target.outline.attribute.type="include"; }; local.showContent(target.outline,target); App.frame.unwait(); }; this.nodeAction = function(gzNode) { var outline = gzNode.outline; var state=App.datamanager.state[outline.id]; var type = gzNode.outline.attribute.type; if(type == "link") { gzNode.activateLink(); return; }; if(gzNode.outline.attribute.text == "Comment Feed" || (gzNode.parent && gzNode.parent.parent && gzNode.parent.parent.outline.attribute.text == "Comment Feed")) { type = "comment"; } else { setActive(gzNode); }; if(!type) { type = "normal text"; }; if(currentHeadlines) { if(gzNode != currentHeadlines.parent && !(type.match(/^rss-story|comment$/)) ) { if(currentStory) { currentStory.destroy(); currentStory=null; }; local.clearHeadlines(); if(type == "rss" && currentHeadlines) { currentHeadlines.destroy(); currentHeadlines=null; }; }; }; if(type.match(/^include|rss|comment$/) && !state.loaded ) { App.frame.setActive(); App.frame.wait(); App.datamanager.getData(gzNode.myUri,local.insert,outline.id,gzNode); } else { if(state.expanded && !(type.match(/^rss-story|rss$/))) { setActive(gzNode.parent.parent); gzNode.child.destroy(); gzNode.child = null; state.expanded=false; } else { state.expanded=true; local.showContent(gzNode.outline,gzNode); }; }; }; this.setScrollPos = function(obj) { setTimeout(function() { panel.setSplits(obj.split); var l = panel.getLeftPanel(); var t = panel.getTopPanel(); var b = panel.getBotPanel(); l.scrollLeft = obj.lX; l.scrollTop = obj.lY; t.scrollLeft = obj.tX; t.scrollTop = obj.tY; b.scrollLeft = obj.bX; b.scrollTop = obj.bY; }, 22); }; this.getScrollPos = function() { var l = panel.getLeftPanel(); var t = panel.getTopPanel(); var b = panel.getBotPanel(); var sp = panel.getSplits(); return {lX:l.scrollLeft,lY:l.scrollTop,tX:t.scrollLeft,tY:t.scrollTop,bX:b.scrollLeft,bY:b.scrollTop,split:sp}; }; this.clear = function() { if(toplist) { toplist.destroy(); toplist=null; }; if(currentStory) { currentStory.destroy(); currentStory=null; }; if(currentHeadlines) { currentHeadlines.destroy(); currentHeadlines=null; }; }; function resetId(outline,id) { outline.id = id; if(outline.childNodes) { for(var i=0, j=outline.childNodes.length; i<j; i++) { GZid(outline.childNodes[i].outline,id+"."+i); }; }; }; this.initReceive = function(outline) { if(outline.attribute.type=="rss") { var newoutline={attribute:{title:"dummy",text:"dummy",type:"folder"},childNodes:[{outline:outline}],id:"-1"}; resetId(outline,"-1.-1"); App.datamanager.state["-1.-1"]={expanded:true,loaded:true}; myRootNode=newoutline; (App.datamanager.rootNode)?null:App.datamanager.rootNode = outline; (App.datamanager.activeNode)?null:setActive(); local.showContent(newoutline); } else { (App.datamanager.rootNode)?null:App.datamanager.rootNode = outline; myRootNode = outline; (App.datamanager.activeNode && App.datamanager.activeNode.id == "-1")?setActive():null; (App.datamanager.activeNode)?null:setActive(); local.showContent(outline); }; App.frame.unwait(); }; this.transition = function(data) { local.currentHL=null; currentNodeTop=null; currentNodeLeft=null; if(toplist) { toplist.destroy(); }; local.clear(); local.clearHeadlines(); if(typeof data == "object") { App.frame.wait(); local.initReceive(data); } else { App.datamanager.state={}; App.datamanager.activeNode=null; App.datamanager.rootNode=null; App.frame.setTitle("Loading..."); var uri = data; App.confManager.set("file",uri); App.frame.wait(); App.frame.setActive(); App.datamanager.getData(uri,local.initReceive,-1); }; }; this.init = function(data) { App.forms.clearForms(); local.transition(data); }; this.clearView = function() { App.frame.removeButton(expandcollapsebutton); panel.clear(); if(toplist) { toplist.destroy(); }; this.display.parentNode.removeChild(this.display); this.display=null; }; function expand(node) { var state=App.datamanager.state[node.outline.id]; if(!state.expanded) { local.showContent(node.outline,node); state.expanded=true; }; }; function collapse(node) { var state=App.datamanager.state[node.outline.id]; if(state.expanded) { if(node.child) { node.child.destroy(); node.child = null; }; state.expanded=false; }; }; var expandcollapsebutton = new titleButton("expandcollapse","Expand All / Collapse All"); expandcollapsebutton.addEventListener("onclick",function() { App.viewer.toggleExpansion() }); App.frame.addButton(expandcollapsebutton); function setHL(node) { var tmpe = {gztarget:node}; return node.highlight(tmpe); }; function backPanel(e) { (local.currentHL && local.currentHL.parent && local.currentHL.parent == currentHeadlines && local.currentHL.parent.parent)?setHL(local.currentHL.parent.parent):useItem(e); }; function useItem(e) { if(local.currentHL) { e.gztarget=local.currentHL; var state = App.datamanager.state[local.currentHL.outline.id]; var type = local.currentHL.outline.attribute.type; if(type == "rss" || type == "rss-story") { if(!state.loaded) { local.currentHL.getData(e); setHL(local.currentHL); } else { local.currentHL.getData(e); local.nodeAction(local.currentHL); setHL(currentNodeTop); }; } else { local.currentHL.getData(e); setHL(local.currentHL); }; }; }; this.getBoundary = function(panel) { var min = panel.scrollTop; var max = min + panel.clientHeight; return {min:min,max:max}; }; function scrollIntoView(node) { switch(node.parent) { case currentHeadlines: var mypanel = hpanel; break; case currentStory: var mypanel = spanel; break; default: var mypanel = panel.getLeftPanel(); break; }; var pos = node.display.offsetTop; var bnd = local.getBoundary(mypanel); var margin = 5; var nodebottom = pos+node.display.offsetHeight; if(pos < bnd.min) { mypanel.scrollTop=pos-margin; }; if(nodebottom > bnd.max) { mypanel.scrollTop=mypanel.scrollTop + (nodebottom-bnd.max+margin); }; }; function getPrevActive(tgt) { var node = tgt.getPrevSibling(); while(node && node.outline && App.datamanager.state[node.outline.id] && App.datamanager.state[node.outline.id].expanded && node.child && node.outline.attribute.type != "rss" && node.outline.attribute.type != "rss-story") { node = node.getLastChild(); }; if(!node) { if(tgt.parent == currentHeadlines) { node = null; } else { node = tgt.getParent(); }; }; return node; }; function prevItem() { if(!App.viewer.currentHL) { if(this.child) { var target = this.child.index[0]; }; while(target && (target != "end") && !setHL(target)) { target = getNextActive(target); }; } else { setHL(App.viewer.currentHL); var target = getPrevActive(App.viewer.currentHL); while(target && (target != "end") && !setHL(target)) { target = getPrevActive(target); }; if(target) { scrollIntoView(target); }; }; }; function getNextActive(node) { if(node && node.outline && App.datamanager.state[node.outline.id] && App.datamanager.state[node.outline.id].expanded && node.child && node.outline.attribute.type != "rss" && node.outline.attribute.type != "rss-story") { var target = node.getChild(); } else { var target = node.getNextSibling(); while(!target && node.parent != currentHeadlines) { node = node.getParent(); if(!node) { return node; }; target = node.getNextSibling(); }; }; return target; }; function nextItem() { if(!App.viewer.currentHL) { var target = toplist.index[0]; while(target && (target != "end") && !setHL(target)) { target = getNextActive(target); }; } else { setHL(App.viewer.currentHL); var target = App.viewer.currentHL.getNextSibling(); var target = getNextActive(App.viewer.currentHL); while(target && (target != "end") && !setHL(target)) { target = getNextActive(target); }; if(target) { scrollIntoView(target); }; }; }; this.key = function(code,e) { switch(code) { case "minus": useItem(e); return false; break; case "plus": useItem(e); return false; break; case "enter": useItem(e); return false; break; case "right": useItem(e); return false; case "left": backPanel(e); return false; break; case "up": prevItem(); return false; break; case "down": nextItem(); return false; break; default: break; }; }; }; var App = this; this.errorlog=new Array(0); this.render = function() { if(window.grazrstatic) { var startfile=window.grazrstatic; } else { var startfile=null; }; this.confManager = new ConfigManager(); this.style = new StyleManager(); this.datamanager = new DataManager(this); this.forms = new FormManager(); this.frame = new AppFrame(document.getElementById("grazr")); this.keymanager = new KeyManager(this); var child=false; try { if(window.opener && window != window.opener && window.opener.App && window.opener.App.childlaunch) { child=true; window.opener.App.childlaunch=false; }; } catch(er) {}; if(child) { this.viewmanager = new ViewManager(this,window.opener.App.viewmanager.getViewIndex()); this.frame.wait(); this.datamanager.state = {}; var parentState = window.opener.App.datamanager.state; for(id in parentState) { this.datamanager.state[id] = {}; for(value in parentState[id]) { this.datamanager.state[id][value] = parentState[id][value]; }; }; this.datamanager.activeNode = window.opener.App.datamanager.activeNode; var temp = window.opener.App.forms.getFormStateObj(); for(var name in temp) { App.forms.storeFormVals(name,temp[name]); }; this.viewer.transition( window.opener.App.datamanager.rootNode); this.viewer.setScrollPos(window.opener.App.viewer.getScrollPos()); } else { this.viewmanager = new ViewManager(this); if(startfile && startfile[this.config.file]) { var outline = this.datamanager.preprocess(startfile[this.config.file],-1); this.viewer.init(outline); } else { this.viewer.init(this.config.file); }; }; }; this.extendGrazr = function(s1, p1, p2) { return eval(s1); }; }; var App; window.onload = function() { App = new Grazr(); App.render(); }; 
