Root/
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 | {% extends "base.html" %} {% block content %} < div class = "centered" > < div class = "checkbox" > < label > < input type = "checkbox" id = "random" class = "set-tooltip" title="Checking this box will match you with anyone - including those that don't match what you are looking for. You and the other party must have this box checked for it to create a match." {% if session.random %} checked = "checked" {% endif %} > Match random users</ label > </ div > < div id = "container" > < button title = "You may or may not be matched with the same person again" type = "button" id = "newMatch" class = "set-tooltip btn btn-primary" >Find new match</ button > < button title = "This will prevent the person at the current session from talking to you and match you with a new person" id = "banAndNewMatch" type = "button" class = "set-tooltip btn btn-danger" >Ignore and find new match</ button > < br > < br > < textarea disabled = "disabled" autocomplete = "off" cols = "100" rows = "25" id = "chat" ></ textarea > < br > < input autocomplete = "off" style = "width: 725px;" placeholder = "Your message here..." type = "text" id = "input" >< br > </ div > </ div > < script type = "text/javascript" > $(function () { $("#newMatch").click(function () { location.reload(); }); $("#banAndNewMatch").click(function () { $.get("./main/ignoresession/", function () { location.reload(); }); }); $(".set-tooltip").tooltip(); $("#random").change(function (e) { console.log(e); $.post("./main/togglerandom", {random: $(this).is(":checked")}); }); var searching = true; function appendChat(text) { var chatVal = $("#chat").val(); chatVal += text + "\n"; $("#chat").val(chatVal); } function poll() { setTimeout(function() { // hit the read endpoint // the read endpoint will return false if matching is in progress // otherwise will return an array $.ajax({ url: "./main/read/", success: function (data) { if (data === false) { $("#container").waitMe({ effect: "ios", text: "Finding match. Please wait...", bg: 'rgba(255,255,255,0.7)', color: '#000', maxSize: '' }); searching = true; } else { $("#container").waitMe("hide"); if (searching) { appendChat("Friendly Replicator Android (Fran): Match found!"); searching = !searching; } if (data) { $.each(data, function (index, value) { appendChat(value); }); } } }, dataType: "json", complete: poll }); }, 2000); } $('#input').keydown(function (e){ if(e.keyCode == 13){ var val = $("#input").val(); $("#input").val(""); appendChat("You: " + val); $.post("./main/send/", {message : val}); } }); $("#container").waitMe({ effect: "ios", text: "Finding match. Please wait...", bg: 'rgba(255,255,255,0.7)', color: '#000', maxSize: '' }); poll(); }); </ script > {% endblock %} |