Improved signatureIdentify().

This commit is contained in:
Martin Edenhofer 2015-04-03 03:49:40 +02:00
parent 132e3c0362
commit 06341d543b
3 changed files with 43 additions and 12 deletions

View file

@ -507,7 +507,7 @@ class App.TicketZoom extends App.Controller
# set see more options # set see more options
setSeeMore: => setSeeMore: =>
maxHeight = 450 maxHeight = 480
@$('.textBubble-content').each( (index) -> @$('.textBubble-content').each( (index) ->
bubble = $( @ ) bubble = $( @ )
@ -519,10 +519,10 @@ class App.TicketZoom extends App.Controller
offsetTop = bubble.find('.js-signatureMarker').position() offsetTop = bubble.find('.js-signatureMarker').position()
# remember bubble heigth # remember bubble heigth
heigth = bubble.height() heigth = bubble.height()
if offsetTop if offsetTop
bubble.attr('data-height', heigth) 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') bubble.parent().find('.textBubble-overflowContainer').removeClass('hide')
else if heigth > maxHeight else if heigth > maxHeight
bubble.attr('data-height', heigth) bubble.attr('data-height', heigth)

View file

@ -243,27 +243,38 @@ class App.Utils
# search for Ms # search for Ms
# From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc] # From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
# Send: Donnerstag, 2. April 2015 10:00 # 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) -> searchForMs = (textToSearchInLines, markers) ->
lineCount = 0 lineCount = 0
fromFound = undefined fromFound = undefined
foundInLines = 0
subjectWithinLines = 5
for line in textToSearchInLines for line in textToSearchInLines
lineCount += 1 lineCount += 1
# find Sent # find Sent
if fromFound if fromFound
if line && line.match( /^(Sent|Gesendet):\s.+?/) if line && line.match( /^(Subject|Betreff):\s.+?/)
marker = marker =
line: fromFound line: fromFound
lineCount: lineCount lineCount: lineCount
type: 'Ms' type: 'Ms'
markers.push marker markers.push marker
else return
if lineCount > ( foundInLines + subjectWithinLines )
fromFound = undefined fromFound = undefined
# find From # find From
else else
if line && line.match( /^(From|Von):\s.+?/ ) 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) searchForMs(textToSearchInLines, markers)
# if no marker is found, return # if no marker is found, return

View file

@ -555,18 +555,38 @@ test( "identify signature", function() {
equal( result, should ) equal( result, should )
// ms // ms
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Gesendet: Donnerstag, 2. April 2015 10:00<br/>lalala</div>" message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Gesendet: Donnerstag, 2. April 2015 10:00<br/>Betreff: lalala</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Gesendet: Donnerstag, 2. April 2015 10:00<br/>lalala</div>' should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Gesendet: Donnerstag, 2. April 2015 10:00<br/>Betreff: lalala</div>'
result = App.Utils.signatureIdentify( message, true ) result = App.Utils.signatureIdentify( message, true )
equal( result, should ) equal( result, should )
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>lalala</div>" message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>lalala</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>lalala</div>' should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>lalala</div>'
result = App.Utils.signatureIdentify( message, true )
equal( result, should )
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>Subject: lalala</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>Subject: lalala</div>'
result = App.Utils.signatureIdentify( message, true )
equal( result, should )
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>1<br/>2<br/>3<br/>4<br/>4<br/>Subject: lalala</div>"
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>1<br/>2<br/>3<br/>4<br/>4<br/>Subject: lalala</div>'
result = App.Utils.signatureIdentify( message, true ) result = App.Utils.signatureIdentify( message, true )
equal( result, should ) equal( result, should )
message = "<div>1<br><br></div><div>Von: Martin Edenhofer via Znuny Support [<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div>" message = "<div>1<br><br></div><div>Von: Martin Edenhofer via Znuny Support [<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div>"
should = "<div>1<br><br></div><div><span class=\"js-signatureMarker\"></span>Von: Martin Edenhofer via Znuny Support [<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div>" should = "<div>1<br><br></div><div>Von: Martin Edenhofer via Znuny Support [<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div>"
result = App.Utils.signatureIdentify( message, true )
equal( result, should )
message = "<div>1<br><br></div><div>Von: Martin Edenhofer via Znuny Support [<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div><div>Betreff: lalala</div>"
should = "<div>1<br><br></div><div><span class=\"js-signatureMarker\"></span>Von: Martin Edenhofer via Znuny Support [<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div><div>Betreff: lalala</div>"
result = App.Utils.signatureIdentify( message, true )
equal( result, should )
message = "<div>1<br><br></div><div>Von: Martin Edenhofer via Znuny Support &lt;<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>&gt;</div>\n<div>An: somebody</div><div>Datum: Donnerstag, 2. April 2015 11:32</div><div>Betreff: lalala</div>"
should = "<div>1<br><br></div><div><span class=\"js-signatureMarker\"></span>Von: Martin Edenhofer via Znuny Support &lt;<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>&gt;</div>\n<div>An: somebody</div><div>Datum: Donnerstag, 2. April 2015 11:32</div><div>Betreff: lalala</div>"
result = App.Utils.signatureIdentify( message, true ) result = App.Utils.signatureIdentify( message, true )
equal( result, should ) equal( result, should )