From 712a013c44e0540d2a40a2cce1c8fcc4c13b6853 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 12 Oct 2015 10:24:44 +0200 Subject: [PATCH] Improved "see more" feature. --- .../ticket_zoom/article_view.coffee | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee index 0a161c81c..fd0aa00fe 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee @@ -108,25 +108,28 @@ class ArticleViewItem extends App.Controller return # prepare html body - signatureDetected = false if @article.content_type is 'text/html' @article['html'] = @article.body - else - - # check if signature got detected in backend - body = @article.body - if @article.preferences && @article.preferences.signature_detection - signatureDetected = '########SIGNATURE########' - body = body.split("\n") - body.splice(@article.preferences.signature_detection, 0, signatureDetected) - body = body.join("\n") - body = App.Utils.textCleanup(body) - @article['html'] = App.Utils.text2html(body) - - if signatureDetected - @article['html'] = @article['html'].replace(signatureDetected, '') - else @article['html'] = App.Utils.signatureIdentify( @article['html'] ) + else + + # client signature detection + bodyHtml = App.Utils.text2html(@article.body) + @article['html'] = App.Utils.signatureIdentify(bodyHtml) + + # if no signature detected or within frist 25 lines, check if signature got detected in backend + if @article['html'] is bodyHtml || (@article.preferences && @article.preferences.signature_detection < 25) + signatureDetected = false + body = @article.body + if @article.preferences && @article.preferences.signature_detection + signatureDetected = '########SIGNATURE########' + body = body.split("\n") + body.splice(@article.preferences.signature_detection, 0, signatureDetected) + body = body.join("\n") + if signatureDetected + body = App.Utils.textCleanup(body) + @article['html'] = App.Utils.text2html(body) + @article['html'] = @article['html'].replace(signatureDetected, '') @html App.view('ticket_zoom/article_view')( ticket: @ticket