2013-04-02 03:17:10 +08:00
|
|
|
//browser-update.org notification script, <browser-update.org>
|
|
|
|
//Copyright (c) 2007-2009, MIT Style License <browser-update.org/LICENSE.txt>
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
|
2013-04-02 14:44:08 +08:00
|
|
|
var $buo = function() {
|
|
|
|
|
2013-12-19 03:47:22 +08:00
|
|
|
var badAndroid = false, ua = null;
|
2013-12-03 03:18:33 +08:00
|
|
|
|
|
|
|
// Sometimes we have to resort to parsing the user agent string. :(
|
|
|
|
if (navigator && navigator.userAgent) {
|
|
|
|
ua = navigator.userAgent;
|
|
|
|
}
|
|
|
|
|
2019-05-06 08:45:45 +08:00
|
|
|
// sam: we require WeakMap, this allows us to easily feature detect IE10 that does not support it
|
|
|
|
// This also catches ancient android phones that never had that feature (2.2 and below)
|
|
|
|
if (window.WeakMap) {
|
2014-02-05 05:04:44 +08:00
|
|
|
return;
|
2013-04-02 14:44:08 +08:00
|
|
|
}
|
|
|
|
|
2013-12-24 04:13:09 +08:00
|
|
|
// we don't ask Googlebot to update their browser
|
2014-02-05 05:04:44 +08:00
|
|
|
if (ua.indexOf('Googlebot') >= 0 || ua.indexOf('Mediapartners') >= 0 || ua.indexOf('AdsBot') >= 0) {
|
|
|
|
return;
|
2013-12-24 04:13:09 +08:00
|
|
|
}
|
|
|
|
|
2013-04-02 15:42:59 +08:00
|
|
|
// retrieve localized browser upgrade text
|
2013-11-28 01:26:27 +08:00
|
|
|
var t = <%= "'" + I18n.t('js.browser_update') + "'" %>;
|
2013-04-02 14:44:08 +08:00
|
|
|
|
2013-04-02 15:42:59 +08:00
|
|
|
// create the notification div HTML
|
2013-04-02 14:44:08 +08:00
|
|
|
var div = document.createElement("div");
|
2013-04-02 15:42:59 +08:00
|
|
|
div.className = "buorg";
|
|
|
|
div.innerHTML = "<div>" + t + "</div>";
|
2013-04-02 14:44:08 +08:00
|
|
|
|
2013-04-02 15:42:59 +08:00
|
|
|
// create the notification div stylesheet
|
2013-04-02 14:44:08 +08:00
|
|
|
var sheet = document.createElement("style");
|
2013-04-02 15:42:59 +08:00
|
|
|
var style = ".buorg {position:absolute; z-index:111111; width:100%; top:0px; left:0px; background:#FDF2AB; text-align:left; font-family: sans-serif; color:#000; font-size: 14px;} .buorg div {padding: 8px;} .buorg a, .buorg a:visited {color:#E25600; text-decoration: underline;}";
|
2013-04-02 14:44:08 +08:00
|
|
|
|
2013-04-02 15:42:59 +08:00
|
|
|
// insert the div and stylesheet into the DOM
|
2014-02-06 23:47:59 +08:00
|
|
|
document.body.appendChild(div); // put it last in the DOM so Googlebot doesn't include it in search excerpts
|
2013-04-02 14:44:08 +08:00
|
|
|
document.getElementsByTagName("head")[0].appendChild(sheet);
|
|
|
|
try {
|
2013-04-02 15:42:59 +08:00
|
|
|
sheet.innerText = style;
|
|
|
|
sheet.innerHTML = style;
|
2013-04-02 14:44:08 +08:00
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
try {
|
|
|
|
sheet.styleSheet.cssText = style;
|
2013-04-02 03:17:10 +08:00
|
|
|
}
|
2013-04-02 14:44:08 +08:00
|
|
|
catch(ex) {
|
|
|
|
return;
|
2013-04-02 03:17:10 +08:00
|
|
|
}
|
2013-04-02 14:44:08 +08:00
|
|
|
}
|
2013-04-02 03:17:10 +08:00
|
|
|
|
2013-04-02 15:42:59 +08:00
|
|
|
// shift the body down to make room for our notification div
|
|
|
|
document.body.style.marginTop = (div.clientHeight) + "px";
|
2013-04-02 03:17:10 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-11-28 01:26:27 +08:00
|
|
|
$bu=$buo();
|
2013-04-02 03:17:10 +08:00
|
|
|
|
2016-01-03 15:49:52 +08:00
|
|
|
})(this);
|