Move the message display code out of get_updates().

(imported from commit 9de20dbd11156cd98a11c736991945cba12b8118)
This commit is contained in:
Tim Abbott 2012-08-28 17:37:38 -04:00
parent 9625c17473
commit 74219b5e08
1 changed files with 10 additions and 8 deletions

View File

@ -135,12 +135,8 @@ $(function() {
setInterval(get_updates, 1000); setInterval(get_updates, 1000);
}); });
function get_updates() { function add_message(index, zephyr) {
var last_received = $("tr:last").attr("id"); var new_str = "<tr id=" + zephyr.id + "> \
$.post("get_updates", {last_received: last_received},
function(data) {
$.each(data, function(index, zephyr) {
var new_str = "<tr id=" + zephyr.id + "> \
<td class='pointer'><p></p></td> \ <td class='pointer'><p></p></td> \
<td class='zephyr'> \ <td class='zephyr'> \
<p><span onclick='narrow('" + zephyr.display_recipient + "','" + zephyr.id + "')' class='zephyr_class' style='background-color: yellow;'>" + zephyr.display_recipient + <p><span onclick='narrow('" + zephyr.display_recipient + "','" + zephyr.id + "')' class='zephyr_class' style='background-color: yellow;'>" + zephyr.display_recipient +
@ -148,8 +144,14 @@ function get_updates() {
zephyr.content + zephyr.content +
"</p></td> \ "</p></td> \
</tr>" </tr>"
$("#table tr:last").after(new_str); $("#table tr:last").after(new_str);
}); }
function get_updates() {
var last_received = $("tr:last").attr("id");
$.post("get_updates", {last_received: last_received},
function(data) {
$.each(data, add_message);
}, "json"); }, "json");
} }
</script> </script>