1"use strict"; 2 3var App = App || {}; 4 5let BrowserModel = function() { 6 let self = {}; 7 8 // based off of https://stackoverflow.com/questions/2324944/in-javascript-how-do-i-determine-if-my-current-browser-is-firefox-on-a-computer 9 function getBrowser() { 10 let agent = navigator.userAgent; 11 let browsers = [ 12 { name: "Edge", identifier: "Edge" }, 13 { name: "Opera", identifier: "OPR" }, 14 { name: "Opera", identifier: "Opera" }, 15 { name: "Internet Explorer", identifier: "Trident" }, 16 { name: "Internet Explorer", identifier: "MSIE" }, 17 { name: "Chrome", identifier: "Chrome" }, 18 { name: "Firefox", identifier: "Firefox" }, 19 { name: "UC Browser", identifier: "UCBrowser" }, 20 { name: "Safari", identifier: "Safari" }, //most agents have safari in them, so may be incorrect 21 ]; 22 let browser = browsers.reduce((acc, b) => agent.indexOf(b.identifier) > -1 ? (acc || b.name) : acc, undefined); 23 24 return browser || "Unknown"; 25 } 26 27 function isValidBrowser() { 28 return ['Firefox', 'Chrome'].indexOf(getBrowser()) > -1; 29 } 30 31 return { 32 getBrowser, 33 isValidBrowser 34 }; 35}
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.