123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- /****************************************************************************************************************************
- 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;
- }
- }
|