nieuws: append create link to navigation block
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 17 Feb 2019 17:51:07 +0000 (18:51 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Sun, 3 Mar 2019 21:31:55 +0000 (22:31 +0100)
Assume an existing .nav container (for rss feed) where this admin option can
be added without conflict.

nieuws/edit.js

index 947de7b6a3b22001a3a365d9a484a577d2b17e92..2bb0c2004e50d12afe7063e7d9634eb137ff1fa1 100644 (file)
@@ -1,8 +1,7 @@
 document.addEventListener('DOMContentLoaded', () => {
-       var overview = document.getElementById('news');
-       if (overview) {
+       var nav = document.querySelector('#news .nav');
+       if (nav) {
                var editlink = document.createElement('a');
-               editlink.className = 'nav';
                editlink.appendChild(document.createTextNode('Nieuw artikel'));
                editlink.onclick = function () {
                        var today = new Date().toJSON().slice(0, 10).split('-');
@@ -14,7 +13,8 @@ document.addEventListener('DOMContentLoaded', () => {
                        window.location = window.location.pathname+'/'+url+'?edit='+title+'#edit';
                        return false;
                };
-               overview.appendChild(editlink);
+               nav.appendChild(document.createTextNode(' '));
+               nav.appendChild(editlink);
        }
 
        var editlink = document.querySelector('a[href="#edit"]');