-
Notifications
You must be signed in to change notification settings - Fork 5
/
browser-detect.js
69 lines (63 loc) · 2.07 KB
/
browser-detect.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//noinspection JSHint,JSLint
(function (papyrus) {
// C O N S T A N T S
papyrus.isMac = navigator.appVersion.indexOf("Mac") != -1;
papyrus.isIE = (navigator.appName == "Microsoft Internet Explorer");
if (papyrus.isIE) { // yesss
papyrus.ieVer = navigator.appVersion.match(/MSIE (\d+)/) || '0';
papyrus.ieVer = parseInt(papyrus.ieVer, 10);
document.documentElement.classList.add('ie');
}
papyrus.isOpera = !!navigator.userAgent.match('Opera');
if (papyrus.isOpera) {
var m;
if (m = navigator.userAgent.match(/Version\/([.\d]+)/)) {
if (parseFloat(m[1]) < 13) {
document.documentElement.classList.add('opera12');
}
}
}
papyrus.isFirefox = navigator.userAgent.indexOf("Firefox") > -1;
papyrus.isSafari = (navigator.vendor || '').indexOf("Apple") > -1;
papyrus.isWin = navigator.platform.indexOf('Win') > -1;
papyrus.isIphone = !!navigator.userAgent.match(/iPhone/i);
papyrus.isIpad = !!navigator.userAgent.match(/iPad/i);
papyrus.isIpod = !!navigator.userAgent.match(/iPod/i);
papyrus.isIos = papyrus.isIphone || papyrus.isIpad || papyrus.isIpod;
papyrus.KEYBOARD = {
PAGE_UP : 33,
PAGE_DOWN : 34,
END : 35,
HOME : 36,
LEFT : 37,
UP : 38,
RIGHT : 39,
DOWN : 40,
COMMAND : 91,
CONTROL : 17,
TAB : 9,
ESC : 27,
ENTER : 13,
BACKSPACE : 8,
DELETE : 46,
SPACE : 32,
ASTERISK : 42,
QUESTION : 63,
SEMICOLON : papyrus.isFirefox ? 59 : 186,
APOSTROPHE : 222,
TILDA: 192
};
var i;
for (i = 0x41; i <= 0x5a; i++) {
papyrus.KEYBOARD[String.fromCharCode(i)] = i;
}
for (i = 0; i < 10; i++) {
papyrus.KEYBOARD['_' + i] = i + 48;
}
//noinspection JSHint,JSLint
if (papyrus.isIE && !(window['console'])) {
var wc = {};
wc.log = wc.warn = wc.fail = function () {};
window.console = wc;
}
}(window['papyrus'] = window['papyrus'] || {}));