~jstys-z/helioviewer.org/client5

« back to all changes in this revision

Viewing changes to help/browser.html

  • Committer: Keith Hughitt
  • Date: 2012-05-29 13:44:18 UTC
  • mfrom: (402.4.52 hv)
  • Revision ID: keith.hughitt@nasa.gov-20120529134418-td0ckwaw3rb7nems
Merged in downstream changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html>
 
2
<html lang='en'>
 
3
<head>
 
4
    <title>Helioviewer.org - Browser Diagnostics</title>
 
5
    <meta charset="utf-8" />
 
6
    <script type='text/javascript' src='http://code.jquery.com/jquery.min.js'></script>
 
7
    <script type='text/javascript'>
 
8
        // http://www.quirksmode.org/js/detect.html
 
9
        var BrowserDetect = {
 
10
                init: function () {
 
11
                        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
 
12
                        this.version = this.searchVersion(navigator.userAgent)
 
13
                                || this.searchVersion(navigator.appVersion)
 
14
                                || "an unknown version";
 
15
                        this.OS = this.searchString(this.dataOS) || "an unknown OS";
 
16
                },
 
17
                searchString: function (data) {
 
18
                        for (var i=0;i<data.length;i++) {
 
19
                                var dataString = data[i].string;
 
20
                                var dataProp = data[i].prop;
 
21
                                this.versionSearchString = data[i].versionSearch || data[i].identity;
 
22
                                if (dataString) {
 
23
                                        if (dataString.indexOf(data[i].subString) != -1)
 
24
                                                return data[i].identity;
 
25
                                }
 
26
                                else if (dataProp)
 
27
                                        return data[i].identity;
 
28
                        }
 
29
                },
 
30
                searchVersion: function (dataString) {
 
31
                        var index = dataString.indexOf(this.versionSearchString);
 
32
                        if (index == -1) return;
 
33
                        return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
 
34
                },
 
35
                dataBrowser: [
 
36
                        {
 
37
                                string: navigator.userAgent,
 
38
                                subString: "Chrome",
 
39
                                identity: "Chrome"
 
40
                        },
 
41
                        {       string: navigator.userAgent,
 
42
                                subString: "OmniWeb",
 
43
                                versionSearch: "OmniWeb/",
 
44
                                identity: "OmniWeb"
 
45
                        },
 
46
                        {
 
47
                                string: navigator.vendor,
 
48
                                subString: "Apple",
 
49
                                identity: "Safari",
 
50
                                versionSearch: "Version"
 
51
                        },
 
52
                        {
 
53
                                prop: window.opera,
 
54
                                identity: "Opera",
 
55
                                versionSearch: "Version"
 
56
                        },
 
57
                        {
 
58
                                string: navigator.vendor,
 
59
                                subString: "iCab",
 
60
                                identity: "iCab"
 
61
                        },
 
62
                        {
 
63
                                string: navigator.vendor,
 
64
                                subString: "KDE",
 
65
                                identity: "Konqueror"
 
66
                        },
 
67
                        {
 
68
                                string: navigator.userAgent,
 
69
                                subString: "Firefox",
 
70
                                identity: "Firefox"
 
71
                        },
 
72
                        {
 
73
                                string: navigator.vendor,
 
74
                                subString: "Camino",
 
75
                                identity: "Camino"
 
76
                        },
 
77
                        {               // for newer Netscapes (6+)
 
78
                                string: navigator.userAgent,
 
79
                                subString: "Netscape",
 
80
                                identity: "Netscape"
 
81
                        },
 
82
                        {
 
83
                                string: navigator.userAgent,
 
84
                                subString: "MSIE",
 
85
                                identity: "Explorer",
 
86
                                versionSearch: "MSIE"
 
87
                        },
 
88
                        {
 
89
                                string: navigator.userAgent,
 
90
                                subString: "Gecko",
 
91
                                identity: "Mozilla",
 
92
                                versionSearch: "rv"
 
93
                        },
 
94
                        {               // for older Netscapes (4-)
 
95
                                string: navigator.userAgent,
 
96
                                subString: "Mozilla",
 
97
                                identity: "Netscape",
 
98
                                versionSearch: "Mozilla"
 
99
                        }
 
100
                ],
 
101
                dataOS : [
 
102
                        {
 
103
                                string: navigator.platform,
 
104
                                subString: "Win",
 
105
                                identity: "Windows"
 
106
                        },
 
107
                        {
 
108
                                string: navigator.platform,
 
109
                                subString: "Mac",
 
110
                                identity: "Mac"
 
111
                        },
 
112
                        {
 
113
                                   string: navigator.userAgent,
 
114
                                   subString: "iPhone",
 
115
                                   identity: "iPhone/iPod"
 
116
                    },
 
117
                        {
 
118
                                string: navigator.platform,
 
119
                                subString: "Linux",
 
120
                                identity: "Linux"
 
121
                        }
 
122
                ]
 
123
 
 
124
        };
 
125
        
 
126
        
 
127
        // Main
 
128
        $(function () {
 
129
            BrowserDetect.init();
 
130
            $("#date").html(new Date().toString());
 
131
            $("#os").html(BrowserDetect.OS);
 
132
            $("#browser").html(BrowserDetect.browser + ' ' + BrowserDetect.version);
 
133
            
 
134
            // localStorage/cookies
 
135
            if (('localStorage' in window) && window['localStorage'] !== null) {
 
136
                $("#settings").html(localStorage.settings);
 
137
            } else {
 
138
                $("#settings").html(document.cookie);
 
139
            }
 
140
            
 
141
        });
 
142
    </script>
 
143
</head>
 
144
<body>
 
145
    <div style='text-align:center;'>
 
146
        <h1>Browser diagnostics</h1>
 
147
        <span style='font-size:11px' id='date'></span>
 
148
        <div style='margin: 50px auto; text-align: left; width: 60%;'>
 
149
            <b>OS:</b> <span id='os'></span><br />
 
150
            <b>Browser:</b> <span id='browser'></span><br />
 
151
            <b>Settings: </b><br />
 
152
            <div id='settings' style='border: 1px solid gray; padding: 5px; font-size: 11px; overflow-x: auto;'></div>
 
153
        </div>
 
154
    </div>
 
155
</body>
 
156
</html>