OSDN Git Service

FIX: NP_AttachをNucleus 3.65/PHP5.4/MySQL5.5で動作するよう修正
[nucleus-jp/nucleus-plugins.git] / NP_TreeMenu / trunk / treemenu / ua.js
1 /*
2  * $Log: not supported by cvs2svn $
3  * Revision 1.9  2002/07/22 14:06:21  bc6ix
4  * fix license path, change version reporting to use 2 digits for each level
5  *
6  * Revision 1.8  2002/07/07 08:23:07  bc6ix
7  * fix line endings
8  *
9  * Revision 1.7  2002/05/14 16:52:52  bc6ix
10  * use CVS Log for revision history
11  *
12  *
13  */
14
15 /* ***** BEGIN LICENSE BLOCK *****
16  * Licensed under Version: MPL 1.1/GPL 2.0/LGPL 2.1
17  * Full Terms at http://bclary.com/lib/js/license/mpl-tri-license.txt
18  *
19  * Software distributed under the License is distributed on an "AS IS" basis,
20  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
21  * for the specific language governing rights and limitations under the
22  * License.
23  *
24  * The Original Code is Netscape code.
25  *
26  * The Initial Developer of the Original Code is
27  * Netscape Corporation.
28  * Portions created by the Initial Developer are Copyright (C) 2001
29  * the Initial Developer. All Rights Reserved.
30  *
31  * Contributor(s): Bob Clary <bclary@netscape.com>
32  *
33  * ***** END LICENSE BLOCK ***** */
34
35 function xbDetectBrowser()
36 {
37   var oldOnError = window.onerror;
38   var element = null;
39
40   window.onerror = null;
41   
42   // work around bug in xpcdom Mozilla 0.9.1
43   window.saveNavigator = window.navigator;
44
45   navigator.OS    = '';
46   navigator.version  = parseFloat(navigator.appVersion);
47   navigator.org    = '';
48   navigator.family  = '';
49
50   var platform;
51   if (typeof(window.navigator.platform) != 'undefined')
52   {
53     platform = window.navigator.platform.toLowerCase();
54     if (platform.indexOf('win') != -1)
55       navigator.OS = 'win';
56     else if (platform.indexOf('mac') != -1)
57       navigator.OS = 'mac';
58     else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1)
59       navigator.OS = 'nix';
60   }
61
62   var i = 0;
63   var ua = window.navigator.userAgent.toLowerCase();
64   
65   if (ua.indexOf('safari') != -1)
66   {
67     i = ua.indexOf('safari');
68     navigator.family = 'safari';
69     navigator.org = 'safari';
70     navigator.version = parseFloat('0' + ua.substr(i+7), 10);
71   }
72   else if (ua.indexOf('opera') != -1)
73   {
74     i = ua.indexOf('opera');
75     navigator.family  = 'opera';
76     navigator.org    = 'opera';
77     navigator.version  = parseFloat('0' + ua.substr(i+6), 10);
78   }
79   else if ((i = ua.indexOf('msie')) != -1)
80   {
81     navigator.org    = 'microsoft';
82     navigator.version  = parseFloat('0' + ua.substr(i+5), 10);
83     
84     if (navigator.version < 4)
85       navigator.family = 'ie3';
86     else
87       navigator.family = 'ie4'
88   }
89   else if (ua.indexOf('gecko') != -1)
90   {
91     navigator.family = 'gecko';
92     var rvStart = ua.indexOf('rv:');
93     var rvEnd   = ua.indexOf(')', rvStart);
94     var rv      = ua.substring(rvStart+3, rvEnd);
95     var rvParts = rv.split('.');
96     var rvValue = 0;
97     var exp     = 1;
98
99     for (var i = 0; i < rvParts.length; i++)
100     {
101       var val = parseInt(rvParts[i]);
102       rvValue += val / exp;
103       exp *= 100;
104     }
105     navigator.version = rvValue;
106
107     if (ua.indexOf('netscape') != -1)
108       navigator.org = 'netscape';
109     else if (ua.indexOf('compuserve') != -1)
110       navigator.org = 'compuserve';
111     else
112       navigator.org = 'mozilla';
113   }
114   else if ((ua.indexOf('mozilla') !=-1) && (ua.indexOf('spoofer')==-1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera')==-1)&& (ua.indexOf('webtv')==-1) && (ua.indexOf('hotjava')==-1))
115   {
116     var is_major = parseFloat(navigator.appVersion);
117     
118     if (is_major < 4)
119       navigator.version = is_major;
120     else
121     {
122       i = ua.lastIndexOf('/')
123       navigator.version = parseFloat('0' + ua.substr(i+1), 10);
124     }
125     navigator.org = 'netscape';
126     navigator.family = 'nn' + parseInt(navigator.appVersion);
127   }
128   else if ((i = ua.indexOf('aol')) != -1 )
129   {
130     // aol
131     navigator.family  = 'aol';
132     navigator.org    = 'aol';
133     navigator.version  = parseFloat('0' + ua.substr(i+4), 10);
134   }
135   else if ((i = ua.indexOf('hotjava')) != -1 )
136   {
137     // hotjava
138     navigator.family  = 'hotjava';
139     navigator.org    = 'sun';
140     navigator.version  = parseFloat(navigator.appVersion);
141   }
142
143   window.onerror = oldOnError;
144 }
145
146 xbDetectBrowser();
147