1 var Ozone = Ozone || {};
  2 /**
  3  * @namespace
  4  * @description Provides OWF utility methods for the widget developer
  5  * 
  6  */
  7 Ozone.util = Ozone.util || {};
  8 
  9 /**
 10  * @description This method informs a widget developer if their widget is running
 11  * in a Container, like OWF
 12  *
 13  * @returns  boolean true if the widget is inside a container, false otherwise.
 14  *
 15  */
 16 Ozone.util.isInContainer = function() {
 17     var inContainer = false;
 18 
 19     //check window.name
 20     if (Ozone.util.parseJson) {
 21         var configParams = Ozone.util.parseWindowNameData();
 22         if (configParams != null
 23                  //is the fact that a json string was in window.name enough to determine the widget is in a container?
 24                 //&& configParams.inContainer
 25                 ) {
 26             inContainer = true;
 27         }
 28     }
 29     return inContainer;
 30 };
 31 
 32 /**
 33  * @description This method informs a widget developer if their widget is running 
 34  * from the OWF or from a direct URL call.
 35  * 
 36  * @returns  boolean true if the widget is inside OWF, false otherwise.
 37  *
 38  */
 39 Ozone.util.isRunningInOWF = function() {
 40     var isInOwf = false;
 41 
 42     //check window.name
 43     if (Ozone.util.parseJson) {
 44         var configParams = Ozone.util.parseWindowNameData();
 45         if (configParams != null && configParams.owf) {
 46             isInOwf = true;
 47         }
 48     }
 49     return isInOwf;
 50 };
 51 
 52 /**
 53  * @private
 54  *
 55  * @description This method takes a string and removes the passed header from the front of it.
 56  * Used to convert a unique id attribute into a id that other functions and objects can use.
 57  * 
 58  * @param {String} id the id attribute value to be manipulated
 59  * @param {String} header the header to be removed from the id
 60  * 
 61  * @returns String the id minus the header. (Ex. parseID('header1', 'header') returns '1')
 62  * 
 63  */
 64 Ozone.util.parseID = function(id, header) {
 65     return id.substring(0, header.length) == header ? id.substring(header.length) : id;
 66 }
 67 
 68 /**
 69  * @description This method returns flash/flex object from dom.
 70  * 
 71  * @returns  flash/flex object from dom
 72  *
 73  */
 74 Ozone.util.getFlashApp = function(id) {
 75     id = id || Ozone.dragAndDrop.WidgetDragAndDrop.getInstance().getFlashWidgetId();
 76     if(!id)
 77         return;
 78     
 79     if (navigator.appName.indexOf ("Microsoft") !=-1) {
 80         return window[id];
 81         }
 82     else {
 83         return document[id];
 84     }
 85 };