Ver Fonte

Add outdated browser warning

Riccardo Balbo há 4 anos atrás
pai
commit
8f7859c185

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "static/browser-update"]
+	path = static/browser-update
+	url = https://github.com/browser-update/browser-update

+ 5 - 1
layouts/_default/baseof.html

@@ -6,8 +6,12 @@
   <title>{{ block "title" . }}{{ .Site.Title }} {{ with .Params.Title }} | {{ . }}{{ end }}{{ end }}</title>
   <meta name="viewport" content="width=device-width,minimum-scale=1">
   <meta name="description" content="jMonkeyEngine is a modern developer friendly game engine written primarily in Java.  ">
-
+  
   <link rel="stylesheet" href="/css/style.css"> 
+
+  <script src="/js/old-browser.js"></script>
+  <link rel="stylesheet" href="/css/old-browser.css"> 
+
   
   <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.min.js" integrity="sha512-WIklPM6qPCIp6d3fSSr90j+1unQHUOoWDS4sdTiR8gxUTnyZ8S2Mr8e10sKKJ/bhJgpAa/qG068RDkg6fIlNFA==" crossorigin="anonymous"></script> -->
 

+ 1 - 0
static/browser-update

@@ -0,0 +1 @@
+Subproject commit c1b88cd013171d6c4494231a746b4d69a469b04f

+ 13 - 0
static/css/old-browser.css

@@ -0,0 +1,13 @@
+body .buorg {
+    border-radius:1vmin;
+    border: 0.1vmin solid #030303;
+    color: rgb(0, 0, 0);
+    background-color: #c8b50b;
+    text-shadow: none!important;
+    font-size:0.8rem;
+    opacity:0.9;
+}
+body #buorgig, body #buorgul, body #buorgpermanent{
+    color: rgb(0, 0, 0)!important;
+
+}

+ 67 - 0
static/js/old-browser.js

@@ -0,0 +1,67 @@
+$buoop = {
+    required: { i: 8, f: 25, o: 17, s: 9, c: 22 },
+    style:"corner",
+    insecure:false,
+    // Specifies required browser versions
+    // Browsers older than this will be notified.
+    // f:22 ---> Firefox < 22 gets notified
+    // Negative numbers specify how much versions behind current version.
+    // c:-5 ---> Chrome < 35  gets notified if latest Chrome version is 40.
+    // more details (in english)
+
+    reminder: 24,
+    // after how many hours should the message reappear
+    // 0 = show all the time
+
+    reminderClosed: 150,
+    // if the user explicitly closes message it reappears after x hours
+
+    onshow: function (infos) { },
+    onclick: function (infos) { },
+    onclose: function (infos) { },
+    // callback functions after notification has appeared / was clicked / closed
+
+    l: false,
+    // set a fixed language for the message, e.g. "en". This overrides the default detection.
+
+    test: false,
+    // true = always show the bar (for testing)
+
+    text: "<b>Your browser ({brow_name}) is out of date.</b><br />This website requires a modern browser to function properly. You can continue using the site with your current browser, but some features will be disabled. <br /><center><a{ignore_but}>Ok</a></center>",
+    // custom notification text (html)
+    // Placeholders {brow_name} will be replaced with the browser name, {up_but} with contents of the update link tag and {ignore_but} with contents for the ignore link.
+    // Example: "Your browser, {brow_name}, is too old: <a{up_but}>update</a> or <a{ignore_but}>ignore</a>."
+    // more details (in english)
+
+
+    newwindow: true,
+    // open link in new window/tab
+
+    url: null,
+    // the url to go to after clicking the notification
+
+    noclose: false,
+    // Do not show the "ignore" button to close the notification
+
+    nomessage: false,
+    // Do not show a message if the browser is out of date, just call the onshow callback function
+
+    jsshowurl: "/browser-update/scripts/update.show.js",
+    // URL where the script, that shows the notification, is located. This is only loaded if the user actually has an outdated browser.
+
+    container: document.body,
+    // DOM Element where the notification will be injected.
+
+    no_permanent_hide: false
+    // Do not give the user the option to permanently hide the notification
+
+
+};
+
+function $buo_f() {
+    var e = document.createElement("script");
+    e.src = "/browser-update/scripts/update.js";
+    document.body.appendChild(e);
+};
+try { document.addEventListener("DOMContentLoaded", $buo_f, false) }
+catch (e) { window.attachEvent("onload", $buo_f) }

+ 1 - 1
static/js/utils.js

@@ -144,7 +144,7 @@ window.addEventListener("DOMContentLoaded", function () {
         window.scrollTo(0, 0);
         if (location.hash) {
             const contentAnchor = document.querySelector(location.hash);
-            scrollTo(contentAnchor);
+            if(contentAnchor)scrollTo(contentAnchor);
         } else {
             const contentAnchor = document.querySelector("#content");
             if (contentAnchor) scrollTo(contentAnchor);