1var notSupportedBrowsers = []; 2var displayPoweredBy = true; 3var noticeLang = 'professional'; 4var noticeLangCustom = null; 5var supportedBrowsers = []; 6 7var BrowserDetection = { 8 init: function(){ 9 if(notSupportedBrowsers == null || notSupportedBrowsers.length < 1){ 10 notSupportedBrowsers = this.defaultNotSupportedBrowsers; 11 } 12 13 this.detectBrowser(); 14 this.detectOS(); 15 16 if(this.browser == '' || this.browser == 'Unknown' || this.os == '' || 17 this.os == 'Unknown' || this.browserVersion == '' || this.browserVersion == 0) 18 { 19 return; 20 } 21 22 // Check if this is old browser 23 var oldBrowser = false; 24 for(var i = 0; i < notSupportedBrowsers.length; i++){ 25 if(notSupportedBrowsers[i].os == 'Any' || notSupportedBrowsers[i].os == this.os){ 26 if(notSupportedBrowsers[i].browser == 'Any' || notSupportedBrowsers[i].browser == this.browser){ 27 if(notSupportedBrowsers[i].version == "Any" || this.browserVersion <= parseFloat(notSupportedBrowsers[i].version)){ 28 oldBrowser = true; 29 break; 30 } 31 } 32 } 33 } 34 35 if(oldBrowser){ 36 this.displayNotice(); 37 } 38 }, 39 40 getEl: function(id){ return window.document.getElementById(id); }, 41 getElSize: function(id){ 42 var el = this.getEl(id); 43 if(el == null){ return null; } 44 return { 'width': parseInt(el.offsetWidth), 'height': parseInt(el.offsetHeight) }; 45 }, 46 getWindowSize: function(){ 47 if(typeof window.innerWidth != 'undefined'){ 48 return {'width': parseInt(window.innerWidth), 'height': parseInt(window.innerHeight)}; 49 } else { 50 if(window.document.documentElement.clientWidth != 0){ 51 return {'width': parseInt(window.document.documentElement.clientWidth), 'height': parseInt(window.document.documentElement.clientHeight)}; 52 } else { 53 return {'width': parseInt(window.document.body.clientWidth), 'height': parseInt(window.document.body.clientHeight)}; 54 } 55 } 56 }, 57 positionNotice: function(){ 58 var noticeSize = this.getElSize('browser-detection'); 59 var windowSize = this.getWindowSize(); 60 var noticeEl = this.getEl('browser-detection'); 61 62 if(noticeEl == null || noticeSize == null || windowSize == null || !windowSize.width || !windowSize.height){ return; } 63 noticeEl.style.left = (windowSize.width - noticeSize.width) / 2 + "px"; 64 65 var offset = (this.browser == "MSIE" && this.browserVersion < 7) ? (window.document.documentElement.scrollTop != 0 ? window.document.documentElement.scrollTop : window.document.body.scrollTop) : 0; 66 noticeEl.style.top = (windowSize.height - noticeSize.height - 20 + offset) + "px"; 67 this.noticeHeight = noticeSize.height; 68 }, 69 70 displayNotice: function(){ 71 if(this.readCookie('bdnotice') == 1){ 72 return; 73 } 74 75 this.writeNoticeCode(); 76 this.positionNotice(); 77 78 var el = this; 79 window.onresize = function(){ el.positionNotice(); }; 80 if(this.browser == "MSIE" && this.browserVersion < 7){ 81 window.onscroll = function(){ el.positionNotice(); }; 82 } 83 84 this.getEl('browser-detection-close').onclick = function(){ el.remindMe(false); }; 85 this.getEl('browser-detection-remind-later').onclick = function(){ el.remindMe(false); }; 86 this.getEl('browser-detection-never-remind').onclick = function(){ el.remindMe(true); }; 87 }, 88 89 remindMe: function(never){ 90 this.writeCookie('bdnotice', 1, never == true ? 365 : 7); 91 this.getEl('browser-detection').style.display = 'none'; 92 this.getEl('black_overlay').style.display = 'none'; 93 }, 94 95 writeCookie: function(name, value, days){ 96 var expiration = ""; 97 if(parseInt(days) > 0){ 98 var date = new Date(); 99 date.setTime(date.getTime() + parseInt(days) * 24 * 60 * 60 * 1000); 100 expiration = '; expires=' + date.toGMTString(); 101 } 102 103 document.cookie = name + '=' + value + expiration + '; path=/'; 104 }, 105 106 readCookie: function(name){ 107 if(!document.cookie){ return ''; } 108 109 var searchName = name + '='; 110 var data = document.cookie.split(';'); 111 112 for(var i = 0; i < data.length; i++){ 113 while(data[i].charAt(0) == ' '){ 114 data[i] = data[i].substring(1, data[i].length); 115 } 116 117 if(data[i].indexOf(searchName) == 0){ 118 return data[i].substring(searchName.length, data[i].length); 119 } 120 } 121 122 return ''; 123 }, 124 125 writeNoticeCode: function(){ 126 var title = ''; 127 var notice = ''; 128 var selectBrowser = ''; 129 var remindMeLater = ''; 130 var neverRemindAgain = ''; 131 132 var browsersList = null; 133 var code = '<div id="black_overlay"></div><div id="browser-detection"><a href="javascript:;" id="browser-detection-close">Close</a>'; 134 135 if(noticeLang == 'custom' && noticeLangCustom != null){ 136 title = noticeLangCustom.title; 137 notice = noticeLangCustom.notice; 138 selectBrowser = noticeLangCustom.selectBrowser; 139 remindMeLater = noticeLangCustom.remindMeLater; 140 neverRemindAgain = noticeLangCustom.neverRemindAgain; 141 } else { 142 var noticeTextObj = null; 143 eval('noticeTextObj = this.noticeText.' + noticeLang + ';'); 144 145 if(!noticeTextObj){ 146 noticeTextObj = this.noticeText.professional; 147 } 148 149 title = noticeTextObj.title; 150 notice = noticeTextObj.notice; 151 selectBrowser = noticeTextObj.selectBrowser; 152 remindMeLater = noticeTextObj.remindMeLater; 153 neverRemindAgain = noticeTextObj.neverRemindAgain; 154 } 155 156 notice = notice.replace("\n", '</p><p class="bd-notice">'); 157 notice = notice.replace("{browser_name}", (this.browser + " " + this.browserVersion)); 158 159 code += '<p class="bd-title">' + title + '</p><p class="bd-notice">' + notice + '</p><p class="bd-notice"><b>' + selectBrowser + '</b></p>'; 160 161 if(supportedBrowsers.length > 0){ 162 browsersList = supportedBrowsers; 163 } else { 164 browsersList = this.supportedBrowsers; 165 } 166 167 code += '<ul class="bd-browsers-list">'; 168 for(var i = 0; i < browsersList.length; i++){
169 code += '<li class="' + browsersList[i].cssClass + '"><a href="' + browsersList[i].downloadUrl + '" target="_blank">' + browsersList[i].name + '</a></li>'; 170 } 171 code += '</ul>'; 172 173 if(displayPoweredBy){ 174 code += '<div class="bd-poweredby">Powered by <a href="http://www.devslide.com/labs/browser-detection" target="_blank">DevSlide Labs</a></div>'; 175 } 176 177 code += '<ul class="bd-skip-buttons">'; 178 code += '<li><button id="browser-detection-remind-later" type="button">' + remindMeLater + '</button></li>'; 179 code += '<li><button id="browser-detection-never-remind" type="button">' + neverRemindAgain + '</button></li>'; 180 code += '</ul>'; 181 code += '</div>'; 182 window.document.body.innerHTML += code; 183 }, 184 185 detectBrowser: function(){ 186 this.browser = ''; 187 this.browserVersion = 0; 188 189 if(/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ 190 this.browser = 'Opera'; 191 } else if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ 192 this.browser = 'MSIE'; 193 } else if(/Navigator[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ 194 this.browser = 'Netscape'; 195 } else if(/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ 196 this.browser = 'Chrome'; 197 } else if(/Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ 198 this.browser = 'Safari'; 199 /Version[\/\s](\d+\.\d+)/.test(navigator.userAgent); 200 this.browserVersion = new Number(RegExp.$1); 201 } else if(/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ 202 this.browser = 'Firefox'; 203 } 204 205 if(this.browser == ''){ 206 this.browser = 'Unknown'; 207 } else if(this.browserVersion == 0) { 208 this.browserVersion = parseFloat(new Number(RegExp.$1)); 209 } 210 }, 211 212 // Detect operation system 213 detectOS: function(){ 214 for(var i = 0; i < this.operatingSystems.length; i++){ 215 if(this.operatingSystems[i].searchString.indexOf(this.operatingSystems[i].subStr) != -1){ 216 this.os = this.operatingSystems[i].name; 217 return; 218 } 219 } 220 221 this.os = "Unknown"; 222 }, 223 224 // Variables 225 noticeHeight: 0, 226 browser: '', 227 os: '', 228 browserVersion: '', 229 supportedBrowsers: [ 230 { 'cssClass': 'firefox', 'name': 'Mozilla Firefox', 'downloadUrl': 'http://www.getfirefox.com/' }, 231 { 'cssClass': 'chrome', 'name': 'Google Chrome', 'downloadUrl': 'http://www.google.com/chrome/' }, 232 { 'cssClass': 'msie', 'name': 'Internet Explorer', 'downloadUrl': 'http://www.getie.com/' }, 233 { 'cssClass': 'opera', 'name': 'Opera', 'downloadUrl': 'http://www.opera.com/' }, 234 { 'cssClass': 'safari', 'name': 'Apple Safari', 'downloadUrl': 'http://www.apple.com/safari/' } 235 ], 236 operatingSystems: [ 237 { 'searchString': navigator.platform, 'name': 'Windows', 'subStr': 'Win' }, 238 { 'searchString': navigator.platform, 'name': 'Mac', 'subStr': 'Mac' }, 239 { 'searchString': navigator.platform, 'name': 'Linux', 'subStr': 'Linux' }, 240 { 'searchString': navigator.userAgent, 'name': 'iPhone', 'subStr': 'iPhone/iPod' } 241 ], 242 defaultNotSupportedBrowsers: [{'os': 'Any', 'browser': 'MSIE', 'version': 6}, {'os': 'Any', 'browser': 'Firefox', 'version': 3}, {'os': 'Any', 'browser': 'Chrome', 'version': 1}], 243 noticeText: { 244 'professional': { "title": "Navigateur obsolète détecté", "notice": "Votre navigateur Internet semble obsolète, vous pouvez le mettre à jour, ou choisir l'un des navigateurs Internet suivant : ", "selectBrowser": "Lien de téléchargement : ", "remindMeLater": "Me le rappeler plus tard", "neverRemindAgain": "Non, ne jamais me le rappeler" }, 245 'informal': { "title": "Whoaaa!", "notice": "It appears you're using an outdated browser which prevents access to some of the features on our website. While it's not required, you really should <b>upgrade or install a new browser</b>!", "selectBrowser": "Visit the official sites for popular browsers below:", "remindMeLater": "Not now, but maybe later", "neverRemindAgain": "No, don't remind me again" }, 246 'technical': { "title": "Old Browser Alert! <span class='bd-highlight'>DEFCON 5</span>", "notice": "Come on! If you are hitting our site, then you must at least be partially tech savvy. So, why the older browser? We're not asking you to brush off your old Fibonacci Heap and share it with the class. Just upgrade!\nI know, I know. You don't like to be told what to do. But, we're only asking you to upgrade so you can access all the latest, greatest features on our site. It's quick and easy. But, if you still want to skip it, that's co
246ol. We will still welcome you — and your creepy old browser. :P", "selectBrowser": "Visit the official sites for popular browsers below:", "remindMeLater": "Remind me later", "neverRemindAgain": "No, don't remind me. I like my Commodore 64!" }, 247 'goofy': { "title": "Are You Serious?", "notice": "Are you really using <b>{browser_name}</b> as your browser?\nYou're surfing the web on a dinosaur (a dangerous one too — like a Tyrannosaurus or Pterodactyl or something scary like that). <b>Get with it and upgrade now!</b> If you do, we promise you will enjoy our site a whole lot more. :)", "selectBrowser": "Visit the official sites for popular browsers below:", "remindMeLater": "Maybe Later", "neverRemindAgain": "No, don't remind me again" }, 248 'mean': { "title": "Umm, Your Browser Sucks!", "notice": "Get a new one here.", "selectBrowser": "Official sites for popular browsers:", "remindMeLater": "Remind me later, a'hole", "neverRemindAgain": "F' off! My browser rocks!" } 249 } 250}; 251 252window.onload = function(){ 253 BrowserDetection.init(); 254};
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.