aboutsummaryrefslogtreecommitdiff
path: root/static/js/journals/journal_view.js
blob: 863ddb74496db8d37df7c3803e24b7f6cb15344f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(function() {
    var host = document.getElementById('journal-entries-host');
    var template = document.getElementById('journal-entries-template');
    var shadow = host.attachShadow({ mode: 'open' });

    var styleUrls = JSON.parse(document.getElementById('journal-view-config').textContent);
    styleUrls.forEach(function(href) {
        var link = document.createElement('link');
        link.rel = 'stylesheet';
        link.type = 'text/css';
        link.href = href;
        shadow.appendChild(link);
    });

    shadow.appendChild(template.content.cloneNode(true));

    shadow.querySelectorAll('.entry-container .weblog-content').forEach(function(content) {
        content.querySelectorAll('img').forEach(function(img, i) {
            img.classList.add(i % 2 === 0 ? 'float-left' : 'float-right');
        });
    });
})();