summaryrefslogtreecommitdiff
path: root/src/pages/guestbook.php
blob: f84b92dbd099e93e8e3e1bc48e136dc57c060378 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<param:title>Guestbook</param:title>
<param:active-link>guestbook</param:active-link>

<div id="guestbook_frame"></div>

<div id="guestbook"></div>

<script type="text/javascript" src="/static/jquery-1.12.4.min.js"></script>
<script>
function htmlentities(str) {
    return str.replace(/&/g, "&amp;")
        .replace(/</g, "&lt;")
        .replace(/>/g, "&gt;")
        .replace(/"/g, "&quot;")
        .replace(/'/g, "&#039;");
}

function nl2br(str, xhtml) {
    if (typeof xhtml === "undefined") xhtml = true;
    return str.replace(/\n/g, "<br" + (xhtml ? " /" : "") + ">");
}

$(function() {
    $("#guestbook_frame").append(
        $("<iframe></iframe>")
            .attr("id", "gbframe")
            .attr("frameborder", "0")
            .attr("src", "//guestbook.hozyro.jkohl.link/?__e=1&__p[ok_target]=_top&__p[ok_url]=" + encodeURIComponent(location.href))
    );
})

function _gbcb(data) {
    $.each(data.entries, function(i, entry) {
        $("<div></div>")
            .addClass("guestbook-entry")
            .append(
                $("<div></div>")
                    .addClass("guestbook-header")
                    .append(
                        $("<strong></strong>")
                            .addClass("guestbook-author-name")
                            .text(entry.author.name),
                        " ",
                        $("<span></span>")
                            .addClass("guestbook-author-email")
                            .text("(" + entry.author.email + ")")
                    ),
                $("<div></div>")
                    .addClass("guestbook-date")
                    .text(entry.published),
                $("<div></div>")
                    .addClass("guestbook-content")
                    .html(nl2br(htmlentities(entry.content)))
            ).appendTo("#guestbook")
    })
}
</script>
<script type="text/javascript" src="//guestbook.hozyro.jkohl.link/?__m=ajax&amp;__r=jsonp&amp;__c=_gbcb"></script>