17 lines
608 B
JavaScript
17 lines
608 B
JavaScript
(function () {
|
|
var content = document.querySelector('.content');
|
|
if (!content) return;
|
|
var headings = content.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
|
if (!headings.length) return;
|
|
|
|
// Section 0 is pre-heading content, editable via full-page edit.
|
|
// Sections 1..N each start at a heading; that is the index sent to the server.
|
|
headings.forEach(function (h, i) {
|
|
var a = document.createElement('a');
|
|
a.href = '?edit§ion=' + (i + 1);
|
|
a.className = 'btn btn-small section-edit';
|
|
a.textContent = 'edit';
|
|
h.appendChild(a);
|
|
});
|
|
}());
|