From 4a8ed1d1fb8feea9dd738c71c378194a66115fbb Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Fri, 7 Apr 2017 21:15:52 +0200 Subject: [PATCH] show comments with breaks after 80 chars and tab subsequent lines in. --- app/views/request_for_comments/show.html.erb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/views/request_for_comments/show.html.erb b/app/views/request_for_comments/show.html.erb index 658cdeab..57c48828 100644 --- a/app/views/request_for_comments/show.html.erb +++ b/app/views/request_for_comments/show.html.erb @@ -141,7 +141,7 @@ also, all settings from the rails model needed for the editor configuration in t jqrequest.done(function(response){ $.each(response, function(index, comment) { comment.className = "code-ocean_comment"; - comment.text = comment.username + ": " + comment.text + comment.text = comment.username + ": " + stringDivider(comment.text, 80, "\n\t\t"); }); session.setAnnotations(response); @@ -268,4 +268,20 @@ also, all settings from the rails model needed for the editor configuration in t text: message.length > 0 ? message : $('#flash').data('message-failure') }); }; + + + function stringDivider(str, width, spaceReplacer) { + if (str.length>width) { + var p=width + for (;p>0 && str[p]!=' ';p--) { + } + if (p>0) { + var left = str.substring(0, p); + var right = str.substring(p+1); + return left + spaceReplacer + stringDivider(right, width, spaceReplacer); + } + } + return str; + } +