diff --git a/app/js/craft-gl.js b/app/js/craft-gl.js index 7949e27..181851c 100644 --- a/app/js/craft-gl.js +++ b/app/js/craft-gl.js @@ -298,7 +298,7 @@ class Craft { run() { if (!WEBGL.isWebGLAvailable()) { - this.error(); + this.error('webgl'); return; } @@ -426,7 +426,7 @@ class Craft { this.blocks.clear(); }); this.socket.on("connect_error", () => { - this.error(); + this.error('socket'); }); } diff --git a/app/js/home.js b/app/js/home.js index a405d82..6c55843 100644 --- a/app/js/home.js +++ b/app/js/home.js @@ -1,5 +1,5 @@ import "./common"; -import Craft from './craft-gl'; +import Craft from "./craft-gl"; import CraftUI from "./craft-ui"; $(function() { @@ -13,36 +13,49 @@ $(function() { }); }); -let homeEnabled = true; const homenav = $("#home-nav"); const blognav = $("#blog-nav"); -if (window.location.hash) { - homenav.hide(); +let homeEnabled = true; + +if (!window.WEBGL.isWebGLAvailable()) { + homeEnabled = false; + $("#craft").hide(); + $("#craft-nav").hide(); + switchMode("blog"); } else { - blognav.hide(); + $(() => { + window.craft = new Craft($("#craft-gl")); + window.craft.error = e => { + console.log("Craft crashed :(", e); + homeEnabled = false; + $("#craft").hide(); + $("#craft-nav").hide(); + switchMode("blog"); + }; + window.craft.run(); + CraftUI("craft-ui"); + }); + switchMode("home"); } -$(() => { - window.craft = new Craft($("#craft-gl")); - window.craft.error = () => { - console.log('Craft crashed :('); - homeEnabled = false; - switchMode("blog"); - $("#craft").hide(); - $("#craft-nav").hide(); - }; - window.craft.run() - CraftUI('craft-ui') -}); +if (window.location.hash) { + switchMode("blog"); +} else { + switchMode("home"); +} function switchMode(mode) { + if (!homeEnabled) { + mode = "blog"; + } + if (mode == "blog") { - blognav.css('display', 'flex'); + blognav.css("display", "flex"); homenav.hide(); $('nav > a[href="#blog"]').addClass("active"); - } else if (mode == "home" && homeEnabled) { - homenav.css('display', 'flex'); + } else if (mode == "home") { + homenav.css("display", "flex"); blognav.hide(); $('nav > a[href="#blog"]').removeClass("active"); } diff --git a/layouts/index.html b/layouts/index.html index a8a5e10..22660f4 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -4,6 +4,7 @@ {{ if not .Paginator.HasPrev }}
+
diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html index 8794bd5..89ea710 100644 --- a/layouts/partials/nav.html +++ b/layouts/partials/nav.html @@ -9,7 +9,7 @@ {{ with .Site.Params.about }}{{ . }}{{ else }}About{{ end }} {{ end }} -