1/** 2* jQuery Browser 3* 4* Description: Get some information about the current used browser, 5* its operating system and its available plugins. 6* Version: 10.12.02 (based on original jquery.browser) 7* Date: 2010-12-02 8* Copyright: (c) 2010 Michael Keck 9* http://www.michaelkeck.de/ 10* License: Dual licensed under the MIT or GPL Version 2 licenses. 11*/ 12(function ($) { 13 14 if (typeof ($.browser) === 'undefined' || !$.browser) { 15 var browser = {}; 16 $.extend(browser); 17 } 18 19 /** 20 * Check the current used useragent and return its informations 21 * @return $.browser 22 */ 23 $.browserTest = function (a, z) { 24 /* Plugins to Check */ 25 var l = { 26 flash: { activex: 'ShockwaveFlash.ShockwaveFlash', plugin: /flash/gim }, 27 java: { activex: navigator.javaEnabled(), plugin: /java/gim }, 28 pdf: { activex: 'PDF.PdfCtrl', plugin: /adobe\s?acrobat/gim }, 29 quicktime: { activex: 'QuickTime.QuickTime', plugin: /quicktime/gim }, 30 realplayer: { activex: 'RealPlayer', plugin: /realplayer/gim }, 31 silverlight: { activex: ['AgControl.AgControl'], plugin: /silverlight/gim }, 32 shockwave: { activex: 'SWCtl.SWCtl', plugin: /shockwave/gim }, 33 windowsmedia: { activex: 'WMPlayer.OCX', plugin: /(windows\smedia)|(Microsoft)/gim } 34 /** 35 * You can add more plugins to check. 36 * Example: 37 * nameoftheplugin : { activex: MixedSearch, plugin: MixedSearch } 38 * Info: 39 * activex searches after Microsoft ActiveX in Ineternet Explorer 40 * plugin seraches after a Plugin in other browsers, like Gecko, WebKit, Khtml, Opera ... 41 */ 42 }; 43 44 /* Default Vars */ 45 var u = 'unknown', ua = (navigator.userAgent || navigator.vendor || window.opera), x = 'X'; 46 47 /* Check Plugins */ 48 var p = function (p) { 49 if (window.ActiveXObject) { 50 try { 51 new ActiveXObject(l[p].activex); 52 $.browser[p] = true; 53 } catch (e) { 54 $.browser[p] = false; 55 } 56 } else { 57 $.each(navigator.plugins, function () { 58 if (this.name.match(l[p].plugin)) { 59 $.browser[p] = true; 60 return false; 61 } else { 62 $.browser[p] = false; 63 } 64 }); 65 } 66 }; 67 68 /* Search and Replace */ 69 var m = function (r, h) { 70 for (var i = 0; i < h.length; i = i + 1) { 71 r = r.replace(h[i][0], h[i][1]); 72 } 73 return r; 74 }; 75 76 /* Get name, version and className of the current used Browser */ 77 var c = function (i, a, b, c) { 78 var r = { 79 name: m((a.exec(i) || [u, u])[1], b) 80 }, t = ''; 81 r[r.name] = true; 82 r.version = (c.exec(i) || [x, x, x, x])[3]; 83 84 if (r.name.match(/safari/) && r.version > 400) { 85 r.version = '2.0'; 86 } 87 if (r.name === 'presto') { 88 r.version = ($.browser.version > 9.27) ? 'futhark' : 'linear_b'; 89 } 90 t = r.version; 91 if (r.version.indexOf('.') !== -1) { 92 t = r.version.split('.'); 93 if (t.length < 1) { 94 t = r.version + '.0'; 95 } else { 96 t = t[0] + '.' + t[1]; 97 } 98 } 99 r.version = (r.version !== x) ? (r.version + '').substr(0, 1) : x; 100 r.cssname = r.name + r.version; 101 r.version = parseFloat(t, 10) || 0; 102 return r; 103 }; 104 105 /* Pregmatch the name of the browser */ 106 a = (a.match(/Opera|Navigator|Minefield|KHTML|Chrome/) 107 ? m(a, [[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/, ''], ['Chrome Safari', 'Chrome'], ['KHTML', 'Konqueror'], ['Minefield', 'Firefox'], ['Navigator', 'Netscape']]) 108 : a 109 ).toLowerCase(); 110 111 /* Store the name, version and classname of the browser in $.browser */ 112 $.browser = $.extend( 113 (!z) ? $.browser : {}, c(a, 114 /(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/, 115 [], 116 /(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/ 117 ) 118 ); 119 120 /* Store the render-engine of the browser in $.layout */ 121 $.layout = c(a, 122 /(gecko|konqueror|msie|opera|webkit)/, 123 [['konqueror', 'khtml'], ['msie', 'trident'], ['opera', 'presto']], 124 /(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/ 125 ); 126 127 /* Store the operating system in $.os */ 128 $.os = { name: (/(win|mac|linux|sunos|solaris|iphone|ipad|ipod)/.exec(navigator.platform.toLowerCase()) || [u])[0].replace('sunos', 'solaris') }; 129 130 /** 131 * Check if the browser has a touchscreen and can support it 132 */ 133 $.browser.hastouch = ('ontouchstart' in window) ? true : false; 134 135 /** 136 * Check if device is an iThing device or browser is 137 * running on an iThing. 138 * $.browser.ithing = true, if its an iPad, iPhone or iPod 139 */ 140 $.browser.ithing = (!!(navigator.userAgent.match(/iPad/i) !== null || navigator.userAgent.match(/iPhone/i) !== null || navigator.userAgent.match(/iPod/i) !== null) || $.os.name == 'ipad' || $.os.name == 'iphone' || $.os.name == 'ipod') ? true : false; 141 142 /** 143 * Check if device is a mobile device or browser is 144 * running on a mobile device. 145 * Note: if $.browser.ithing == true then $.browser.mobile = true 146 */ 147 $.browser.mobile = (/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(ua) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|
147sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(ua.substr(0, 4)) || $.browser.ithing); 148 149 /** 150 * Check if we have on a mobile device with a touch screen 151 * Note: if $.browser.ithing == true 152 * or $.browser.hastouch == true 153 * then $.browser.touch = true 154 */ 155 $.browser.touch = (($.browser.mobile && ($.browser.hastouch || $.browser.ithing)) ? true : false); 156 157 /** 158 * Get the absolute url of the current 159 * window.location.href object or an 160 * optional given path 161 * and store it in $.browser.hostpath 162 * @param {string} p [optional pathname] 163 * @return {string} absolute url 164 */ 165 $.browser.realpath = function (p) { 166 var a = [], b = [], r = window.location.href, t = '', x = 0; 167 if (p) { 168 t = (p + '').replace('\\', '/'); 169 if (t.indexOf('://') !== -1) { 170 x = 1; 171 } 172 if (!x) { 173 t = r.substring(0, r.lastIndexOf('/') + 1) + t; 174 } 175 } else { 176 t = r.substring(0, r.lastIndexOf('/') + 1); 177 } 178 a = t.split('/'); 179 for (var k in a) { 180 if (a[k] == '.') { 181 continue; 182 } 183 if (a[k] == '..') { 184 if (b.length > 3) { 185 b.pop(); 186 } 187 } 188 else { 189 if ((b.length < 2) || (a[k] !== '')) { 190 b.push(a[k]); 191 } 192 } 193 } 194 if (p) { 195 return b.join('/'); 196 } 197 $.browser.hostpath = b.join('/'); 198 }; 199 200 201 /** 202 * Get the base filename of the current window.location.href object 203 * and store it in $.browser.basename. 204 */ 205 $.browser.basename = (function () { 206 var r = window.location.href; 207 r = r.substring(r.lastIndexOf('/') + 1, r.length); 208 $.browser.filename = r; 209 if (r.lastIndexOf('?') !== -1) { 210 r = r.substring(0, r.lastIndexOf('?')); 211 } else if (r.lastIndexOf('#') !== -1) { 212 r = r.substring(0, r.lastIndexOf('#')); 213 } 214 return r; 215 })(); 216 217 218 /** 219 * This function extracts all required informations 220 * from a file. 221 * Example: 222 * // your document.location.href would return 223 * // http://www.domain.com/page/media/fotos/index.html 224 * var fileinfo = $.browser.fileinfo('media/fotos/myfoto.jpg'); 225 * // would be 226 * fileinfo = { 227 * basename : 'myfoto.jpg', 228 * dirname : '/media/fotos', 229 * filename : 'myfoto', 230 * filetype : 'jpg', 231 * filelink : 'http://www.domain.com/page/media/fotos/myfoto.jpg' 232 * realpath : '/page/media/fotos' 233 * }; 234 * @param {string} file to check 235 */ 236 $.browser.fileinfo = function (f) { 237 var r = { 'basename': null, 'dirname': null, 'filename': null, 'filetype': null, 'filelink': null, 'pathlink': null, 'realpath': null }, p = $.browser.hostpath, h = $.browser.hostaddr; 238 if (!f) { 239 f = window.location.href; 240 } 241 r.basename = f; 242 if (f.indexOf('/') !== -1) { 243 r.basename = f.substring(f.lastIndexOf('/') + 1, f.length); 244 } 245 r.filename = r.basename; 246 if (r.basename.indexOf('.') !== -1) { 247 r.filetype = r.basename.substring(r.basename.lastIndexOf('.') + 1, r.basename.length); 248 r.filename = r.basename.substring(0, r.filename.length - r.filetype.length - 1); 249 } 250 r.filelink = $.browser.realpath(f); 251 r.pathlink = r.filelink.substring(0, r.filelink.lastIndexOf('/')); 252 r.dirname = r.pathlink.replace(p, '').substring(0, r.pathlink.lastIndexOf('/')); 253 r.realpath = r.pathlink.replace(h, '').substring(0, r.pathlink.lastIndexOf('/')); 254 if (r.dirname.substring(0, 1) !== '/') { 255 r.dirname = '/' + r.dirname; 256 } 257 if (r.realpath.substring(0, 1) !== '/') { 258 r.realpath = '/' + r.realpath; 259 } 260 return r; 261 }; 262 263 264 /** 265 * Checking, if the browser support some CSS3-definitions 266 */ 267 $.browser.css3 = (function (e) { 268 e = e || document.documentElement; 269 var c = { 270 'borderRadius': 'border-radius', 271 'borderImage': 'border-image', 272 'boxShadow': 'box-shadow', 273 'opacity': 'opacity', 274 'overflowX': 'overflow-x', 275 'overflowY': 'overflow-y', 276 'textShadow': 'text-shadow' 277 }; 278 var f = false, r = [], s = e.style, m = ['Moz', 'Webkit', 'Khtml', 'O', 'Ms']; 279 for (var p in c) { 280 var n = p, a = false; 281 /* test standard property first */ 282 if (typeof (s[p]) == 'string') { 283 r[n] = [c[n].toLowerCase()]; 284 f = true; 285 a = true; 286 } 287 /* test vendor specific properties */ 288 else { 289 /* capitalize */ 290 p = p.charAt(0).toUpperCase() + p.slice(1); 291 for (var i = 0, l = m.length; i < l; i++) { 292 var t = m[i] + p; 293 if (typeof (s[t]) == 'string') { 294 r[n] = ['-' + m[i].toLowerCase() + '-' + c[n].toLowerCase()]; 295 f = true; 296 a = true; 297 } 298 } 299 } 300 if (a !== true) { 301 r[n] = false; 302 } 303 } 304 if (f) { 305 return r; 306 } else { 307 return false; 308 } 309 })();
310 311 312 /* Check browsers HTML5-support */ 313 $.browser.html5 = (typeof (HTMLVideoElement) !== undefined && typeof (HTMLAudioElement) !== undefined && typeof (HTMLCanvasElement) !== undefined) ? true : false; 314 315 /* Protocol like 'http://' or 'https://' */ 316 $.browser.protocol = ((window.location.href.indexOf('://') !== -1) ? $.browser.protocol = window.location.href.substring(0, window.location.href.indexOf('://') + 3) : $.browser.protocol = 'file://'); 317 318 /* Real Hostname (without the 'www.') */ 319 $.browser.host = window.location.hostname.toLowerCase().replace(/(www.|ftp.|ftps.|mail.|mailto.|imap.|smtp.|pop.|pop3.)/gi, ''); 320 321 /* Original Hostname (perhabs with the 'www.') */ 322 $.browser.hostname = window.location.hostname.toLowerCase(); 323 324 /* Host-Address */ 325 $.browser.hostaddr = $.browser.protocol + $.browser.hostname + '/'; 326 327 /* Get the realpath of the current window.location.href */ 328 $.browser.realpath(); 329 330 /* Get the base filename of the current window.location.href */ 331 $.browser.basename; 332 333 /* Browser viewport */ 334 $.browser.innerWidth = $.browser.viewWidth = (window.innerWidth || self.innerWidth || (document.documentElement && document.documentElement.clientWidth) || document.body.clientWidth); 335 $.browser.innerHeight = $.browser.viewHeight = (window.innerHeight || self.innerHeight || (document.documentElement && document.documentElement.clientHeight) || document.body.clientHeight); 336 337 /* Available screen resultion of the current system browser running in */ 338 $.browser.screenWidth = (screen.width || 0); 339 $.browser.screenHeight = (screen.height || 0); 340 341 /* Check Plugins */ 342 $.each(l, function (i, n) { p(i); }); 343 344 }; 345 346 /** 347 * Init the browser check 348 */ 349 $.browserTest(navigator.userAgent); 350 351 /** 352 * Compatibility for some other Plugins made by 353 * Michael Keck (http://www.michaelkeck.de/) 354 */ 355 //$.usragnt = $.browser; 356 357 /** 358 * DEBUGGING 359 * -------------------------------------------- 360 * 361 * var dbg = ''; 362 * for (var b in $.browser) { 363 * if (typeof($.browser[b]) == 'function') { 364 * continue; 365 * } 366 * if (typeof($.browser[b]) !== 'object') { 367 * dbg += b + '\t: ' + $.browser[b] + '\n'; 368 * } else { 369 * dbg += b + ': ' + (($.browser[b]) ? true : false) + '\n'; 370 * for (var bb in $.browser[b]) { 371 * dbg += '\t ' + b + '.' + bb + '\t= ' + $.browser[b][bb] + '\n'; 372 * } 373 * } 374 * } 375 * alert(dbg); 376 */ 377 378})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.