1(function($){ 2 $(document).ready( function(){ 3 var user_agent = navigator.userAgent; 4 var is_opera_edge; 5 var browser = user_agent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))/i) || []; 6 var browser_name = ''; 7 var browser_class = ''; 8 9 if ( /trident/i.test( browser[0] ) ) { 10 browser_name = 'ie'; 11 } else if ( browser[0] === 'Chrome' ) { 12 is_opera_edge = user_agent.match(/\b(OPR|Edge)/); 13 14 if ( is_opera_edge !== null ) { 15 browser_name = is_opera_edge[0].replace('OPR', 'opera'); 16 } 17 } 18 19 // use navigator.appName as browser name if we were unable to get it from user_agent 20 if ( '' === browser_name ) { 21 browser_name = '' !== browser[0] ? browser[0] : navigator.appName; 22 } 23 24 browser_name = browser_name.toLowerCase(); 25 26 // convert browser name to class. Some classes do not match the browser name 27 switch( browser_name ) { 28 case 'msie' : 29 browser_class = 'ie'; 30 break; 31 case 'firefox' : 32 browser_class = 'gecko'; 33 break; 34 default : 35 browser_class = browser_name; 36 break; 37 } 38 39 // add `iphone` class if browsing from iphone 40 if ( user_agent.match(/iPhone/) ) { 41 browser_class += ' iphone'; 42 } 43 44 $( 'body' ).addClass( browser_class ); 45 }); 46})(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.