Improved signatureIdentify().
This commit is contained in:
parent
132e3c0362
commit
06341d543b
|
@ -507,7 +507,7 @@ class App.TicketZoom extends App.Controller
|
|||
|
||||
# set see more options
|
||||
setSeeMore: =>
|
||||
maxHeight = 450
|
||||
maxHeight = 480
|
||||
@$('.textBubble-content').each( (index) ->
|
||||
bubble = $( @ )
|
||||
|
||||
|
@ -522,7 +522,7 @@ class App.TicketZoom extends App.Controller
|
|||
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)
|
||||
|
|
|
@ -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
|
||||
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
|
||||
|
|
|
@ -555,18 +555,38 @@ test( "identify signature", function() {
|
|||
equal( result, should )
|
||||
|
||||
// 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>"
|
||||
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>'
|
||||
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/>Betreff: 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/>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 )
|
||||
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>"
|
||||
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 <<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>></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 <<a href=\"mailto:support@znuny.inc\" title=\"mailto:support@znuny.inc\" target=\"_blank\">mailto:support@znuny.inc</a>></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 )
|
||||
equal( result, should )
|
||||
|
||||
|
|
Loading…
Reference in a new issue