1 /** This file is part of KCFinder project
3 * @desc User Agent jQuery Plugin
6 * @author Pavel Tzonkov <sunhater@sunhater.com>
7 * @copyright 2010-2014 KCFinder Project
8 * @license http://opensource.org/licenses/GPL-3.0 GPLv3
9 * @license http://opensource.org/licenses/LGPL-3.0 LGPLv3
10 * @link http://kcfinder.sunhater.com
16 var agent
= " " + navigator
.userAgent
,
20 expr
: / [a
-z
]+\/[0-9a-z\.]+/ig,
23 expr
: / [a
-z
]+:[0-9a
-z
\.]+/ig
,
25 keys
: ["rv", "version"]
27 expr
: / [a
-z
]+\s
+[0-9a
-z
\.]+/ig
,
29 keys
: ["opera", "msie", "firefox", "android"]
31 expr
: /[ \/\(]([a-z0-9_]+)[ ;\)\/]/ig,
32 keys
: "i386|i486|i586|i686|x86|x64|x86_64|intel|ppc|powerpc|windows|macintosh|darwin|unix|linux|sunos|android|iphone|ipad|ipod|amiga|amigaos|beos|wii|playstation|gentoo|fedora|slackware|ubuntu|archlinux|debian|mint|mageia|mandriva|freebsd|openbsd|netbsd|solaris|opensolaris|x11|mobile|phone".split('|'),
37 $.each(patterns
, function(i
, pattern
) {
38 var elements
= agent
.match(pattern
.expr
);
39 if (elements
=== null)
41 $.each(elements
, function(j
, ag
) {
42 ag
= ag
.replace(/^\s+/, "").toLowerCase();
43 var key
= ag
.replace(pattern
.expr
, "$1"),
45 if (typeof pattern
.delim
!= "undefined") {
46 ag
= ag
.split(pattern
.delim
);
51 if (typeof pattern
.keys
!= "undefined") {
52 var exists
= false, k
= 0;
53 for (; k
< pattern
.keys
.length
; k
++)
54 if (pattern
.keys
[k
] == key
) {
62 if (typeof pattern
.sub
!= "undefined") {
63 if (typeof $.agent
[pattern
.sub
] != "object")
64 $.agent
[pattern
.sub
] = {};
65 if (typeof $.agent
[pattern
.sub
][key
] == "undefined")
66 $.agent
[pattern
.sub
][key
] = val
;
68 } else if (typeof $.agent
[key
] == "undefined")
73 if (!$.agent
.platform
)
74 $.agent
.platform
= {};
76 // Check for mobile device
78 var keys
= "mobile|android|iphone|ipad|ipod|iemobile|phone".split('|');
81 $.each([a
, a
.platform
], function(i
, p
) {
82 for (var j
= 0; j
< keys
.length
; j
++) {