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;
|
|
|
|
}
|
|
|
|
if (ua && (ua.indexOf('Android 2.2') >= 0 || ua.indexOf('Android 2.3') >= 0)) {
|
|
|
|
// Android 2.2 and 2.3 browsers report that they have pushState, but they don't really.
|
|
|
|
// See http://caniuse.com/#search=pushstate
|
|
|
|
badAndroid = true;
|
|
|
|
}
|
|
|
|
|
2016-01-03 15:49:52 +08:00
|
|
|
// sam: my main concern here is mobile, but its an outlier, for now we support ie10, set conditionally and stuff with pushState
|
2013-12-03 03:18:33 +08:00
|
|
|
if (window.ie === "new" || (window.history && window.history.pushState && !badAndroid)) {
|
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);
|