1 document.addEventListener('DOMContentLoaded', () => {
2 var overview = document.getElementById('news');
4 var editlink = document.createElement('a');
5 editlink.className = 'nav';
6 editlink.appendChild(document.createTextNode('Nieuw artikel'));
7 editlink.onclick = function () {
8 var today = new Date().toJSON().slice(0, 10).split('-');
9 var input = prompt('Paginalink (beknopte titel)', '');
10 if (!input) return false;
11 var url = today[0] + '/' + today[1] + '-' + today[2] + '-' +
12 input.toLowerCase().replace(/[^a-z0-9]+/g, '-').trim();
13 var title = encodeURIComponent(input.trim());
14 window.location = window.location.pathname+'/'+url+'?edit='+title+'#edit';
17 overview.appendChild(editlink);