1/** 2 * lwUACheck 3 * 0.9.4 4 * @param ua 5 */ 6var lwUACheck = function (ua) { 7 8 //â»userAgent 9 this.userAgent = (ua || window.navigator.userAgent); 10 11 //â»userAgentLowerCase 12 this.userAgentLowerCase = this.userAgent.toLowerCase(); 13 14 //â»browser 15 if (this.userAgentLowerCase.indexOf('msie') >= 0 || this.userAgentLowerCase.indexOf('trident') >= 0) { 16 // IE 17 this.browser = 'ie'; 18 } else if (this.userAgentLowerCase.indexOf('edge') != -1) { 19 // Edge 20 this.browser = 'edge'; 21 } else if (this.userAgentLowerCase.indexOf('chrome') != -1) { 22 // Google Chrome 23 this.browser = 'chrome'; 24 } else if (this.userAgentLowerCase.indexOf('firefox') != -1) { 25 // FireFox 26 this.browser = 'firefox'; 27 } else if (this.userAgentLowerCase.indexOf('safari') != -1) { 28 // Safari 29 this.browser = 'safari'; 30 } else if (this.userAgentLowerCase.indexOf('opera') != -1) { 31 // Opera 32 this.browser = 'opera'; 33 } else if (this.userAgentLowerCase.indexOf('gecko') != -1) { 34 // Gecko 35 this.browser = 'gecko'; 36 } else { 37 this.browser = null; 38 } 39 40 //â»PC Browser Check 41 this.isIE = (this.browser == 'ie'); 42 this.isEdge = (this.browser == 'edge'); 43 this.isChrome = (this.browser == 'chrome'); 44 this.isSafari = (this.browser == 'safari'); 45 this.isFirefox = (this.browser == 'firefox'); 46 47 //â»Mobile Check 48 this.isiPhone = (this.userAgentLowerCase.indexOf('iphone') >= 0); 49 this.isiPod = (this.userAgentLowerCase.indexOf('ipod') >= 0); 50 this.isiPad = (this.userAgentLowerCase.indexOf('ipad') >= 0); 51 this.isiOS = (this.isiPhone || this.isiPod || this.isiPad); 52 this.isAndroid = (this.userAgentLowerCase.indexOf('android') >= 0); 53 this.isMobile = (this.isiOS || this.isAndroid); 54 this.isTablet = (this.isiPad || (this.isAndroid && this.userAgentLowerCase.indexOf('mobile') < 0)); 55 56 //â»verIE 57 if (this.isIE) { 58 var verArray = /(msie|rv:?)\s?([0-9]{1,})([\.0-9]{1,})/.exec(this.userAgentLowerCase); 59 if (verArray) { 60 this.verIE = String(verArray[2]); 61 } 62 } else { 63 this.verIE = null; 64 } 65 66 //â»verChrome 67 if (this.isChrome) { 68 if (this.userAgentLowerCase.match(/chrome\/([0-9_.]+)/)) { 69 this.verChrome = String(RegExp.$1).split("_").join("."); 70 } 71 } else { 72 this.verChrome = null; 73 } 74 75 //â»verIOS 76 if (this.isiOS) { 77 if (this.userAgentLowerCase.match(/cpu iphone os ([0-9_.]+)/)) { 78 // â»iPhone,iPodç¨ 79 this.veriOS = String(RegExp.$1).split("_").join("."); 80 } else if (this.userAgentLowerCase.match(/cpu os ([0-9_.]+)/)) { 81 // â»iPadç¨ 82 this.veriOS = String(RegExp.$1).split("_").join("."); 83 } 84 } else { 85 this.veriOS = null; 86 } 87 88 //â»verAndroid 89 if (this.isAndroid) { 90 if (this.userAgentLowerCase.match(/android ([0-9_.]+)/)) { 91 this.verAndroid = String(RegExp.$1).split("_").join("."); 92 } 93 } else { 94 this.verAndroid = null; 95 } 96 97 //â»isWindows 98 this.isWindows = (this.userAgentLowerCase.indexOf('windows nt') >= 0); 99 100 //â»verWindows 101 if (this.isWindows) { 102 if (this.userAgentLowerCase.match(/windows nt ([0-9_.]+)/)) { 103 this.verWindows = String(RegExp.$1).split("_").join("."); 104 } 105 } else { 106 this.verWindows = null; 107 } 108 109 //â»isMacOSX 110 this.isMacOSX = (this.userAgentLowerCase.indexOf('mac os x') >= 0 && !this.isMobile); 111 112 //â»verMacOSX 113 if (this.isMacOSX) { 114 if (this.userAgentLowerCase.match(/mac os x ([0-9_.]+)/)) { 115 this.verMacOSX = String(RegExp.$1).split("_").join("."); 116 } 117 } else { 118 this.verMacOSX = null; 119 } 120 121 122}; 123 124/** 125 * verIE_over 126 * @param minVer 127 * @param maxVer 128 * @returns {boolean} 129 */ 130lwUACheck.prototype.verIE_over = function (minVer, maxVer) { 131 132 if (this.isIE) { 133 var current = this.verIE; 134 var min = String(minVer); 135 var max = (maxVer !== undefined) ? String(maxVer) : null; 136 var result = false; 137 if(max){ 138 result = this.minVerCheck(current, min) && this.maxVerCheck(current, max); 139 }else{ 140 result = this.minVerCheck(current, min); 141 } 142 return result; 143 } else { 144 return false; 145 } 146 147}; 148 149/** 150 * verChrome_over 151 * @param minVer 152 * @param maxVer 153 * @returns {boolean} 154 */ 155lwUACheck.prototype.verChrome_over = function (minVer, maxVer) { 156 157 if (this.isChrome) { 158 159 var current = this.verChrome; 160 161 var min = String(minVer); 162 var max = (maxVer !== undefined) ? String(maxVer) : null; 163 var result = false; 164 if(max){ 165 result = this.minVerCheck(current, min) && this.maxVerCheck(current, max); 166 }else{ 167 result = this.minVerCheck(current, min); 168 } 169 return result; 170 } else { 171 return false; 172 } 173 174}; 175 176/** 177 * veriOS_over 178 * @param minVer 179 * @param maxVer 180 * @returns {boolean} 181 */ 182lwUACheck.prototype.veriOS_over = function (minVer, maxVer) { 183 184 if (this.isiOS) { 185 186 var current = this.veriOS; 187 188 var min = String(minVer); 189 var max = (maxVer !== undefined) ? String(maxVer) : null; 190 var result = false; 191 if(max){ 192 result = this.minVerCheck(current, min) && this.maxVerCheck(current, max); 193 }else{ 194 result = this.minVerCheck(current, min); 195 } 196 return result; 197 } else { 198 return false; 199 } 200 201}; 202 203/** 204 * verAndroid_over 205 * @param minVer 206 * @param maxVer 207 * @returns {boolean} 208 */ 209lwUACheck.prototype.verAndroid_over = function (minVer, maxVer) { 210 211 if (this.isAndroid) { 212 213 var current = this.verAndroid; 214 215 var min = String(minVer); 216 var max = (maxVer !== undefined) ? String(maxVer) : null; 217 var result = false; 218 if(max){ 219 result = this.minVerCheck(current, min) && this.maxVerCheck(current, max); 220 }else{ 221 result = this.minVerCheck(current, min); 222 } 223 return result; 224 } else { 225 return false; 226 } 227}; 228 229/** 230 * verWindows_over 231 * @param minVer 232 * @param maxVer 233 * @returns {boolean} 234 */ 235lwUACheck.prototype.verWindows_over = function (minVer, maxVer) { 236 237 if (this.isWindows) { 238 239 var current = this.verWindows; 240 241 var min = String(minVer); 242 var max = (maxVer !== undefined) ? String(maxVer) : null; 243 var result = false; 244 if(max){ 245 result = this.minVerCheck(current, min) && this.maxVerCheck(current, max); 246 }else{ 247 result = this.minVerCheck(current, min); 248 } 249 return result; 250 } else { 251 return false; 252 } 253 254}; 255 256/** 257 * verMacOSX_over 258 * @param minVer 259 * @param maxVer 260 * @returns {boolean} 261 */ 262lwUACheck.prototype.verMacOSX_over = function (minVer, maxVer) { 263 264 if (this.isMacOSX) { 265 266 var current = this.verMacOSX; 267 268 var min = String(minVer); 269 var max = (maxVer !== undefined) ? String(maxVer) : null; 270 var result = false; 271 if(max){ 272 result = this.minVerCheck(current, min) && this.maxVerCheck(current, max); 273 }else{ 274 result = this.minVerCheck(current, min); 275 } 276 return result; 277 } else { 278 return false; 279 } 280 281}; 282 283 284/** 285 * minVerCheck 286 * @param current 287 * @param min 288 * @returns {boolean} 289 */ 290lwUACheck.prototype.minVerCheck = function (current, min) { 291 292 var minVersions = this.getVersions(min); 293 var currentVersions = this.getVersions(current); 294 295 if (minVersions[0] < currentVersions[0]) { 296 return true; 297 } else if (currentVersions[0] < minVersions[0]) { 298 return false; 299 } 300 301 if (minVersions[1] < currentVersions[1]) { 302 return true; 303 } else if (currentVersions[1] < minVersions[1]) { 304 return false; 305 } 306 307 if (minVersions[2] < currentVersions[2]) { 308 return true; 309 } else if (currentVersions[2] < minVersions[2]) { 310 return false; 311 } 312 313 return true; 314 315}; 316 317 318/** 319 * maxVerCheck 320 * @param current 321 * @param max 322 * @returns {boolean} 323 */ 324lwUACheck.prototype.maxVerCheck = function (current, max) { 325 326 var maxVersions = this.getVersions(max); 327 var currentVersions = this.getVersions(current); 328 329 if (maxVersions[0] > currentVersions[0]) { 330 return true; 331 } else if (currentVersions[0] > maxVersions[0]) { 332 return false; 333 } 334 335 if (maxVersions[1] > currentVersions[1]) { 336 return true; 337 } else if (currentVersions[1] > maxVersions[1]) { 338 return false; 339 } 340 341 if (maxVersions[2] > currentVersions[2]) { 342 return true; 343 } else if (currentVersions[2] > maxVersions[2]) { 344 return false; 345 } 346 347 return true; 348 349}; 350 351/** 352 * getVersions 353 * @param ver 354 * @returns {Array} 355 */ 356lwUACheck.prototype.getVersions = function (ver) { 357 358 var versions = String(ver).split('.'); 359 360 for (var i=versions.length; i<3; i++) { 361 versions.push(0); 362 } 363 364 for(var j=0; j<versions.length; j++){ 365 versions[j] = parseInt(versions[j], 10); 366 } 367 368 return versions; 369 370}; 371 372/** 373 * verIE_eq 374 * @param equalVer 375 * @returns {boolean} 376 */ 377lwUACheck.prototype.verIE_eq = function (equalVer) { 378 379 if (this.isIE) { 380 var equal = String(equalVer); 381 var current = this.verIE; 382 var result = this.equalVerCheck(current, equal); 383 return result; 384 } else { 385 return false; 386 } 387 388}; 389 390/** 391 * verChrome_eq 392 * @param equalVer 393 * @returns {boolean} 394 */ 395lwUACheck.prototype.verChrome_eq = function (equalVer) { 396 397 if (this.isChrome) { 398 var equal = String(equalVer); 399 var current = this.verChrome; 400 var result = this.equalVerCheck(current, equal); 401 return result; 402 } else { 403 return false; 404 } 405 406}; 407 408/** 409 * veriOS_eq 410 * @param equalVer 411 * @returns {boolean} 412 */ 413lwUACheck.prototype.veriOS_eq = function (equalVer) { 414 415 if (this.isiOS) { 416 var equal = String(equalVer); 417 var current = this.veriOS; 418 var result = this.equalVerCheck(current, equal); 419 return result; 420 } else { 421 return false; 422 } 423 424}; 425 426/** 427 * verAndroid_eq 428 * @param equalVer 429 * @returns {boolean} 430 */ 431lwUACheck.prototype.verAndroid_eq = function (equalVer) { 432 433 if (this.isAndroid) { 434 var equal = String(equalVer); 435 var current = this.verAndroid; 436 var result = this.equalVerCheck(current, equal); 437 return result; 438 } else { 439 return false; 440 } 441 442}; 443 444/** 445 * verWindows_eq 446 * @param equalVer 447 * @returns {boolean} 448 */ 449lwUACheck.prototype.verWindows_eq = function (equalVer) { 450 451 if (this.isWindows) { 452 var equal = String(equalVer); 453 var current = this.verWindows; 454 var result = this.equalVerCheck(current, equal); 455 return result; 456 } else { 457 return false; 458 } 459 460}; 461 462/** 463 * verMacOSX_eq 464 * @param equalVer 465 * @returns {boolean} 466 */ 467lwUACheck.prototype.verMacOSX_eq = function (equalVer) { 468 469 if (this.isMacOSX) { 470 var equal = String(equalVer); 471 var current = this.verMacOSX; 472 var result = this.equalVerCheck(current, equal); 473 return result; 474 } else { 475 return false; 476 } 477 478}; 479 480 481/** 482 * equalVerCheck 483 * @param current 484 * @param equal 485 * @returns {boolean} 486 */ 487lwUACheck.prototype.equalVerCheck = function (current, equal) { 488 489 var equalVersions = String(equal).split('.'); 490 for(var i=0; i< equalVersions.length; i++){ 491 equalVersions[i] = parseInt(equalVersions[i], 10); 492 } 493 494 var currentVersions = String(current).split('.'); 495 for(var j=0; j<currentVersions.length; j++){ 496 currentVersions[j] = parseInt(currentVersions[j], 10); 497 } 498 499 for (var k=0; k<equalVersions.length; k++) { 500 if(equalVersions[k] !== currentVersions[k]){ 501 return false; 502 } 503 } 504 505 return true; 506 507};
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.