summaryrefslogtreecommitdiff
path: root/src/pages/guestbook.php
blob: 0b44dac9f7a63933926e7aea38afec26ee93fbf0 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<param:title>Guestbook</param:title>
<param:active-link>guestbook</param:active-link>

<h1>Guestbook</h1>

<div id="guestbook_frame" class="is-loading"></div>
<p><a href="#" id="emoticon-guide"><span>Emoticon guide</span></a></p>
<div id="guestbook" class="is-loading h32"></div>

<script type="text/javascript" src="/static/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="/emoticons.js?<?= md5(strval(time())) ?>"></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 replace_emoticons(html) {
    for (var i = 0; i < EMOTICONS[0].length; ++i) {
        html = html.split(":" + EMOTICONS[0][i][0] + ":")
            .join(
                '<img src="/static/emoticons/' + EMOTICONS[0][i][0] + '.gif" ' +
                ' width="' + EMOTICONS[0][i][1] + '"' + 
                ' height="' + EMOTICONS[0][i][2] + '"' + 
                ' alt="' + EMOTICONS[0][i][0] + '"' +
                ' title=":' + EMOTICONS[0][i][0] + ':" />'
            );
    }
    return html;
}

$(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))
            .on("load", function() {
                $("#guestbook_frame").removeClass("is-loading");
            })
    );
    $("#emoticon-guide").click(function(e) {
        e.preventDefault();
        var win = window.open("about:blank", "emguide", "width=260,height=450,left=0,top=0,popup=yes,toolbar=no,menubar=no,scrollbars=yes");
        //win.document.title = "Emoticon guide";
        win.document.open();
        win.document.write('<html><head>');
        win.document.write('<title>Emoticon guide</title>');
        win.document.write('</head><body bgcolor="#05456a">');
        win.document.write('<center>');
        win.document.write('<table border=1 bgcolor=white cellspacing=0><tbody>');
        var idx = 0;
        for (var i = 0; i < EMOTICONS[1].length; ++i) {
            idx = EMOTICONS[1][i];
            win.document.write(
                "<tr><td>" + 
                '<img src="/static/emoticons/' + EMOTICONS[0][idx][0] + '.gif"' +
                ' width="' + EMOTICONS[0][idx][1] + '"' + 
                ' height="' + EMOTICONS[0][idx][2] + '"' + 
                ' alt="' + EMOTICONS[0][idx][0] + '"' +
                ' title=":' + EMOTICONS[0][idx][0] + ':" />' +
                "</td><td><font face=Verdana size=2>" +
                ":" + EMOTICONS[0][idx][0] + ":" +
                "</font></td></tr>\n"
            );
        }
        win.document.write('</tbody></table>');
        win.document.write('</center>');
        win.document.write('</body></html>');
        win.document.close();
        return;
    });
})

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(replace_emoticons(nl2br(htmlentities(entry.content))))
            ).appendTo("#guestbook")
    })

    $("#guestbook").removeClass("h32 is-loading");
}
</script>
<script type="text/javascript" src="//guestbook.hozyro.jkohl.link/?__m=ajax&amp;__r=jsonp&amp;__c=_gbcb"></script>