From a8fa6b156aa355c8089429af3a2ec40e68aff198 Mon Sep 17 00:00:00 2001 From: Jessica McKellar Date: Wed, 29 Aug 2012 16:47:53 -0400 Subject: [PATCH] Turn newlines into linebreaks. (imported from commit 67999641a8cff471be1430e421f259b1c558444d) --- templates/zephyr/index.html | 2 +- zephyr/static/js/zephyr.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/templates/zephyr/index.html b/templates/zephyr/index.html index e13079aa61..04c81d16e6 100644 --- a/templates/zephyr/index.html +++ b/templates/zephyr/index.html @@ -26,7 +26,7 @@ {% endif %} {{ zephyr.sender.user.username }}
-{{ zephyr.content }} +{{ zephyr.content|linebreaksbr }}

{% endfor %} diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index dac8c04bc2..f29c687d6b 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -183,6 +183,10 @@ $(function() { setInterval(get_updates, 1000); }); +function newline2br(content) { + return content.replace(/\n/g, '
'); +} + function add_message(index, zephyr) { var new_str = "" + "

" + @@ -200,7 +204,7 @@ function add_message(index, zephyr) { } new_str += "" + zephyr.sender + "
" - + zephyr.content + + + newline2br(zephyr.content) + "

" + ""; $("#table tr:last").after(new_str);