/**************************************************************************************************************************** Licensed Materials - Property of IBM BI and PM: QFW © Copyright IBM Corp. 2005, 2010 US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *****************************************************************************************************************************/ var G_QanPrettyPrint = {}; G_QanPrettyPrint.F_OnClick = function( v_elSrc, sFoldingState, sLang ) { for( ; v_elSrc && v_elSrc.className != "selectTitle" && v_elSrc.className != "selectAlias" && v_elSrc.className != "itemDef"; v_elSrc = v_elSrc.parentElement ); if( !v_elSrc ) return; if( v_elSrc.className == "itemDef" ) return this.f_itemDefOnClick( v_elSrc, sLang ); var v_elContent; var v_elHiddenContent; var v_elChild = v_elSrc.parentElement.firstChild; for( ; v_elChild; v_elChild = v_elChild.nextSibling ) { if( v_elChild.className == "content" || v_elChild.className == "selectNest" ) v_elContent = v_elChild; if( v_elChild.className == "collapsed" ) v_elHiddenContent = v_elChild; } if( sFoldingState ) { v_elContent.v_sFolding = (sFoldingState == "open")? null: sFoldingState; } else if( !v_elContent.v_sFolding ) { if( v_elSrc.innerText.toUpperCase() == "FROM" || v_elSrc.innerText.toUpperCase() == "WITH" ) { v_elContent.v_sFolding = "halfOpen"; } else v_elContent.v_sFolding = "closed"; } else if( v_elContent.v_sFolding == "halfOpen" ) v_elContent.v_sFolding = "closed"; else v_elContent.v_sFolding = null; if( !v_elContent.v_sFolding ) { v_elContent.style.display = ""; v_elHiddenContent.style.display = "none"; } else if( v_elContent.v_sFolding == "halfOpen") { for( var iAS = 0; iAS < v_elContent.childNodes.length; ++iAS ) { var v_elItem = v_elContent.childNodes[iAS]; if( v_elItem.className != "item" ) continue; var v_elItemDef = v_elItem.firstChild; if( v_elItemDef.className != "itemDef" ) continue; var v_elAliasedSelect = v_elItemDef.firstChild; if( v_elAliasedSelect.className != "aliasedSelect" ) continue; for( var iA = 0; iA < v_elAliasedSelect.childNodes.length; ++iA ) { var v_elAlias = v_elAliasedSelect.childNodes[iA]; if( v_elAlias.className != "selectAlias" ) continue; this.F_OnClick( v_elAlias, "closed" ); } } } else { v_elContent.style.display = "none"; if( !v_elHiddenContent ) { v_elHiddenContent = v_elContent.document.createElement( "span" ); v_elContent.parentElement.insertBefore( v_elHiddenContent, v_elContent ); v_elHiddenContent.className = "collapsed"; } v_elHiddenContent.style.display = "inline"; } } G_QanPrettyPrint.f_getQanParser = function() { if( !this.f_oQanParser ) this.f_oQanParser = new C_QanParser(); return this.f_oQanParser; } G_QanPrettyPrint.f_getItemExprType = function( v_elSrc, sLang ) { if( sLang == "MDX" ) return "axisDef"; for( ; v_elSrc && v_elSrc.className != "selectBlock"; v_elSrc = v_elSrc.parentElement ); if( !v_elSrc ) return; var v_elTitle = v_elSrc.firstChild; if( !v_elTitle || v_elTitle.className != "selectTitle" ) return; var v_sBlockType = v_elTitle.innerText; if( v_sBlockType.toUpperCase() == "FROM" ) return "fromItemExpr"; else return "itemExpr"; } G_QanPrettyPrint.f_itemDefOnClick = function( v_elSrc, sLang ) { var v_sExprType = this.f_getItemExprType( v_elSrc, sLang ); var v_elChild = v_elSrc.firstChild; for( ; v_elChild; v_elChild = v_elChild.nextSibling ) if( v_elChild.className == v_sExprType ) return; var v_oParser = this.f_getQanParser(); var v_xmlResult = v_oParser.F_TransformBlockToXML( v_elSrc.innerText.F_LTrim(), v_sExprType, sLang ); if( !v_xmlResult.nodeType ) return; v_elSrc.onclick = function() { G_QanPrettyPrint.F_BlockOnClick(); }; v_elSrc.onmouseover = function() { G_QanPrettyPrint.F_BlockOnMouseOver(); }; v_elSrc.onmouseout = function() { G_QanPrettyPrint.F_BlockOnMouseOut(); }; v_elSrc.innerHTML = v_oParser.F_TransformBlockToHTML( v_xmlResult ); } G_QanPrettyPrint.f_getEventSrc = function( v_elSrc ) { return ( event )? event.srcElement: G_QanApp.F_GetLoggingView().event.srcElement; } G_QanPrettyPrint.f_setNextBlockState = function( v_elSrc ) { if( !v_elSrc.state ) v_elSrc.state = "block"; else if( v_elSrc.state == "block" ) /* v_elSrc.state = "closed"; else if( v_elSrc.state == "closed" ) */ v_elSrc.state = null; } G_QanPrettyPrint.f_getBlockEffectiveSrc = function( v_elSrc ) { if( v_elSrc.className != 'binaryOp' && v_elSrc.className != 'fTitle' && v_elSrc.className != 'joinTypeOn' && v_elSrc.className != 'joinType' && v_elSrc.className != 'joinOn' && v_elSrc.className != 'betweenOp' && v_elSrc.className != 'likeOp' && v_elSrc.className != 'paramBlockId' && v_elSrc.className != 'orderBlockId' && v_elSrc.className != 'dimPropTitle' && v_elSrc.className != 'caseOp' && v_elSrc.className != 'when' && v_elSrc.className != 'then' && v_elSrc.className != 'else' ) { return null; } // v_elSrc = this.f_getActiveBlock( v_elSrc ); if( v_elSrc.className != 'when' && v_elSrc.className != 'then' && v_elSrc.className != 'joinOn' && v_elSrc.className != 'else' ) { return v_elSrc.parentElement; } return v_elSrc; } G_QanPrettyPrint.F_BlockOnClick = function() { var v_elSrc = this.f_getEventSrc(); var v_elInitSrc = v_elSrc; v_elSrc = this.f_getBlockEffectiveSrc( v_elSrc ); if( !v_elSrc ) return; this.f_setNextBlockState( v_elSrc ); var v_elChild = v_elSrc.firstChild; for( ; v_elChild; v_elChild = v_elChild.nextSibling ) { if( !v_elChild.style || v_elChild == v_elInitSrc ) continue; if( !v_elSrc.state ) { v_elChild.style.width = ""; v_elChild.style.overflow = ""; v_elChild.style.height = ""; v_elChild.style.paddingTop = ""; v_elChild.style.backgroundColor = ""; v_elChild.style.marginLeft = ""; v_elChild.style.marginRight = ""; v_elChild.style.borderBottom = ""; v_elChild.style.borderLeft = ""; v_elChild.style.borderRight = ""; v_elChild.style.display = ""; v_elChild.style.paddingLeft = ""; } else if( v_elSrc.state == "block" ) { v_elChild.style.display = "block"; v_elChild.style.paddingLeft = "1em"; } else if( v_elSrc.state == "closed" ) { v_elChild.style.width = "1em"; v_elChild.style.height = "0.5em"; v_elChild.style.overflow = "hidden"; v_elChild.style.paddingTop = "3em"; v_elChild.style.backgroundColor = "#F7F7F7"; v_elChild.style.marginLeft = "2px"; v_elChild.style.marginRight = "2px"; v_elChild.style.borderBottom = "#777777 1px solid"; v_elChild.style.borderLeft = "#777777 1px solid"; v_elChild.style.borderRight = "#777777 1px solid"; v_elChild.style.display = "inline"; } } } G_QanPrettyPrint.f_getActiveBlock = function( v_elSrc ) { var v_elActive = v_elSrc; for( ; v_elActive.className == "unaryOp" || v_elActive.className == "binaryOp" || v_elActive.className == "unaryOp" || v_elActive.className == "joinType" || v_elActive.className == "joinTypeOn"|| v_elActive.className == "paramBlockId"|| v_elActive.className == "orderBlockId"|| v_elActive.className == "fTitle"|| v_elActive.className == "qnames"; ) { v_elActive = v_elActive.parentElement; } return (v_elActive)? v_elActive: v_elSrc; } G_QanPrettyPrint.F_BlockOnMouseOver = function() { this.f_blockHightlight("#DDDDDD"); } G_QanPrettyPrint.F_BlockOnMouseOut = function() { this.f_blockHightlight( "" ); } G_QanPrettyPrint.f_blockHightlight = function(sColor ) { var v_elSrc = this.f_getEventSrc(); var v_elInitSrc = v_elSrc; v_elSrc = this.f_getBlockEffectiveSrc( v_elSrc ); if( !v_elSrc ) return; var v_elChild = v_elSrc.firstChild; for( ; v_elChild; v_elChild = v_elChild.nextSibling ) { if( !v_elChild.style || v_elChild == v_elInitSrc || v_elChild == v_elInitSrc.parentElement) { continue; } v_elChild.style.backgroundColor = sColor; } }