forked from Aleph-One-Marathon/aleph-one-marathon.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite.js
36 lines (33 loc) · 966 Bytes
/
site.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function switchPlatform(desired) {
var plats = new Array('mac', 'win', 'linux');
for (var pi = 0; pi < plats.length; pi++)
{
var plat = plats[pi];
var visible = (plat == desired);
$('.' + plat + '_block').css('display', (visible ? 'block' : 'none'));
}
}
function detectPlatform() {
try {
if (navigator.platform) {
var platform = navigator.platform;
if (/Win/.test(platform))
return 'win';
else if (/Mac/.test(platform))
return 'mac';
else if (/Linux/.test(platform) ||
/X11/.test(platform) ||
/BSD/.test(platform) ||
/Solaris/.test(platform))
return 'linux';
else if (navigator.userAgent &&
(/iPhone/.test(navigator.userAgent) ||
/iPad/.test(navigator.userAgent)))
return 'mac';
}
} catch (err) {}
return 'win';
}
$(document).ready(function () {
switchPlatform(detectPlatform());
});