diff --git a/index.html b/index.html index a6b15b7..d5c2468 100644 --- a/index.html +++ b/index.html @@ -166,6 +166,10 @@
The content that should be here is dynamically generated. Please enable JavaScript if you see this.
+ +
+ The content that should be here is dynamically generated. Please enable JavaScript if you see this. +
diff --git a/scripts/blog.js b/scripts/blog.js index 7f9a32d..2c55889 100644 --- a/scripts/blog.js +++ b/scripts/blog.js @@ -1,15 +1,20 @@ +$("#blog-archive-button").on("click", function () { + let archive = $('#blog-archive'); + archive.toggle(); + $(this).html((archive.is(":visible") ? "Hide" : "Show") + " archived posts"); +}); + $.ajax({ dataType: "json", url: "blog/posts.json", cache: false, success: function (json) { let list = $('#blog-list'); + let archive = $('#blog-archive'); list.html(""); + archive.html(""); for (let i = json.length - 1; i >= 0; i--) { var obj = json[i]; - if (obj.archived) - continue; - let p = ""; p += '
'; p += '
'; @@ -17,7 +22,11 @@ $.ajax({ p += '
' + obj.summary + '
'; p += '' + obj.date + ""; p += '
'; - list.append(p); + if (obj.archived) { + archive.append(p); + } else { + list.append(p); + } } } }); \ No newline at end of file diff --git a/style/style.css b/style/style.css index 9824cf2..ad13412 100644 --- a/style/style.css +++ b/style/style.css @@ -72,6 +72,19 @@ body { text-align: center; } +#blog-archive-button { + display: block; + position: relative; + margin-top: 20px; + margin-left: auto; + margin-right: 0; + padding: 0; +} + +#blog-archive { + display: none; +} + .anchor { display: block; position: relative;