home *** CD-ROM | disk | FTP | other *** search
/ Ice Age Fan CD 1 / CD1_Scrat.iso / flash / data / game.swf / scripts / com / google / analytics / utils / Environment.as next >
Encoding:
Text File  |  2012-07-04  |  8.0 KB  |  318 lines

  1. package com.google.analytics.utils
  2. {
  3.    import com.google.analytics.core.ga_internal;
  4.    import com.google.analytics.debug.DebugConfiguration;
  5.    import com.google.analytics.external.HTMLDOM;
  6.    import flash.system.Capabilities;
  7.    import flash.system.Security;
  8.    import flash.system.System;
  9.    
  10.    use namespace ga_internal;
  11.    
  12.    public class Environment
  13.    {
  14.       private var _dom:HTMLDOM;
  15.       
  16.       private var _appName:String;
  17.       
  18.       private var _debug:DebugConfiguration;
  19.       
  20.       private var _appVersion:Version;
  21.       
  22.       private var _url:String;
  23.       
  24.       private var _protocol:Protocols;
  25.       
  26.       private var _userAgent:UserAgent;
  27.       
  28.       public function Environment(param1:String = "", param2:String = "", param3:String = "", param4:DebugConfiguration = null, param5:HTMLDOM = null)
  29.       {
  30.          var _loc6_:Version = null;
  31.          super();
  32.          if(param2 == "")
  33.          {
  34.             if(isAIR())
  35.             {
  36.                param2 = "AIR";
  37.             }
  38.             else
  39.             {
  40.                param2 = "Flash";
  41.             }
  42.          }
  43.          if(param3 == "")
  44.          {
  45.             _loc6_ = flashVersion;
  46.          }
  47.          else
  48.          {
  49.             _loc6_ = Version.fromString(param3);
  50.          }
  51.          _url = param1;
  52.          _appName = param2;
  53.          _appVersion = _loc6_;
  54.          _debug = param4;
  55.          _dom = param5;
  56.       }
  57.       
  58.       public function isAIR() : Boolean
  59.       {
  60.          return playerType == "Desktop" && Security.sandboxType.toString() == "application";
  61.       }
  62.       
  63.       public function get screenWidth() : Number
  64.       {
  65.          return Capabilities.screenResolutionX;
  66.       }
  67.       
  68.       public function get playerType() : String
  69.       {
  70.          return Capabilities.playerType;
  71.       }
  72.       
  73.       public function get locationSearch() : String
  74.       {
  75.          var _loc1_:String = _dom.search;
  76.          if(_loc1_)
  77.          {
  78.             return _loc1_;
  79.          }
  80.          return "";
  81.       }
  82.       
  83.       public function get protocol() : Protocols
  84.       {
  85.          if(!_protocol)
  86.          {
  87.             _findProtocol();
  88.          }
  89.          return _protocol;
  90.       }
  91.       
  92.       public function get flashVersion() : Version
  93.       {
  94.          return Version.fromString(Capabilities.version.split(" ")[1],",");
  95.       }
  96.       
  97.       public function get userAgent() : UserAgent
  98.       {
  99.          if(!_userAgent)
  100.          {
  101.             _userAgent = new UserAgent(this,appName,appVersion.toString(4));
  102.          }
  103.          return _userAgent;
  104.       }
  105.       
  106.       public function get languageEncoding() : String
  107.       {
  108.          var _loc1_:String = null;
  109.          if(System.useCodePage)
  110.          {
  111.             _loc1_ = _dom.characterSet;
  112.             if(_loc1_)
  113.             {
  114.                return _loc1_;
  115.             }
  116.             return "-";
  117.          }
  118.          return "UTF-8";
  119.       }
  120.       
  121.       public function get appName() : String
  122.       {
  123.          return _appName;
  124.       }
  125.       
  126.       public function get screenColorDepth() : String
  127.       {
  128.          var _loc1_:String = null;
  129.          switch(Capabilities.screenColor)
  130.          {
  131.             case "bw":
  132.                _loc1_ = "1";
  133.                break;
  134.             case "gray":
  135.                _loc1_ = "2";
  136.                break;
  137.             case "color":
  138.             default:
  139.                _loc1_ = "24";
  140.          }
  141.          var _loc2_:String = _dom.colorDepth;
  142.          if(_loc2_)
  143.          {
  144.             _loc1_ = _loc2_;
  145.          }
  146.          return _loc1_;
  147.       }
  148.       
  149.       private function _findProtocol() : void
  150.       {
  151.          var _loc4_:String = null;
  152.          var _loc5_:String = null;
  153.          var _loc1_:Protocols = Protocols.none;
  154.          if(_url != "")
  155.          {
  156.             _loc4_ = _url.toLowerCase();
  157.             _loc5_ = _loc4_.substr(0,5);
  158.             switch(_loc5_)
  159.             {
  160.                case "file:":
  161.                   _loc1_ = Protocols.file;
  162.                   break;
  163.                case "http:":
  164.                   _loc1_ = Protocols.HTTP;
  165.                   break;
  166.                case "https":
  167.                   if(_loc4_.charAt(5) == ":")
  168.                   {
  169.                      _loc1_ = Protocols.HTTPS;
  170.                   }
  171.                   break;
  172.                default:
  173.                   _protocol = Protocols.none;
  174.             }
  175.          }
  176.          var _loc2_:String = _dom.protocol;
  177.          var _loc3_:String = (_loc1_.toString() + ":").toLowerCase();
  178.          if(_loc2_ && _loc2_ != _loc3_ && Boolean(_debug))
  179.          {
  180.             _debug.warning("Protocol mismatch: SWF=" + _loc3_ + ", DOM=" + _loc2_);
  181.          }
  182.          _protocol = _loc1_;
  183.       }
  184.       
  185.       public function get locationSWFPath() : String
  186.       {
  187.          return _url;
  188.       }
  189.       
  190.       public function get platform() : String
  191.       {
  192.          var _loc1_:String = Capabilities.manufacturer;
  193.          return _loc1_.split("Adobe ")[1];
  194.       }
  195.       
  196.       public function get operatingSystem() : String
  197.       {
  198.          return Capabilities.os;
  199.       }
  200.       
  201.       public function set appName(param1:String) : void
  202.       {
  203.          _appName = param1;
  204.          userAgent.applicationProduct = param1;
  205.       }
  206.       
  207.       ga_internal function set url(param1:String) : void
  208.       {
  209.          _url = param1;
  210.       }
  211.       
  212.       public function get referrer() : String
  213.       {
  214.          var _loc1_:String = _dom.referrer;
  215.          if(_loc1_)
  216.          {
  217.             return _loc1_;
  218.          }
  219.          if(protocol == Protocols.file)
  220.          {
  221.             return "localhost";
  222.          }
  223.          return "";
  224.       }
  225.       
  226.       public function isInHTML() : Boolean
  227.       {
  228.          return Capabilities.playerType == "PlugIn";
  229.       }
  230.       
  231.       public function get language() : String
  232.       {
  233.          var _loc1_:String = _dom.language;
  234.          var _loc2_:String = Capabilities.language;
  235.          if(_loc1_)
  236.          {
  237.             if(_loc1_.length > _loc2_.length && _loc1_.substr(0,_loc2_.length) == _loc2_)
  238.             {
  239.                _loc2_ = _loc1_;
  240.             }
  241.          }
  242.          return _loc2_;
  243.       }
  244.       
  245.       public function get domainName() : String
  246.       {
  247.          var _loc1_:String = null;
  248.          var _loc2_:String = null;
  249.          var _loc3_:int = 0;
  250.          if(protocol == Protocols.HTTP || protocol == Protocols.HTTPS)
  251.          {
  252.             _loc1_ = _url.toLowerCase();
  253.             if(protocol == Protocols.HTTP)
  254.             {
  255.                _loc2_ = _loc1_.split("http://").join("");
  256.             }
  257.             else if(protocol == Protocols.HTTPS)
  258.             {
  259.                _loc2_ = _loc1_.split("https://").join("");
  260.             }
  261.             _loc3_ = int(_loc2_.indexOf("/"));
  262.             if(_loc3_ > -1)
  263.             {
  264.                _loc2_ = _loc2_.substring(0,_loc3_);
  265.             }
  266.             return _loc2_;
  267.          }
  268.          if(protocol == Protocols.file)
  269.          {
  270.             return "localhost";
  271.          }
  272.          return "";
  273.       }
  274.       
  275.       public function set userAgent(param1:UserAgent) : void
  276.       {
  277.          _userAgent = param1;
  278.       }
  279.       
  280.       public function set appVersion(param1:Version) : void
  281.       {
  282.          _appVersion = param1;
  283.          userAgent.applicationVersion = param1.toString(4);
  284.       }
  285.       
  286.       public function get screenHeight() : Number
  287.       {
  288.          return Capabilities.screenResolutionY;
  289.       }
  290.       
  291.       public function get locationPath() : String
  292.       {
  293.          var _loc1_:String = _dom.pathname;
  294.          if(_loc1_)
  295.          {
  296.             return _loc1_;
  297.          }
  298.          return "";
  299.       }
  300.       
  301.       public function get documentTitle() : String
  302.       {
  303.          var _loc1_:String = _dom.title;
  304.          if(_loc1_)
  305.          {
  306.             return _loc1_;
  307.          }
  308.          return "";
  309.       }
  310.       
  311.       public function get appVersion() : Version
  312.       {
  313.          return _appVersion;
  314.       }
  315.    }
  316. }
  317.  
  318.