MINI MINI MANI MO

Path : /opt/oracle/product/18c/dbhomeXE/rdbms/xml/em/scripts/
File Upload :
Current File : //opt/oracle/product/18c/dbhomeXE/rdbms/xml/em/scripts/shell.js

/* Copyright (c) 2012, 2018, Oracle and/or its affiliates. 
All rights reserved.*/
/*---------------------------------------------------------------------------
                               Global Setting   
--------------------------------------------------------------------------*/

// the server info object
var _serverInfo;

// initial menu states
var menuItem = 0;
var mainMenuItem = 0;
var clicked = 0;

// a AJAX request object
var request;

// locale
var locale = "en_US";
var resourceModuleURLs;
var parentUrl = "";

var emxShell = false;

// true when we are loading a swf. Swf is loaded the first time around
var loadingSwf = true;

var xmlvar = "";

//window can support event listener 
if(window.addEventListener)
{
  // determine event type (special case for firefox)
  var eventType = (navigator.userAgent.indexOf('Firefox') !=-1) ? "DOMMouseScroll" : "mousewheel";
  
  // listen to mouse wheel events
  window.addEventListener(eventType, handleWheel, false);
}

// for active report only: register event listener for receving messages from parent frame 
if (emMode == "active_report")
{
  if (typeof window.addEventListener != 'undefined') 
  { 
    window.addEventListener("message", messageReceivedFromParent, false);
  }
  else if (typeof window.attachEvent != 'undefined') 
  { 
    window.attachEvent("onmessage", messageReceivedFromParent);
  }
}

/*---------------------------------------------------------------------------
                                       Utilities  
---------------------------------------------------------------------------*/

/*
 *  This function returns the Flex flash application
 * 
 *  Parameters:
 *       none
 */
function getFlashApp()
{
  // get the embedded flash object
  var flashApp;
  if (navigator.appName.indexOf ("Microsoft") != -1)
  {
    flashApp = window["emExpressFlash"];
  } 
  else 
  {
    flashApp = document["emExpressFlash"];
  }
  
  return(flashApp);
}

/*---------------------------------------------------------------------------
                Support for mouse wheel (which does not work  
  ---------------------------------------------------------------------------*/

/*
*  This is called when using the mouse wheel
*
*  Parameters:
*       target    - top level menu item
*       subMenuId - sub menu to be opened during mouse over
*/
function handleWheel(event) 
{
  // ignore that event if we are currently loading a swf
  if (loadingSwf)
    return;

  // get flashApp
  var flashApp = getFlashApp();
  
  // compute event arguments
  var edelta = (navigator.userAgent.indexOf('Firefox') !=-1) ? -event.detail : event.wheelDelta/40;
  var mouseWheelArg = {x: event.screenX, 
                       y: event.screenY, delta: edelta,
                       ctrlKey: event.ctrlKey, 
                       altKey: event.altKey, 
                       shiftKey: event.shiftKey};

  try 
  {
    // call Flex with to trigger mousewheel event 
    flashApp.handleMouseWheel(mouseWheelArg);
  }
  catch (error)
  {
    // #13914689: errors can happen when ing swf, do not alert
  }
}

/*---------------------------------------------------------------------------
                          Functions for Menu Interactions
  ---------------------------------------------------------------------------*/

/*
 *  This is called when mousing over the top level menu item
 *
 *  Parameters:
 *       target    - top level menu item
 *       subMenuId - sub menu to be opened during mouse over
 */
function mainMenuMouseOver(target, subMenuId)
{
  // reset previously highlighted menu item
  if (mainMenuItem)
    mainMenuItem.style.background="url('image/t.gif')";

  // if already clicked on a menu item, automatically open the sub menu
  // during mouseover.  This is the same as if clicking on the menu item
  if (clicked)
  {
    openMenu(target, subMenuId);
  }
  // if not, just highlight the menu item
  else
  {
    mainMenuItem = target;
    mainMenuItem.style.background="url('image/menuButtonBackgroundMouseOver.png') repeat-x";
  }
}

/*
 *  This is called when mouse is moved away from the top level menu item
 *
 *  Parameters:
 *       target    - top level menu item
 */
function mainMenuMouseOut(target)
{
  // when no sub menu is opened, moving mouse away will de-highlight the 
  // previously selected menu item
  if (!clicked)
  {
    if (mainMenuItem)
      mainMenuItem.style.background="url('image/t.gif')";
  }
}

/*
 *  This is called when mousing over the sub menu item
 *
 *  Parameters:
 *       target    - sub menu item
 */
function subMenuMouseOver(target)
{
  // highlight the sub menu item
  target.style.backgroundColor = '#C1E6FF';
}

/*
 *  This is called when mouse is moved away from the sub menu item
 *
 *  Parameters:
 *       target    - sub menu item
 */
function subMenuMouseOut(target)
{
  // de-highlight the sub menu item when mouse moved away
  target.style.backgroundColor = 'white';
}

/*
 *  This is called when clicking on a top level menu item
 *
 *  Parameters:
 *       target    - top level menu item
 *       subMenuId - sub menu to be opened after the click
 */
function mainMenuClick(target, subMenuId)
{
  // set the menu state
  clicked = !(clicked);
  if (clicked)
    openMenu(target, subMenuId);
  else
    resetMenu();

}

/*
 *  This function will open a sub menu
 *
 *  Parameters:
 *       target    - top level menu item
 *       subMenuId - sub menu to be opened after the click
 */
function openMenu(target, subMenuId)
{
  // update top level menu item color after the click
  mainMenuItem = target;
  mainMenuItem.style.background="url('image/menuButtonBackgroundMouseDown.png') repeat-x";

  // close existing open submenu
  if(menuItem) 
    menuItem.style.visibility = 'hidden';

  // open new submenu
  menuItem = document.getElementById(subMenuId);
  if (menuItem)
    menuItem.style.visibility = 'visible';
}

/*
 *  This function will close any opened sub menu and reset
 *  menu state when clicking outside the menu
 *
 *  Parameters:
 *       event - the onclick event
 */
function closeMenu(event)
{

  // if clicked on anywhere other than menu reset all menu states

  var targetId;

  // for Internet Explorer, since event is not passed in IE
  if (!event)
  {
    // now get the event from windows.event in IE
    event = window.event;
    // get the id of the element user clicked on
    if (event && event.srcElement)
    {
      targetId = event.srcElement.id;
    }
  }
  // for all other browsers
  else
  {
    if (event.target)
    {
      // get the id of the element user clicked on
      targetId = event.target.id;
    }
  }

  // if user clicked on anything other than menu item (top level or sub menu)
  // close any open menu and reset all menu states
  if (!targetId || (!(targetId.indexOf("menuItem") >= 0)
                   && !(targetId.indexOf("subMenuItem") >= 0)))
  {
    resetMenu();
  }
}

/*
 *  This function will reset all menu states
 *
 *  Parameters:
 *       none
 */
function resetMenu()
{
  // reset top level menu state
  if (mainMenuItem)
  {
    mainMenuItem.style.background="url('image/t.gif')";
    mainMenuItem = 0;
  }

  // reset sub menu state
  if (menuItem)
  {
    menuItem.style.visibility = 'hidden';
    menuItem = 0;
  }

  // reset menu click state
  clicked = 0;
}


/*
 *  This function will open a new browser tab for help menu item
 *
 *  Parameters:
 *       help url
 */
function openHelpMenu(helpUrl)
{
  var browser = getBrowserType();

  if (browser == "IE")
  {
    window.open(helpUrl);
  }
  else
  {
    window.open(helpUrl, '_blank', '');
  }
  
}


/*---------------------------------------------------------------------------
                          Functions for Navigation
  ---------------------------------------------------------------------------*/


/*
 *  This function is called to navigate to an EM Express URL
 *  An EM Express URL looks like: 
 *         /em/shell#/<component>/<report>?parameters
 *  For example, for SQL Monitor List page which has component name
 *  "sqlmonitor", report name "list", and no parameter, the URL looks like:
 *         /em/shell#/sqlmonitor/list
 *
 *  This function could be called from EM Express Shell, via user clicking a 
 *  menu item, or from inside a Flex application when user is trying to 
 *  navigate away from the current application to a new Flex application.
 *
 *  This function sets a 1ms timeout and calls a helper function to do the 
 *  actual navigation after the timeout. The timeout ensures that if 
 *  navigation comes from inside a Flex application, the control is given back
 *  to the browser to navigate to a different swf file by updating the swf
 *  file source of the embedded flash object. 
 * 
 *  Parameters:
 *       url - The new EM Express URL to navigate to
 */
function navigateToUrl(url)
{
  // set location to the new url, this will trigger hashChanged event
  location = url;
}

/*
 *  This function is called to  the current swf file to another swf file.
 *  Since this function is called from Flex. we cannot execute the  right
 *  away. So perform to  using an event which will be processed by the
 *  browser directly   
 *
 *  Parameters:
 *       swfUrlPrefix   - URL Prefix for the new SWF file
 *       swfParams      - new Flex application parameters (flashvars)
 */
function switchSwf(swfUrlPrefix, swfParams)
{
  // show loading indicator
  startSwfLoadingIndicator();

  // set a 1ms timeout before doing the actual navigation
  setTimeout("switchSwfHelper('" + swfUrlPrefix + "', '" + swfParams + "');", 1);
}

function switchSwfHelper(swfUrlPrefix, swfParams)
{  
  // append the cacing number of em_express connected mode 
  if (emMode == "em_express")
  { 
    // check get extension position 
    var fileExtPos = swfUrlPrefix.lastIndexOf(".");

    if (fileExtPos != -1)
    {
      fileExt = swfUrlPrefix.slice(fileExtPos, swfUrlPrefix.length);
      swfUrlPrefix = swfUrlPrefix.replace(fileExt, cachingNumberStr + fileExt);    
    }
  }

  var flashHtml = document.getElementById("flashApp").innerHTML;

  // var swfFile   = urlPrefix + swfUrlPrefix + "/report.swf";  // full name
  var swfFile = swfUrlPrefix;  // full name including swf file  

  // trying to match: src="<anything that is not a quotation mark>"
  var swfFileRegStr = 'src="[^"]*"';
  var swfFileReg = new RegExp(swfFileRegStr, "gi");
  var newFlashHtml;
  newFlashHtml = flashHtml.replace(swfFileReg, 'src="'+swfFile+'"');

  var swfFileRegStrIE = '<param name="movie" value="[^"]*"';
  var swfFileRegIE = new RegExp(swfFileRegStrIE, "gi");
  newFlashHtml = newFlashHtml.replace(swfFileRegIE, 
       '<param name="movie" value="'+swfFile+'"');

  var swfFileRegStrIE2 = '<param name="src" value="[^"]*"';
  var swfFileRegIE2 = new RegExp(swfFileRegStrIE2, "gi");
  newFlashHtml = newFlashHtml.replace(swfFileRegIE2, 
       '<param name="src" value="'+swfFile+'"');

  var swfVarsRegStr = 'flashvars="[^"]*"';
  var swfVarsReg = new RegExp(swfVarsRegStr, "gi");

  var swfVarsRegStrIE = '<param name="FlashVars" value="[^"]*"';
  var swfVarsRegIE = new RegExp(swfVarsRegStrIE, "gi");

  // parameters for the flash application
  var flashParams = "em_express=true";

  // add locale parameters if they are specified
  // alert("shell.js SwfHelper() locale="+locale + ", resourceModuleURLs: " + 
  // resourceModuleURLs);
 
  // get resource bundle base url, the part of the url before "/em/"
  // this is used for constructing the url for resource bundles
  // for active report only
  var resourceBaseUrl = "";
  if (emMode == "active_report")
  {
    resourceBaseUrl = window.location.pathname;
    resourceBaseUrl = resourceBaseUrl.substring(0, resourceBaseUrl.indexOf("/em/"));
  }
  
  if (locale != null && locale != "" && resourceModuleURLs != null && resourceModuleURLs != "")
    flashParams = flashParams + '&online=true&localeChain=' + locale +
      '&resourceModuleURLs=' + resourceBaseUrl + resourceModuleURLs;

  // add active report
  if (emMode == "active_report")
    flashParams = flashParams + '&active_report=true';

  // add accessibility information
  if ((_serverInfo != null) && (_serverInfo.accessibilityMode == "true"))
    flashParams = flashParams + '&accessibility=true';

  // finally add the parameters for the swf, if any
  if ((swfParams != null) && (swfParams != ""))
    flashParams = flashParams + '&' + swfParams;

  // dynamically change tag
  newFlashHtml = newFlashHtml.replace(swfVarsReg, 'flashvars=' + '"' + flashParams + '"');
  newFlashHtml = newFlashHtml.replace(swfVarsRegIE,
                                      '<param name="FlashVars" value="' + flashParams + '"');

  // replace flashApp tag
  document.getElementById("flashApp").innerHTML = newFlashHtml;
}


/*
 *  This function let Flex code know that the hash part of the URL has been changed.
 *  This will trigger a UI refresh (see DBUrlNavigator.handleWindowHashChanged() method) 
 * 
 *  Parameters:
 *       none
 */
function hashChanged()
{
  // get the embedded flash object
  var flashApp = getFlashApp();

  try 
  {
    // call registered callback "handleWindowHashChanged" on this flash object
    // this callback is registered in the action script of this flex app 
    flashApp.handleWindowHashChanged();
  }
  catch (error)
  {
    // ignore, probably some bootstarp issues
    // alert("shell.js hashChanged ... error:  " + error ); 
  }

}

/*
 *  This function logs out the current user. It does the following:
 *  1. sends an async request to the server asking it to obsolete the current 
 *     session
 *  2. on the client side, if an EM Express cookie exists, cleans the cookie 
 *     by setting the EMXSESSIONID cookie to empty
 *  3. redirect user to login
 * 
 *  Parameters:
 *       none
 */
function logout()
{
  // send logout command to server to clean cookie in the server
  createRequest();
  if (request)
  {
    var url = "/em/doLogout";
    request.open("POST", url, true);
    request.send(null);
  }
  
  // redirect to login, but allow this logout request to process for 0.5 sec
  setTimeout("logoutRedirect();", 500);

  return false;
}

/*
 *  This function redirects user to login page after logout
 * 
 *  Parameters:
 *       none
 */
function logoutRedirect()
{
  // redirect to login
  window.location = "/em/login";  
}

/*
 *  This function helps to create an AJAX request object. The create request
 *  is currently used by logout only, but any function can use it to send a 
 *  request to server to obtain some information behind the scene.
 * 
 *  Parameters:
 *       none
 */
function createRequest() 
{
  // creating a new AJAX request
  try 
  {
    request = new XMLHttpRequest();
  }
  catch (trymicrosoft) 
  {
    try 
    {
      request = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (othermicrosoft) 
    {
      try 
      {
        request = new ActiveXObject("Microsoft.XMLHTTP");
      } 
      catch (failed) 
      {
        request = false;
      }
    }
  }

  if (!request)
    alert("Can not create AJAX request!");
}


/*---------------------------------------------------------------------------
                      Functions for Information on Shell
  ---------------------------------------------------------------------------*/

/*
 *  This function is called by Shell.swf to update EM Express shell with 
 *  server information from Shell.swf flex app
 * 
 *  Parameters:
 *       svrInfo - server information collected by Flex application Shell
 */
function updateServerInfo(serverInfo)
{
  // alert("updateServerInfo.serverInfo="+serverInfo); 

  // update emxShell flag to indicate a real em express shell is used
  emxShell = true;

  // update serverInfo variable
  if (serverInfo != null)
  {
    updateShell(serverInfo);
  }
}

/*
 * This function is called by the swf application (from AppContext) to fetch the part of the
 * HTML which embbeds the XML report for the active report
 *
 * Returns
 *   Strin containing the active report
 */
function getActiveReportString()
{

  // get fxtmodel
  //var ret = document.getElementById("fxtmodel").innerHTML + '';
  var ret = xmlvar;
  // return result
  return(ret);
}


/*
 * This function is called in em.html to load the first swf file 
 * with the right parameters depending on whether we are producing 
 * an active report, flex ide page, or em express page 
 *
 * Parameters:
 *    none
 */
function loadAppSwf()
{
  // default flash vars
  var flash_vars;

  // default swf file to load
  var default_swf_src;

  // Major version of Flash required
  var requiredMajorVersion = 10;

  // Minor version of Flash required
  var requiredMinorVersion = 0;

  // Minor version of Flash required
  var requiredRevision = 124;

  // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
  var hasProductInstall = DetectFlashVer(10, 0, 0);
      
  // Version check based upon the values defined in globals
  var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

  // load swf file and set flash_vars based on emMode 
  if (emMode == "active_report")
  { 
    // this is an active report. The XML report is embeded. 
    // get it into a local variable  
    var url_xml = 'em_express=true&active_report=true';

    // if running from ide, use flexIdeSwf
    if (flexIdeSwf == "${swf}")
      default_swf_src = "swf/emxShell";
      //default_swf_src = 'orarep/sqlmonitor/SqlMonitor.swf';
    else
      default_swf_src = flexIdeSwf;
      
    flash_vars = url_xml;
  }     
  else if (emMode == "flex_ide") 
  {
    // this is in fact flex ide
    default_swf_src = flexIdeSwf;
    flash_vars = "flex_ide=1";
  }
  else 
  {
    // this is em express connected to a backend  
    // use exm_cachin_number for the file name so that it can be cached
    // this is needed because the file does not have an extension otherwise, 
    // we do not need to include the constant. 
    default_swf_src = "swf/emxShell_c" + caching_number;
    flash_vars = "em_express=true&caching=" + caching_number;
  }

  // NOTE: please note that to be able to use em.html for both em express and
  //       active reports and also because we wanted em.html to be empty,
  //       i.e., all the work is performed inside loadCompleted(), 
  //       we had to change AC_FL_RunContent to use dom innerHTML
  //       of a specific node/element of em.html instead of document.write().
  //  
  //       Here are two main reasons we cannot use document.write anymore:
  //         1. document.write() is called inside a script tag and 
  //            therefore writes the string in exactly where the script tag 
  //            is located in the html document. 
  //         2. when document.write() is called after the page load 
  //            is completed, it overrides the body of the document.   
  if (hasProductInstall && !hasRequestedVersion)
  {
    // DO NOT MODIFY THE FOLLOWING FOUR LINES
    // Location visited after installation is complete if installation is required
    var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
      var MMredirectURL = window.location;
    document.title = document.title.slice(0, 47) + " - Flash Player Installation";
    var MMdoctitle = document.title;
      AC_FL_RunContent(
    "src", "playerProductInstall",
    "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
    "width", "100%",
    "height", "100%",
    "align", "middle",
    "id", "emExpressFlash",
    "quality", "high",
    "bgcolor", "#FFFFFF",
    "name", "emExpressFlash",
    "allowscriptaccess","sameDomain",
    "type", "application/x-shockwave-flash",
    "pluginspage", "http://www.adobe.com/go/getflashplayer"
      );
  }
  else if (hasRequestedVersion)
  {
    // if we've detected an acceptable version
    // embed the Flash Content SWF when all tests are passed
    AC_FL_RunContent("src", default_swf_src,
         "width", "100%",
         "height", "100%",
         "align", "middle",
         "id", "emExpressFlash",
         "quality", "high",
         "bgcolor", "#FFFFFF",
         "name", "emExpressFlash",
         "flashvars", flash_vars,
         "allowScriptAccess","sameDomain",
         "wmode", "transparent",
         "type", "application/x-shockwave-flash",
         "pluginspage", "http://www.adobe.com/go/getflashplayer");    
  }
  else
  {  // flash is too old or we can't detect the plugin
    var alternateContent = 'Alternate HTML content should be placed here. '
      + 'This content requires the Adobe Flash Player. '
      + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
    document.write(alternateContent);   // insert non-flash content
  }
}

/*
 * This function is used to set the header of the em.html file
 * Parameters: 
 *       emMode: em mode which is either em_express, active_report, 
 *               or flex_ide
 */
function addEMBrandingHeader(emMode)
{
  var _body = document.getElementsByTagName("body")[0];
  // FIXME: db release should not hard-coded
  var pageHeader = ""; //"Database Express 12c"; 
  
  // change page header title if active report 
  if (emMode == "active_report")
    pageHeader = "Database Active Report"; 
  
  var text = '<!-- EM branding header --> ' +  
      '<table cellpadding="0" cellspacing="0" border="0" summary=""> ' +
      '<tbody> ' +
        '<tr id="emHeaderTbodyTr"> ' +
          '<!-- upper left: logo and brand name --> ' +
          '<td style="width: 100%; "> ' +
            '<div id="emHeader:branding" style="overflow: hidden; padding: 5px 0px 3px 10px;"> ' +
                  '<img id="emHeader:logo" title="Oracle" alt="Oracle"  ' +
                  ' style="border:0;" src="image/OracleLogo.png"/> ' +
                  '<a id="emHeader:em" class="emFont1" onclick="return false;">Enterprise Manager</a> ' +
                  '<a id="emHeader:dbExpress" class="emFont2" onclick="return false;">' +pageHeader+ '</a> ' +
            '</div> ' +
          '</td> ' +
        '</tr> ' +
      '</tbody> ' +
    '</table>';

  // create header element and insert it into the body as first tag/child-element
  var header = document.createElement("div");
  header.setAttribute("id", "emHeader");
  header.innerHTML = text;
  document.body.appendChild(header);

  // add a dummy table just to add a line (separator) after the page header,
  // but only for active report mode. In all other cases the sparator will 
  // be added a part of adding the menu bar
  if (emMode == "active_report")
  {
    text = '<!-- dummy table  --> ' +
      '<table cellpadding="0" cellspacing="0" border="0" summary="" style="padding-left:6px; padding-top:4px;"> ' +
      '<tr/></table> ';

    // create header element  
    header = document.createElement("div"); 
    header.setAttribute(getAttributeClass(), "menuBarBackground");
    header.innerHTML = text; 

    // insert start Menu just after header   
    //document.body.insertBefore(header, _body.childNodes[1]);
  }
}


/*
 * Return the right attribute name based on the browser type.
 * 
 * Parameters:
 *     none 
 */
function getAttributeClass()
{
  // get the browser type
  var browser = getBrowserType();
  
  // return the right attribute name based on the browser type
  return ((browser == "IE") ? "className" : "class"); 
}


/*
 * This function runs the flash application 
 * 
 * Parameters:
 *     none 
 */
function runFlashApp()
{
  var _body = document.getElementsByTagName("body")[0];
  var text = '<!-- Flash application --> ' +
    '<center id="flashAppContent"> ' +
      '<!--  load the application swf file with the rigth argument --> ' +
    '</center>';

  // create a new td element and add it at the end of the html body  
  var div = document.createElement("div"); 
  div.setAttribute("id", "flashApp");

  var swfBorderStyle = "swfBorder";
  if (emMode == "active_report")
    swfBorderStyle = "activeReportSwfBorder";
     
  div.setAttribute(getAttributeClass(), swfBorderStyle);
  
  div.setAttribute("onmousedown", "closeMenu();");
  div.innerHTML = text; 
  _body.appendChild(div); 

  // insert the script tag to run loadAppSwf
  var ss = document.createElement('script');
  ss.setAttribute("language", "JavaScript");
  ss.setAttribute("type", "text/javascript");
  ss.text = 'loadAppSwf();' ;
  //ss.appendChild(document.createTextNode('loadAppSwf();'));
  var _element = document.getElementById('flashAppContent');
  _element.appendChild(ss);

  // insert the no-script tag 
  var noss = document.createElement('noscript');
  text = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' +
      'id="emExpressFlashObj"  ' +
                        'width="100%" ' +
                        'height="100%" ' +
      'codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> ' +
      '<param name="movie" value="swf/emxShell.swf" /> ' +
      '<param name="quality" value="high" /> ' +
      '<param name="bgcolor" value="#FFFFFF" /> ' +
                        '<param name="wmode" value="transparent"> ' +
      '<param name="allowscriptaccess" value="sameDomain" /> ' +
      '<embed id="emExpressFlash" ' +
                               'src="swf/emxShell.swf"  ' +
                               'bgcolor="#FFFFFF" ' +
             'width="100%" height="100%" ' +
                   'name="emExpressFlash"  ' +
                               'flashvars="em_express=true" ' +
                               'align="middle" ' +
                               'play="true" ' +
             'loop="false" ' +
             'quality="high" ' +
                               'wmode="transparent" ' +
             'allowscriptaccess="sameDomain" ' +
             'type="application/x-shockwave-flash" ' +
             'pluginspage="http://www.adobe.com/go/getflashplayer"> ' +
      '</embed> ' +
   '</object> ';

  noss.text = text;
  _element.appendChild(noss);
}

/* 
 * This function is called when the parent html in active report
 * mode communicates with the child iframe (em.html).  Upon receiver
 * of the message, it'll get the xml from the message payload and
 * load the flash app
 */
function messageReceivedFromParent(event)
{
  xmlvar = event.data;
  loadFinished();
}
 
/*
 * This function is called when the html finishes loading
 */
function loadCompleted()
{
  // only when we are in flex ide, and serverInfo is not set
  // we use default hard-coded value to fill in shell
  // for static testing only

  // add document header, but only if active report
  // mode. Otherwise, the page header is added in 
  // function updateShell 

  // register any click on the screen to closeMenu for
  // closing the menu when clicking on a space outside menu    
  document.onclick=closeMenu;

  // add document header 
  addEMBrandingHeader(emMode);

  // add start Menu
  startMenuBar(emMode);

  // add the loading spinner 
  generateSwfLoadingIndicator();

  if (emMode != "active_report")
  {
    loadFinished();
  }
}

function loadFinished()
{
  // run the flash application  
  runFlashApp();

  if (emMode == "flex_ide")
  {
    _serverInfo = {
      dbStatus : "ACTIVE",
      featureMenus :
      [
        {
          icon: "configure_qualifier.png",
          label: "Configuration",
          label_untranslated: "GLOB_CONFIG",
          type: "menu",
          menuItems: 
          [
           {
            component: "config",
            label: "Initialization Parameters",
            label_untranslated: "GLOB_INITIALIZATION_PARAMETERS",
            report: "show_params",
            type: "report" 
           },
           {
            component: "memory",
            label: "Memory",
            label_untranslated: "GLOB_MEMORY",
            report: "show_memory",
            type: "report"
           },
           {
            component: "config",
            label: "Database Feature Usage",
            label_untranslated: "GLOB_DATABASE_FEATURE_USAGE",
            report: "show_feature_usage",
            type: "report" 
           },
           {
            component: "config",
            label: "Current Database Properties",
            label_untranslated: "GLOB_CURRENT_DATABASE_PROPERTIES",
            report: "show_db_props",
            type: "report"
           },
           {
             component: "rsrcmgr",
             label: "Resource Management",
             label_untranslated: "GLOB_RESOURCE_MANAGEMENT",
             report: "show_dashboard",
             type: "report"
            }
          ]
        },
        {
          icon: "dbagent_qualifier.png",
          label: "Storage",
          label_untranslated: "GLOB_STORAGE",
          type: "menu",
          menuItems: 
          [
           {
            component: "storage",
            label: "Tablespaces",
            label_untranslated: "GLOB_TABLESPACES",
            report: "show_tablespaces",
            type: "report"
           },
           {
            component: "storage",
            label: "Undo Management",
            label_untranslated: "GLOB_UNDO_MANAGEMENT",
            report: "show_undo_details",
            type: "report"
           },
           {
            component: "storage",
            label: "Redo Log Groups",
            label_untranslated: "GLOB_REDO_LOG_GROUPS",
            report: "show_redolog_files",
            type: "report"
           },
           {
            component: "storage",
            label: "Archive Logs",
            label_untranslated: "GLOB_ARCHIVE_LOGS",
            report: "show_archlog_files",
            type: "report"
           },
           {
            component: "storage",
            label: "Control Files",
            label_untranslated: "GLOB_CONTROL_FILES",
            report: "show_control_files",
            type: "report"
           }
          ]
        },
        {
          icon: "admin_ena.png",
          label: "Security",
          label_untranslated: "GLOB_SECURITY",
          type: "menu",
          menuItems: 
          [
           {
            component: "security",
            label: "Users",
            label_untranslated: "GLOB_USERS",
            report: "show_users",
            type: "report"
           },
           {
            component: "security",
            label: "Roles",
            label_untranslated: "GLOB_ROLES",
            report: "show_roles",
            type: "report"
           },
           {
            component: "security",
            label: "Profiles",
            label_untranslated: "GLOB_PROFILES",
            report: "show_profiles",
            type: "report"
           }
          ]
        },
        {
          icon: "stock_qualifier.png",
          label: "Performance",
          label_untranslated: "GLOB_PERFORMANCE",
          type: "menu",
          menuItems: 
          [
           {
            component: "perf",
            label: "Performance Hub",
            label_untranslated: "GLOB_PERFORMANCE_HUB",
            report: "main",
            type: "report"
           },
           {
            component: "sqltune",
            label: "SQL Tuning Advisor",
            label_untranslated: "GLOB_SQLTUNING_ADVISOR",
            report: "task_list",
            type: "report"
           },
           {
            component: "sqlpa",
            label: "SQL Performance Analyzer",
            label_untranslated: "GLOB_SQL_PERFORMANCE_ANALYZER",
            report: "task_list",
            type: "report"
           }
         ]
        }
      ],
      frameworkMenus : [
        {
          label : "Help",
          label_untranslated: "GLOB_HELP",
          menuItems : [
            {
              action : "openHelpMenu('https://docs.oracle.com');",
              actionLink: "https://docs.oracle.com",
              label : "Oracle Online Documentation",
              label_untranslated: "EMX_ONLINE_DOC",
              type : "action"
            },
            {
              action : "openHelpMenu('https://forums.oracle.com/forums/main.jspa?categoryID=84');",
              actionLink: "https://forums.oracle.com/forums/main.jspa?categoryID=84",
              label : "Oracle Online Forums",
              label_untranslated: "EMX_ONLINE_FORUM",
              type : "action"
            },
            {
              action : "openHelpMenu('http://www.oracle.com/technetwork/oem/grid-control/overview/index.html');",
              actionLink: "http://www.oracle.com/technetwork/oem/grid-control/overview/index.html",
              label : "Oracle Technology Network",
              label_untranslated: "EMX_ONLINE_OTN",
              type : "action" 
            }
          ],
          type : "menu"
        }
      ],    
      host : null,
      dbName : "DB2",
      instanceName : "db2",
      isRac : "NO",
      locale : "en_US",
      otherShellMessages : {
        home_label : "Home",
        logout : "Log Out",
        page_refreshed : "Page Refreshed",
        dbType : "Single Instance"
      },
      resourceModuleURLs : "",
      status : "OPEN",
      userName : "SYSTEM",
      version : "12.1.0.0.0",
      instCount : "0",
      accessibilityMode: "false",
      largeFonts: "false",
      cdbContainerName: "CDB1_PDB1",
      cdbContainerID: "0",
      appRoot: "NO",
      managementPack: "2"
    };

    updateShell(_serverInfo);
  }
  // otherwise, set the right size of the flash app
  else 
    sizeFlashapp();
}


/*
 *  This function returns the server info object generated by the 
 *  EM Express Shell application.
 *
 */
function getServerInfo()
{
  // return the serverInfo Object
  return _serverInfo;
}


/*
 *  This function updates the EM Express shell UI with the server info
 *  The server info could be coming from EM Express Shell application, which 
 *  loads the shell information from the server, or it could come from a static
 *  variable when testing in flex ide after the onLoad event happens
 *
 *  Parameters:
 *       serverInfo - server information collected by Flex application Shell
 */
function updateShell(serverInfo)
{
  // remember the serverInfo
  _serverInfo = serverInfo;

  // DB name
  var dbName = serverInfo.dbName;

  // host name
  var host = serverInfo.host;

  // DB version
  var version = serverInfo.version;

  //Bug-26848489: Update the version in the EM Branding bar
  if (version) {
    document.getElementById('emHeader:dbExpress').innerHTML = "Database Express " + version;
  }
  else {
    document.getElementById('emHeader:dbExpress').innerHTML = "Database Express 12c";     
  }

  if (serverInfo.isStandby == "YES")
	  version = serverInfo.version + ", standby"; 

  // status
  var status = serverInfo.status;

  // RAC or not
  var isRac = serverInfo.isRac;

  // DB status
  var dbStatus = serverInfo.dbStatus;

  // currently logged in user name
  var userName = serverInfo.userName;
  
  // cdb container id and name
  var conId = serverInfo.cdbContainerID;
  var conName = serverInfo.cdbContainerName;
  
  // logout 
  var logout;
  
  // home label  
  var homeLabel;

  // database type label
  var dbType;

  // other messages 
  if (serverInfo.otherShellMessages != undefined)
  {
    logout = (serverInfo.otherShellMessages.logout);
    homeLabel = serverInfo.otherShellMessages.home_label;
    dbType = serverInfo.otherShellMessages.dbType;
  }

  // check if database is cdb, if it is, also check if it's a non-root pdb
  var isCDB = (conId != null && conName != null &&
               conId != undefined && conName != undefined && 
               conId != '0');  // is a cdb
  var isPDB = (isCDB && conId != '1');  // non-root pdb

  // check if database is rac
  var isRAC = (isRac != null && isRac != undefined && isRac != 'NO'); 

  // full database name text we display in shell
  var dbNameFull = dbName;

  // dbname +/- cdb informatin
  // if in non-root PDB, add conName to db name
  if (isPDB)
  {  
    dbNameFull = dbNameFull + " / " + conName;
  }

  // only display first 20 characters of the db name
  var dbNameShort = dbNameFull;
  if (dbNameFull != null && dbNameFull.length > 20)
  {
    dbNameShort = dbNameFull.substring(0, 20) + "...";
  }

  // dbname +/- rac information 
  if (isRAC)
  {
    dbNameFull = dbNameFull + " (" + version + " " + dbType + ")";
    dbNameShort = dbNameShort + " (" + version + " " + dbType + ")";
  }
  else
  {
    dbNameFull = dbNameFull + " (" + version + ")";
    dbNameShort = dbNameShort + " (" + version + ")";
  }


  // only display first 20 characters of the user name
  var userNameShort = userName;
  if (userName != null && userName.length > 20)
  {
    userNameShort = userName.substring(0, 20) + "...";
  }

  // database type icon and label
  var dbIcon;
  if (isCDB && isRAC)
  {
    dbIcon = "image/rac_cdb.png";
  }
  else if (serverInfo.appRoot == "YES") {
    dbIcon = "image/application_pdb_star.png";
  }
  else if (isCDB)
  {
    dbIcon = "image/database_cdb.png";
  }
  else if (isRAC)
  {
    dbIcon = "image/rac.png";
  }
  else
  {
    dbIcon = "image/database_ena.png";
  }

  // local  
  if (serverInfo.locale != null && serverInfo.locale != "")
  {
    locale = serverInfo.locale;
    
    // set the "lang" attribute in em.html 
    document.documentElement.lang=locale;

    if (locale != "en_US")
      locale = locale + ",en_US";
  }

  // resource module urls 
  resourceModuleURLs = serverInfo.resourceModuleURLs;

  // find out if we're in accessibility mode
  var accessibilityMode = (serverInfo.accessibilityMode == "true");

  // if we're not in accessibility mode
  if (!accessibilityMode)
  {

    // update shell
    if (emMode != "active_report")
    {
      document.getElementById("emxShell:logout").innerHTML = logout;
      document.getElementById("emxShell:dbName").innerHTML = dbNameShort;
      document.getElementById("emxShell:dbName").title = dbNameFull;
      document.getElementById("emxShell:hostName").innerHTML = host;
      document.getElementById("emxShell:userName").innerHTML = userNameShort;
      document.getElementById("emxShell:userName").title = userName;
      document.getElementById("emxShell:dbIcon").title=dbType;
      document.getElementById("emxShell:dbIcon").alt=dbType;
      document.getElementById("emxShell:dbIcon").src=dbIcon;

      // update feature menu  
      document.getElementById("emxShell:featureMenuBar").innerHTML = 
        generateFeatureMenuBar(serverInfo.featureMenus, homeLabel);

    }

    // update the framework menu. 
    // note for active report, the freameworkMenus is used for local/language menu
    document.getElementById("emxShell:frameworkMenuBar").innerHTML = 
      generateFrameworkMenuBar(serverInfo.frameworkMenus);

  }
  // otherwise
  else
  {
    // hide the chrome
    document.getElementById("emHeader").style.display = "none";
    document.getElementById("startMenuBar").style.display = "none";
  }
   
  // if we are called from emx shell swf, pretend that the url has changed. This will trigger us to navigate
  // to the correct swf file
  // Don't do anything if not in EM Express shell
  // as the handleWindowHashChanged callback won't be there
  // Also don't do anything if in Flex IDE, as emxShell will be false anyway for all apps except for emExpressShell
  // When testing emExpressShell from IDE connecting to backend, we don't want to keep calling hashChanged()
  // and navigating back to shell
  if (emxShell == true && emMode == "em_express")
  {
    hashChanged();
  }

  // there is a dependency between sizeFlashapp() and serverInfo, so we need
  // to call sizeFlashapp() again if flexIde is false
  sizeFlashapp();
  
  // if the user is using large fonts, load the large font CSS
  if (_serverInfo.largeFonts == "true")
    loadLargeFontsCSS();
}

/*
 *  This function loads the large fonts CSS (only called if the user is using large fonts).
 *
 */
function loadLargeFontsCSS()
{
  // construct a link element for the large fonts CSS
  var largeFontsCSSLink = document.createElement('link');
  largeFontsCSSLink.id = 'shellStyleSheet';
  largeFontsCSSLink.rel = 'stylesheet';
  largeFontsCSSLink.type = 'text/css';
  largeFontsCSSLink.href = 'shell_largefont.css';
  
  // add it to the "head" tag
  var head = document.getElementsByTagName('head')[0];
  head.appendChild(largeFontsCSSLink);
}

/*
 *  This function is called by Flex application to indicate that an xml load
 *  has started. It then starts spinning the status icon by replacing it with 
 *  an animated image.
 * 
 *  Parameters:
 *       isSynchronous - whether the request is synchronous or not
 */
function swfStartXmlLoad()
{
  // set the status icon to the spinning version
  document.getElementById("emxShell:loadingStatus").setAttribute("src", "image/connecting.gif"); 
}

/*
 *  This function is called by Flex application to indicate that an xml load
 *  has completed. It then stops spinning the status icon by replacing it with
 *  a non-animated image. It also updates the last refreshed time.
 * 
 *  Parameters:
 *       stopTime - time when the xml load has completed
 */
function swfStopXmlLoad(stopTime)
{
  // set the status icon to the non-spinning version
  document.getElementById("emxShell:loadingStatus").setAttribute("src", "image/connected.png"); 
}


/*
 *  This function returns the browser type
 * 
 *  Parameters:
 *       none
 */
function getBrowserType()
{
  var browser;
            
  // get browser useragent info.
  var browserAgent = navigator.userAgent;
        
  // Determines brand of browser using a find index. If not found indexOf returns (-1).
  if(browserAgent != null && browserAgent.indexOf("Firefox") >= 0) 
  {
    browser = "Firefox";
  } 
  else if(browserAgent != null && browserAgent.indexOf("Chrome") >= 0) 
  {
    browser = "Chrome";
  } 
  else if(browserAgent != null && browserAgent.indexOf("Safari") >= 0)
  {
    browser = "Safari";
  }             
  else if(browserAgent != null && browserAgent.indexOf("MSIE") >= 0)
  {
    browser = "IE";
  }         
  else if(browserAgent != null && browserAgent.indexOf("Opera") >= 0)
  {
    browser = "Opera";
  }
  else 
  {
    browser = "Undefined";
  }

  return (browser);
}

/*
 *  This function is a utility function that returns the current height of the browser window
 * 
 *  Parameters:
 *       none
 */
function getWindowHeight()
{
  var windowHeight = 0;

  // if window.innerWidth is defined, use it
  if (typeof(window.innerHeight ) == 'number')
  {
    // not IE...
    windowHeight = window.innerHeight;
  }
  else if (document.documentElement &&
           (document.documentElement.clientWidth 
            || document.documentElement.clientHeight))
  {
    //IE 6 + others in 'standards compliant mode'
    windowHeight = document.documentElement.clientHeight;
  }
  else if (document.body &&
           (document.body.clientWidth || document.body.clientHeight))
  {
    // IE 4 compatible
    windowHeight = document.body.clientHeight;
  }

  return windowHeight;
}

/*
 *  This function resizes the flash object as browser window is being resized
 * 
 *  Parameters:
 *       none
 */
function sizeFlashapp()
{
  // first get browser window height
  var windowHeight        = getWindowHeight();
  var flexWindowHeight    = 0;
  var flexWindowWidth     = 0;
  
  // find out if we're in accessibility mode
  var inAccessibilityMode = (_serverInfo != null) && 
    (_serverInfo.accessibilityMode == "true");

  if (windowHeight > 0)
  {
    // compute Flex region height acounting for the height of the chrome (menues...).
    // the goal is to remove any scroll bars
    var chromeHeight = 64;
    if (inAccessibilityMode)
      chromeHeight = 0;
    else if (emMode == "active_report")
      chromeHeight = 37;
    flexWindowHeight = windowHeight - chromeHeight;
  }
  else
    flexWindowHeight=0;

  // if we're in accessibility mode    
  if (inAccessibilityMode)
  {
    // hardcode the height and width to reasonably large numbers; this is necessary to 
    // make sure all the content is accessible via the browser scrollbar in accessibility
    flexWindowHeight = 900;
    flexWindowWidth = 1600;
    
    // change the overflow style from "hidden" to "auto"; if we 
    // don't do this, we won't see the browser scrollbar
    document.body.style.overflow = "auto";
  }
  
  // get the flash elements whose dimensions (width and height) need to be set
  var elemFlashApp = document.getElementById('flashApp');
  var elemEMExpressFlash = document.getElementById('emExpressFlash');
  var elemEMExpressFlashObj = document.getElementById('emExpressFlashObj');
  
  // if the flash elements have been added to the page, set their heights
  if (elemFlashApp)
    elemFlashApp.style.height = flexWindowHeight;
  if (elemEMExpressFlash)
    elemEMExpressFlash.height = flexWindowHeight;
  if (elemEMExpressFlashObj)
    elemEMExpressFlashObj.height = flexWindowHeight;
  
  // if we're in accessibility mode and flexWindowWidth is non-zero, 
  // set the width of the flash elements
  if (inAccessibilityMode && (flexWindowWidth != 0) && elemFlashApp)
    elemFlashApp.style.width = flexWindowWidth;
}

/*
 *  This function starts spinning a loading icon to indicate that a swf file is being loaded
 * 
 *  Parameters:
 *       none
 */
function startSwfLoadingIndicator()
{
  // we are now loading a swf
  loadingSwf = true;

  if (document.getElementById('emxShell:loading'))
    document.getElementById('emxShell:loading').style.display = 'block';
}

/*
 *  This function stops spinning a loading icon to indicate that a swf file has been loaded
 * 
 *  Parameters:
 *       none
 */
function stopSwfLoadingIndicator()
{
  // not loading a swf anymore
  loadingSwf = false;

  if (document.getElementById('emxShell:loading'))
    document.getElementById('emxShell:loading').style.display = 'none';
}

/*
 *  This function generates the HTML code for the spinner that indicates a swf file is loading
 * 
 *  Parameters:
 *       none
 */
function generateSwfLoadingIndicator()
{
  var spinnerHtml = "";
  var browser = getBrowserType();

  // create the div element 
  var div = document.createElement("div"); 
  div.setAttribute("id", "emxShell:loading");

  if (browser != "Safari")
  {
    spinnerHtml += "  <table style='width: 100%; height: 100%' border='0' cellspacing='0' cellpadding='0'>";
    spinnerHtml += "    <tr>";
    spinnerHtml += "      <td align='center' valign='middle'>";
    spinnerHtml += "        <img id='emxShell:loadingImage' src='image/ring_60.gif' alt='Loading...'/>";
    spinnerHtml += "      </td>";
    spinnerHtml += "    </tr>";
    spinnerHtml += "  </table>";

  }
  else
  {
    div.style.position = "fixed";
    div.style.top = "50%";
    div.style.left = "50%";
    spinnerHtml += "  <center>";
    spinnerHtml += "    <img id='emxShell:loadingImage' src='image/ring_60.gif' alt='Loading...'/>";
    spinnerHtml += "  </center>";
  }

  // set div inner html and add it to the body in the third position 
  div.innerHTML = spinnerHtml;    
  var _body = document.getElementsByTagName("body")[0];
  document.body.appendChild(div);
}

OHA YOOOO