Paste #30
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 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Top Page - chat</title> </head> <body> <style type="text/css"> .poster { font-size: 80%; color: #999999; font-style: italic; } </style> <div id="status" style="float: right;"></div> <div> {% if request.user.is_anonymous() %} <a href="{{ create_login_url() }}">login</a> {% else %} Hello {{ request.user }}! <a href="{{ create_logout_url() }}">logout</a> {% endif %} </div> <div id="comment_form"> {{ form()|safe }} </div> <div id="recent_comments"> {% for comment in comments %} <div>{{ comment.content }}<span class="poster"> by {{ comment.get_owner() }}</span></div> {% endfor %} </div> <script type="text/javascript" src="{{ media_url }}/js/update_check_socket.js"> </script> <script type="text/javascript"> var cws = null; function updateComments() { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState==4) { var data = JSON.parse(xhr.responseText); document.getElementById('recent_comments').innerHTML=''; for (var i = 0; i < data.length; i++) { var comment_div = document.createElement('div'); comment_div.innerHTML = data[i].content+'<span class="poster"> by '+data[i].owner+'</span>'; document.getElementById('recent_comments').appendChild(comment_div); } } }; xhr.open("GET", "json", true); xhr.send(null); } window.addEventListener('load', function(e){ cws = new UpdateCheckSocket("mars.shehas.net", 10080, "/checkupdates", document.getElementById('status'), updateComments); function sendNOOP() { cws.send("NOOP"); setTimeout(sendNOOP, 60000); } setTimeout(sendNOOP, 60000); }, false); window.addEventListener('unload', function(e){ cws.ws.close(); }, false); document.forms[0].addEventListener('submit', function(e){ cws.ws.close(); return true; }, false); </script> </body> </html> |