diff options
| author | Jonas Kohl | 2024-07-23 16:34:35 +0200 | 
|---|---|---|
| committer | Jonas Kohl | 2024-07-23 16:34:35 +0200 | 
| commit | 252e4cfa9c2236e50f38adc4611396a5665f8301 (patch) | |
| tree | 17a3359490f99ecbce2548d775a782fba6c40417 /src/pages | |
| parent | e163c5950aa74278401679190fb7d755f730fa04 (diff) | |
Add codegen & emoticons
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/guestbook.php | 52 | 
1 files changed, 48 insertions, 4 deletions
| diff --git a/src/pages/guestbook.php b/src/pages/guestbook.php index f84b92d..2d40089 100644 --- a/src/pages/guestbook.php +++ b/src/pages/guestbook.php @@ -2,10 +2,11 @@  <param:active-link>guestbook</param:active-link>  <div id="guestbook_frame"></div> - +<p><a href="#" id="emoticon-guide">Emoticon guide</a></p>  <div id="guestbook"></div>  <script type="text/javascript" src="/static/jquery-1.12.4.min.js"></script> +<script type="text/javascript" src="/emoticons.js"></script>  <script>  function htmlentities(str) {      return str.replace(/&/g, "&") @@ -20,13 +21,56 @@ function nl2br(str, xhtml) {      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" ' + +                EMOTICONS[0][i][1] +  +                ' 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)) +            .attr("src", "//guestbook.web.local/?__e=1&__p[ok_target]=_top&__p[ok_url]=" + encodeURIComponent(location.href))      ); +    $("#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><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" ' + +                EMOTICONS[0][idx][1] +  +                ' 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) { @@ -50,9 +94,9 @@ function _gbcb(data) {                      .text(entry.published),                  $("<div></div>")                      .addClass("guestbook-content") -                    .html(nl2br(htmlentities(entry.content))) +                    .html(replace_emoticons(nl2br(htmlentities(entry.content))))              ).appendTo("#guestbook")      })  }  </script> -<script type="text/javascript" src="//guestbook.hozyro.jkohl.link/?__m=ajax&__r=jsonp&__c=_gbcb"></script> +<script type="text/javascript" src="//guestbook.web.local/?__m=ajax&__r=jsonp&__c=_gbcb"></script> |