aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/notification.php
blob: 0b105bd2c41a9b77b9229affcbe8047119672c83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<div class="notification">
    <div class="notifImage">
        <?php if ($imageUrl != null): ?>
            <?php if ($imageLink != null): ?>
                <a href="<?= $imageLink ?>">
                <?php endif; ?>
                <img src="<?= $imageUrl ?>">
                <?php if ($imageLink != null): ?>
                </a>
            <?php endif; ?>
        <?php endif; ?>
    </div>
    <div class="notifContent">
        <?php if ($titleLink != null): ?>
            <a href="<?= $titleLink ?>">
            <?php endif; ?>
            <span class="title"><?= htmlspecialchars($title) ?></span>
            <?php if ($titleLink != null): ?>
            </a>
        <?php endif; ?>
        <span class="body"><?= htmlspecialchars($body, double_encode: false) ?></span>
    </div>
    <div hidden class="notifier" <?php if ($unread ?? false): ?> _="
        on load
            set title to innerText of previous .title
            set body to innerText of previous .body
            set icon to @src of previous <img/>
            set titleLink to previous <a/>
            js(title, body, icon, titleLink)
                let n = new Notification(title, { body: body, icon: icon })
                n.addEventListener('click', () => titleLink.click())
            end
    " <?php endif; ?>></div>
</div>