home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 May / PersonalComputerWorld-May2008-CoverdiscCD.iso / Software / Full / Nero 7 / Installation / Cab / 83AF5E4E.cab / BasicFunctionsEB9FC35B.js next >
Encoding:
JavaScript  |  2006-06-20  |  8.2 KB  |  235 lines

  1.    /////////////////////////////////////////////////////////////
  2.    // Identify page as enabled for Media Center. This avoids a warning dialog to user.
  3.    function IsMCEEnabled()
  4.    {
  5.        return true
  6.    }
  7.  
  8. /////////////////////////////////////////////////////////////////
  9. // Scaling elements for page resize 
  10. function onScaleEvent(vScale)
  11. {
  12.     try
  13.     {
  14.         body.style.zoom=vScale;
  15.         // when page gets resized, reset positions and sizes of focusable elements
  16.         setArray()
  17.     }
  18.     catch(e)
  19.     {
  20.         // ignore error
  21.     }
  22. }
  23.  
  24. var nFullScreen = 0
  25. function backFromFullScreen()
  26. {
  27.     if (nFullScreen == 0)
  28.     {
  29.         nFullScreen = 1
  30.         return false
  31.     }
  32.     else return true
  33. }
  34.  
  35.  
  36. /////////////////////////////////////////////////////////////////
  37. // determine which remote control key the user selected 
  38. // and take appropriate action
  39. function onRemoteEvent(keyChar)
  40. {
  41.     /* Call optional "doOnFocus" function if needed; you can locate this function on the HTML page, and use it to tie some
  42.    custom functionality to a remote-control keypress. If you want to stop onRemoteEvent from moving focus after that, 
  43.    return true in the doOnFocus function to indicate that remote control keypress is already being handled in some other way */
  44.     try
  45.     {
  46.         if (doOnFocus(keyChar) == true) 
  47.         {
  48.             return true;
  49.         }
  50.     }
  51.     catch(e)
  52.     {
  53.         // if doOnFocus function is not present on page, ignore error
  54.     }
  55.     try
  56.     {
  57.     // this switch tests to see which button on the remote is pressed
  58.         switch (keyChar)
  59.         {
  60.         case 38:  // Up button selected
  61.             changeFocus("up");
  62.             break;
  63.  
  64.         case 40:  // Down button selected
  65.             changeFocus("down");
  66.             break;
  67.  
  68.         case 37:  // Left button selected
  69.             changeFocus("left");
  70.             break;
  71.  
  72.         case 39:  // Right button selected
  73.             changeFocus("right");
  74.             break;
  75.  
  76.         case 13:    // Enter button selected, execute link to content/page
  77.             doSelect();
  78.             return true;
  79.             break;
  80.  
  81.         case 8:  // Keyboard Backspace selected
  82.             return false;
  83.             break;
  84.  
  85.         case 166:             // Remote Control Back button selected; Media Center will already perform a Back
  86.             return false;      // navigation when this is pressed, but this case can be used to add additional
  87.             break;             //functionality to Back button
  88.  
  89.         case 33:    // Page up (plus) selected; page-up scrolling menu
  90.             pageUpDown("up");
  91.             return true;
  92.             break;
  93.             
  94.         case 34:    // Page down (minus) selected; page-down scrolling menu
  95.             pageUpDown("down");
  96.             return true;
  97.             break;
  98.  
  99.         default:
  100.             return false;
  101.             // ignore all other clicks
  102.         }
  103.     }
  104.     catch(ex)
  105.     {
  106.         //ignore error
  107.     }
  108.     return true
  109. }
  110.  
  111.     
  112. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  113. // Set background color for Shared Viewport and MCE toolbars that appear when you move mouse
  114. function setBGColor(Color)
  115. {
  116.     try
  117.     {
  118.         window.external.MediaCenter.BGColor = Color
  119.     }
  120.     catch(e)
  121.     {
  122.         // not using Media Center, or attribute not set
  123.     }
  124. }
  125.  
  126. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  127. /* For Media Center 2003 version, test onload event to see if variables are reset; if they are not, this
  128. means that user is returning from some Media Center view, such as full-screen video mode or my TV.
  129. If this is the case, you want to ignore your page's onload event. In the current version of Media Center, 
  130. the page does not fire an onload event when this happens, so this function will not be necessary */
  131.  
  132. var backFromMediaCenter = false
  133. function continueOnloadFunctions()
  134. {
  135.     if (backFromMediaCenter == false) // meaning variable has been reset to its default state
  136.     {
  137.         // set variable to true and return
  138.         backFromMediaCenter = true
  139.         return
  140.     }
  141.     /* otherwise, page variables have not been reset, so you do not want to continue to call
  142.     your page initilizing functions. Return false */
  143.      return false
  144. }
  145.     
  146. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  147. // This function tests to see if you need to open a Viewport for media playback
  148. function needViewport()
  149. {
  150.     // if Shared or Custom Viewport is already visible, return false
  151.     if (window.external.MediaCenter.SharedViewPort.Visible == true || window.external.MediaCenter.CustomViewPort.Visible == true)
  152.     {
  153.         return false
  154.     }
  155.     // if there is no media playing, return false
  156.     if(window.external.MediaCenter.Experience.PlayState == -1) return false
  157.     // otherwise return true
  158.     return true
  159. }
  160.  
  161. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  162. // This function detects what version of Media Center the user is running. It will return year as string, such as "2005"
  163. function showMCEVersion()
  164. {
  165.     try
  166.     {
  167.         var nMajVer = window.external.MediaCenter.MajorVersion
  168.     }
  169.     catch (e)
  170.     {
  171.         return null
  172.     }
  173.     if (nMajVer < 7) return "2004"
  174.     if (nmajVer = 7) return "2005"
  175.     // in case above fails, return null
  176.     return null
  177. }
  178.  
  179. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  180. // This function detects whether user is in a remote session on a Media Center Extender device
  181. // detect whether user is in a remote session on a Media Center Extender device
  182. function IsMCExtender()
  183. {
  184.     try
  185.     {
  186.         // if this is not a console session ...
  187.         if (window.external.MediaCenter.Capabilities.IsConsole == false)
  188.         {
  189.             /* ...then it is either a Media Center Extender session or a traditional Remote Desktop session.
  190.              To tell which type of session it is, check if video is allowed. If video is allowed... */
  191.             if (window.external.MediaCenter.Capabilities.IsVideoAllowed == true)
  192.             {
  193.                 // ... then it is an extender session, so return true    
  194.                 return true
  195.             }
  196.             // Media Center does not allow video in a traditional Remote Desktop session. So if video is not allowed ...
  197.             else
  198.             {
  199.                 /* IsConsole and IsVideoAllowed are both false false, so user is accessing through a traditional Remote 
  200.                 Desktop session, rather than from an extender device. That means that they probably have access to a keyboard 
  201.                 and mouse, but they cannot play video. If your application features video playback, you may want to 
  202.                 adjust your functionality for this user accordingly. 
  203.                 Returning false simply indicates that this is not an Extender session.  */     
  204.                 return false
  205.             }
  206.         }
  207.         else
  208.         {
  209.             // If not, this is a Media Center session on the console PC, so return false
  210.             return false
  211.         }
  212.     }
  213.     catch(e)
  214.     {
  215.         /* If above cause errors, user is probably accessing from a browser outside of Media Center.
  216.         Return false to indicate that it is not an extender session. */
  217.         return false
  218.     }
  219. }
  220.  
  221. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  222. // Function for reloading page
  223.     function reloadPage()
  224.     {
  225.         /* This function refreshes the page, and calls the onScaleEvent function
  226.         to manage resizing of the elements on the page */
  227.         window.location.reload()
  228.         // determine width of page
  229.         var newWidth = body.getBoundingClientRect().right
  230.         // determine how much the page needs to be resized, by comparing page width to 1024
  231.         var sizeAmount = (newWidth/1024)
  232.         // call onScaleEvent function
  233.         onScaleEvent(sizeAmount)
  234.     }
  235.