From 9969e10b59bc94c1711f495ecc3fea8a6a2acf64 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 4 Oct 2019 15:51:42 +0200 Subject: [PATCH] Revert "added title and description changes based on area" This reverts commit 2cc7bdc9f64f13b7c3c00d1dc5fa1c3fbdb1c2e0. --- index.html | 8 ++++---- scripts/blog.js | 42 ++++++++++++------------------------------ scripts/main.js | 29 +---------------------------- 3 files changed, 17 insertions(+), 62 deletions(-) diff --git a/index.html b/index.html index df6af84..e92448b 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ Ellpeck.de - + @@ -16,9 +16,9 @@ - - - + + + diff --git a/scripts/blog.js b/scripts/blog.js index e7b521e..9695ff6 100644 --- a/scripts/blog.js +++ b/scripts/blog.js @@ -11,7 +11,7 @@ $.ajax({ let list = $('#blog-list'); list.html(""); for (let i = json.length - 1; i >= 0; i--) { - let obj = json[i]; + var obj = json[i]; let id = obj["id"]; let p = ""; @@ -22,69 +22,51 @@ $.ajax({ p += '
' + obj["summary"] + '
'; p += '
'; p += '' + obj["date"] + ""; - let discussLink = obj["discuss"]; + var discussLink = obj["discuss"]; if (discussLink) p += '' p += ''; list.append(p); $("#blog-button-" + id).on('click', function () { - let post = $("#blog-post-" + id); + var post = $("#blog-post-" + id); if (post.html() !== "") { - var newHash = "#blog"; - history.pushState(null, null, newHash); - updateMeta(newHash); - post.html(""); - let discuss = $("#blog-discuss-" + id); + var discuss = $("#blog-discuss-" + id); if (discuss.length) discuss.html(""); $("#blog-summary-" + id).show(); + history.pushState(null, null, "#blog"); } else { + openBlogPost(id); history.pushState(null, null, "#blog-" + id); - openBlogPost(obj); } }); } - var blogId = getBlogIdFromHash(window.location.hash); - if (blogId) { - for (var i = 0; i < json.length; i++) { - var obj = json[i]; - if (obj["id"] !== blogId) - continue; - - var anchor = $("#blog-" + blogId); - openBlogPost(obj, function () { + if (window.location.hash.startsWith("#blog-")) { + var anchor = $(window.location.hash); + if (anchor.length) { + openBlogPost(window.location.hash.substring(6), function () { $('html, body').animate({ scrollTop: anchor.offset().top }, 0) }); - break; } } } }); -function getBlogIdFromHash(hash) { - if (hash.startsWith("#blog-")) - return hash.substring(6); - return ""; -} - -function openBlogPost(obj, onDone) { - let id = obj["id"]; +function openBlogPost(id, onDone) { $.get("blog/" + id + ".md", function (markdown) { let html = converter.makeHtml(markdown); $("#blog-post-" + id).html(html); - let discuss = $("#blog-discuss-" + id); + var discuss = $("#blog-discuss-" + id); if (discuss.length) discuss.html("Discuss this post"); $("#blog-summary-" + id).hide(); - setTitleAndDesc(obj["name"], obj["summary"]); - PR.prettyPrint(); if (onDone) onDone(); diff --git a/scripts/main.js b/scripts/main.js index 19993ad..6e3f700 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -22,12 +22,7 @@ $(function () { openModals(window.location.hash); $('a').on('click', function () { openModals($(this).attr('href')); - }); - - updateMeta(window.location.hash); - $(window).on("hashchange", function () { - updateMeta(window.location.hash); - }); + });; $('.navbar-collapse a').on('click', function () { $('.navbar-collapse').collapse('hide'); @@ -48,28 +43,6 @@ $(function () { PR.prettyPrint(); }); -function updateMeta(hash) { - var title; - if (hash === "#projects") { - title = "Projects"; - } else if (hash === "#social") { - title = "Social"; - } else if (hash === "#about") { - title = "About" - } else if (hash === "#blog") { - title = "Blog" - } - setTitleAndDesc(title, "Ellpeck's little internet place"); -} - -function setTitleAndDesc(title, desc) { - let fullTitle = "Ellpeck.de" + (title ? " - " + title : ""); - $('meta[property="og:title"]').attr("content", fullTitle); - document.title = fullTitle; - $('meta[property="og:description"]').attr("content", desc); - $('meta[name="description"]').attr("content", desc); -} - function getCookie(key) { let c = document.cookie; if (!c)