From 06341d543b5f5513bc8fade3b44e06d1564bd53a Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 3 Apr 2015 03:49:40 +0200 Subject: [PATCH] Improved signatureIdentify(). --- .../app/controllers/ticket_zoom.js.coffee | 6 ++-- .../app/lib/app_post/utils.js.coffee | 21 ++++++++++---- public/assets/tests/html-utils.js | 28 ++++++++++++++++--- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index 72824f5b7..a3e20387f 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -507,7 +507,7 @@ class App.TicketZoom extends App.Controller # set see more options setSeeMore: => - maxHeight = 450 + maxHeight = 480 @$('.textBubble-content').each( (index) -> bubble = $( @ ) @@ -519,10 +519,10 @@ class App.TicketZoom extends App.Controller offsetTop = bubble.find('.js-signatureMarker').position() # remember bubble heigth - heigth = bubble.height() + heigth = bubble.height() if offsetTop bubble.attr('data-height', heigth) - bubble.css('height', "#{offsetTop.top + 42}px") + bubble.css('height', "#{offsetTop.top + 30}px") bubble.parent().find('.textBubble-overflowContainer').removeClass('hide') else if heigth > maxHeight bubble.attr('data-height', heigth) diff --git a/app/assets/javascripts/app/lib/app_post/utils.js.coffee b/app/assets/javascripts/app/lib/app_post/utils.js.coffee index f2e5dcda3..b23ead13f 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.js.coffee @@ -243,27 +243,38 @@ class App.Utils # search for Ms # From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc] # Send: Donnerstag, 2. April 2015 10:00 + # To/Cc/Bcc: xxx + # Subject: xxx + # - or - + # From: xxx + # To/Cc/Bcc: xxx + # Date: 01.04.2015 12:41 + # Subject: xxx searchForMs = (textToSearchInLines, markers) -> - lineCount = 0 - fromFound = undefined + lineCount = 0 + fromFound = undefined + foundInLines = 0 + subjectWithinLines = 5 for line in textToSearchInLines lineCount += 1 # find Sent if fromFound - if line && line.match( /^(Sent|Gesendet):\s.+?/) + if line && line.match( /^(Subject|Betreff):\s.+?/) marker = line: fromFound lineCount: lineCount type: 'Ms' markers.push marker - else + return + if lineCount > ( foundInLines + subjectWithinLines ) fromFound = undefined # find From else if line && line.match( /^(From|Von):\s.+?/ ) - fromFound = line.replace(/\s{0,5}\[.+?\]/g, '') + fromFound = line.replace(/\s{0,5}(\[|<).+?(\]|>)/g, '') + foundInLines = lineCount searchForMs(textToSearchInLines, markers) # if no marker is found, return diff --git a/public/assets/tests/html-utils.js b/public/assets/tests/html-utils.js index 3fcc28fac..ff4f24d0c 100644 --- a/public/assets/tests/html-utils.js +++ b/public/assets/tests/html-utils.js @@ -555,18 +555,38 @@ test( "identify signature", function() { equal( result, should ) // ms - message = "
test 123

--no not match--

Bob Smith
Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Gesendet: Donnerstag, 2. April 2015 10:00
lalala
" - should = '
test 123

--no not match--

Bob Smith
Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Gesendet: Donnerstag, 2. April 2015 10:00
lalala
' + message = "
test 123

--no not match--

Bob Smith
Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Gesendet: Donnerstag, 2. April 2015 10:00
Betreff: lalala
" + should = '
test 123

--no not match--

Bob Smith
Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Gesendet: Donnerstag, 2. April 2015 10:00
Betreff: lalala
' result = App.Utils.signatureIdentify( message, true ) equal( result, should ) message = "
test 123

--no not match--

Bob Smith
From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Sent: Donnerstag, 2. April 2015 10:00
lalala
" - should = '
test 123

--no not match--

Bob Smith
From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Sent: Donnerstag, 2. April 2015 10:00
lalala
' + should = '
test 123

--no not match--

Bob Smith
From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Sent: Donnerstag, 2. April 2015 10:00
lalala
' + result = App.Utils.signatureIdentify( message, true ) + equal( result, should ) + + message = "
test 123

--no not match--

Bob Smith
From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Sent: Donnerstag, 2. April 2015 10:00
Subject: lalala
" + should = '
test 123

--no not match--

Bob Smith
From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Sent: Donnerstag, 2. April 2015 10:00
Subject: lalala
' + result = App.Utils.signatureIdentify( message, true ) + equal( result, should ) + + message = "
test 123

--no not match--

Bob Smith
From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Sent: Donnerstag, 2. April 2015 10:00
1
2
3
4
4
Subject: lalala
" + should = '
test 123

--no not match--

Bob Smith
From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Sent: Donnerstag, 2. April 2015 10:00
1
2
3
4
4
Subject: lalala
' result = App.Utils.signatureIdentify( message, true ) equal( result, should ) message = "
1

Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
\n
Gesendet: Donnerstag, 2. April 2015 11:32
" - should = "
1

Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
\n
Gesendet: Donnerstag, 2. April 2015 11:32
" + should = "
1

Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
\n
Gesendet: Donnerstag, 2. April 2015 11:32
" + result = App.Utils.signatureIdentify( message, true ) + equal( result, should ) + + message = "
1

Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
\n
Gesendet: Donnerstag, 2. April 2015 11:32
Betreff: lalala
" + should = "
1

Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
\n
Gesendet: Donnerstag, 2. April 2015 11:32
Betreff: lalala
" + result = App.Utils.signatureIdentify( message, true ) + equal( result, should ) + + message = "
1

Von: Martin Edenhofer via Znuny Support <mailto:support@znuny.inc>
\n
An: somebody
Datum: Donnerstag, 2. April 2015 11:32
Betreff: lalala
" + should = "
1

Von: Martin Edenhofer via Znuny Support <mailto:support@znuny.inc>
\n
An: somebody
Datum: Donnerstag, 2. April 2015 11:32
Betreff: lalala
" result = App.Utils.signatureIdentify( message, true ) equal( result, should )