Changeset 5149 for branches/2.2/phpgwapi/js/browser
- Timestamp:
- 11/04/11 09:34:47 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/phpgwapi/js/browser/browserDetect.js
r5058 r5149 1 1 (function() 2 2 { 3 4 var agt= navigator.userAgent.toLowerCase();5 var appVer = navigator.appVersion.toLowerCase();3 // NAVIGATOR USER AGENT 4 var agt = navigator.userAgent.toLowerCase(); 5 var browser = [['chrome',8,'chrome'],['epiphany',2,'epiphany'], ['firefox',3,'firefox'], ['iceweasel',3 ,'iceweasel'], ['msie',5,'msie'], ['safari', 5 ,'version']]; 6 6 7 var is_minor = parseFloat(appVer); 8 var is_major = parseInt(is_minor); 9 10 var iePos = appVer.indexOf('msie'); 11 12 if ( iePos != -1 ) 13 { 14 is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos))); 15 is_major = parseInt(is_minor); 16 } 17 18 //Konqueror 19 20 var is_konq = false; 21 var kqPos = agt.indexOf('konqueror'); 22 23 if ( kqPos !=-1 ) 24 { 25 is_konq = true; 26 is_minor = parseFloat(agt.substring(kqPos+10,agt.indexOf(';',kqPos))); 27 is_major = parseInt(is_minor); 28 } 29 30 //Is_Khtml 31 var is_khtml = (((agt.indexOf('safari')!=-1) && (agt.indexOf('mac')!=-1)) && ( is_konq )); 32 33 //Is_Opera 34 var is_opera = (agt.indexOf("opera") != -1 ); 35 36 //Is_IE 37 var is_ie = ((iePos!=-1) && (!is_opera) && (!is_khtml)); 38 39 // Gecko 40 var is_gecko = ((!is_khtml)&&(navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false; 41 var is_gver = 0; 42 43 if (is_gecko) 44 is_gver = navigator.productSub; 45 46 // Moz 47 var is_moz = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) && 48 (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1) && 49 (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1) && 50 (is_gecko) && ((navigator.vendor=="")||(navigator.vendor=="Mozilla"))); 51 52 var _browser = [ 53 54 // Chrome 55 ['chrome8', ( agt.indexOf('chrome/8') != -1 ) ], 56 ['chrome11', ( agt.indexOf('chrome/11') != -1 ) ], 57 58 // EPIPHANY 59 ['epiphany2', ( agt.indexOf('epiphany/2') != -1 ) ], 60 61 // FIREFOX 62 ['firefox1', ( agt.indexOf('firefox/1') != -1 ) ], 63 ['firefox2', ( agt.indexOf('firefox/2') != -1 ) ], 64 ['firefox3', ( agt.indexOf('firefox/3') != -1 ) ], 65 ['firefox4', ( agt.indexOf('firefox/4') != -1 ) ], 66 ['firefox5', ( agt.indexOf('firefox/5') != -1 ) ], 67 ['firefox6', ( agt.indexOf('firefox/6') != -1 ) ], 68 69 // ICEWEASEL 70 ['iceweasel3', (agt.indexOf('iceweasel/3') != -1 ) ], 71 72 // IE 73 ['ie3', (((iePos!=-1) && (!is_opera) && (!is_khtml)) && (is_major < 4 )) ], 74 ['ie4', (((iePos!=-1) && (!is_opera) && (!is_khtml)) && (is_major == 4 )) ], 75 ['ie5', (((iePos!=-1) && (!is_opera) && (!is_khtml)) && (is_major == 5 )) ], 76 ['ie55', (((iePos!=-1) && (!is_opera) && (!is_khtml)) && (agt.indexOf("msie 5.5") !=-1 )) ], 77 ['ie6', (((iePos!=-1) && (!is_opera) && (!is_khtml)) && (is_major == 6 )) ], 78 ['ie7', (((iePos!=-1) && (!is_opera) && (!is_khtml)) && (is_major == 7 )) ], 79 ['ie8', (((iePos!=-1) && (!is_opera) && (!is_khtml)) && (is_major == 8 )) ], 80 81 //IS? 82 ['is_ie', ((iePos!=-1) && (!is_opera) && (!is_khtml)) ], 83 ['is_gecko', is_gecko ], 84 ['is_opera', is_opera ], 85 ['is_khtml', is_khtml ], 86 ['is_moz', is_moz ], 87 88 // OPERA 89 ['is_opera', is_opera], 90 ['opera2', ( agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1) ], 91 ['opera3', ( agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1) ], 92 ['opera4', ( agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1) ], 93 ['opera5', ( agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1) ], 94 ['opera6', ( agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1) ], 95 ['opera7', ( agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1) ], 96 ['opera8', ( agt.indexOf("opera 8") != -1 || agt.indexOf("opera/8") != -1) ], 97 ['opera9', ( agt.indexOf("opera 9") != -1 || agt.indexOf("opera/9") != -1) ], 98 99 // IS SAFARI/KHTML 100 ['safari', ( agt.indexOf('safari') != -1 ) ], 101 ['khtml', is_khtml ] 102 ]; 103 104 function isLoadApp() 105 { 106 var Browser = new Array(); 107 108 // Chrome; 109 Browser = [ 110 // Chrome; 111 {navigator : "chrome11"}, 112 // Epiphany 113 {navigator : "epiphany2"}, 114 // Firefox; 115 {navigator : "firefox3"}, 116 {navigator : "firefox4"}, 117 {navigator : "firefox5"}, 118 {navigator : "firefox6"}, 119 //IceWeasel 120 {navigator : "iceweasel3"}, 121 // IE; 122 {navigator : "ie8"}, 123 // Safari; 124 {navigator : "safari"} 125 ]; 126 127 if( arguments.length > 0 ) 128 { 129 for(var i = 0; i < Browser.length; i++) 130 { 131 if( Browser[i].navigator.indexOf(arguments[0]) > -1 ) 132 { 133 if( isCompatible(Browser[i].navigator) ) 134 return true; 135 } 136 } 137 138 return false; 139 } 140 else 141 { 142 return isCompatible(Browser); 143 } 144 } 145 146 function isCompatible() 147 { 148 if( arguments.length > 0 ) 149 { 150 var _args = ( typeof(arguments[0]) === 'object' ) ? arguments[0] : arguments; 151 152 for( i = 0; i < _args.length; i++ ) 153 { 154 for( j = 0; j < _browser.length; j++ ) 155 { 156 var navigator = _args[i].toString().toLowerCase(); 157 158 if( typeof(_args[i]) === 'object' ) 159 var navigator = _args[i].navigator.toLowerCase(); 160 161 if ( navigator === _browser[j][0] ) 162 if( _browser[j][1] ) 163 return true; 164 } 165 } 166 167 return false; 168 } 169 } 170 171 function SnifferBrowser(){} 172 173 SnifferBrowser.prototype.isLoadApp = isLoadApp; 174 SnifferBrowser.prototype.isCompatible = isCompatible; 175 176 window.SnifferBrowser = new SnifferBrowser; 7 function isLoadApp() 8 { 9 for(var i = 0 ; i < browser.length; i++ ) 10 { 11 if( arguments.length > 0 ) 12 { 13 if( agt.indexOf(arguments[0]) != -1 ) 14 { 15 return true; 16 } 17 } 18 else 19 { 20 if( agt.indexOf(browser[i][0]) != -1 ) 21 { 22 var ver = parseInt(agt.substr(agt.indexOf(browser[i][2]) + (browser[i][2].length) + 1 )); 23 24 if( ver >= browser[i][1] ) 25 { 26 return true; 27 } 28 } 29 } 30 } 31 32 return false; 33 } 34 35 function SnifferBrowser(){} 36 37 SnifferBrowser.prototype.isLoadApp = isLoadApp; 38 window.SnifferBrowser = new SnifferBrowser; 177 39 178 40 })();
Note: See TracChangeset
for help on using the changeset viewer.