html_utils.js 164 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382
  1. window.onload = function() {
  2. // textCleanup
  3. test("textCleanup", function() {
  4. var source = "Some\nValue\n\n\nTest"
  5. var should = "Some\nValue\n\nTest"
  6. var result = App.Utils.textCleanup(source)
  7. equal(result, should, source)
  8. source = "Some\nValue\n\n \n\n\nTest"
  9. should = "Some\nValue\n\nTest"
  10. result = App.Utils.textCleanup(source)
  11. equal(result, should, source)
  12. source = "Some\n\rValue\n\r\n\r\n\rTest"
  13. should = "Some\nValue\n\nTest"
  14. result = App.Utils.textCleanup(source)
  15. equal(result, should, source)
  16. source = "Some\n\rValue\n\r\n\r\n\rTest\r"
  17. should = "Some\nValue\n\nTest"
  18. result = App.Utils.textCleanup(source)
  19. equal(result, should, source)
  20. source = "Some\r\nValue\r\n\r\n\r\nTest\r\n"
  21. should = "Some\nValue\n\nTest"
  22. result = App.Utils.textCleanup(source)
  23. equal(result, should, source)
  24. source = "Some\r\nValue\r\n\r\n\r\n\r\n\r\n\r\nTest\r\n"
  25. should = "Some\nValue\n\nTest"
  26. result = App.Utils.textCleanup(source)
  27. equal(result, should, source)
  28. source = "> Welcome!\n> \n> Thank you for installing Zammad.\n> \n> You will find ..."
  29. should = "> Welcome!\n>\n> Thank you for installing Zammad.\n>\n> You will find ..."
  30. result = App.Utils.textCleanup(source)
  31. equal(result, should, source)
  32. });
  33. // text2html
  34. test("text2html", function() {
  35. var source = "Some\nValue\n\n\nTest"
  36. var should = "<div>Some</div><div>Value</div><div><br></div><div>Test</div>"
  37. var result = App.Utils.text2html(source)
  38. equal(result, should, source)
  39. source = "Some\nValue\n"
  40. should = "<div>Some</div><div>Value</div>"
  41. result = App.Utils.text2html(source)
  42. equal(result, should, source)
  43. source = "Some\n<b>Value</b>\n"
  44. should = "<div>Some</div><div>&lt;b&gt;Value&lt;/b&gt;</div>"
  45. result = App.Utils.text2html(source)
  46. equal(result, should, source)
  47. source = "> Welcome!\n> \n> Thank you for installing Zammad.\n> \n> You will find ..."
  48. should = "<div>&gt; Welcome!</div><div>&gt;</div><div>&gt; Thank you for installing Zammad.</div><div>&gt;</div><div>&gt; You will find ...</div>"
  49. result = App.Utils.text2html(source)
  50. equal(result, should, source)
  51. source = "Some\nValue\n"
  52. should = "<div>Some</div><div>Value</div>"
  53. result = App.Utils.text2html(source)
  54. equal(result, should, source)
  55. source = "Some\rValue\r"
  56. should = "<div>Some</div><div>Value</div>"
  57. result = App.Utils.text2html(source)
  58. equal(result, should, source)
  59. source = "Some\n\rValue\n\r"
  60. should = "<div>Some</div><div>Value</div>"
  61. result = App.Utils.text2html(source)
  62. equal(result, should, source)
  63. source = "Some\r\nValue\r\n"
  64. should = "<div>Some</div><div>Value</div>"
  65. result = App.Utils.text2html(source)
  66. equal(result, should, source)
  67. source = "Some Value 123"
  68. should = "<div>Some &nbsp; Value 123</div>"
  69. result = App.Utils.text2html(source)
  70. equal(result, should, source)
  71. source = "Some\n Value\n 123"
  72. should = "<div>Some</div><div> &nbsp; Value</div><div> &nbsp; &nbsp;123</div>"
  73. result = App.Utils.text2html(source)
  74. equal(result, should, source)
  75. });
  76. // htmlStrip
  77. test("htmlStrip", function() {
  78. var source = $('<div><br><b>lala</b></div>')
  79. var should = '<div><b>lala</b></div>'
  80. App.Utils.htmlStrip(source)
  81. equal(source.get(0).outerHTML, should)
  82. source = $('<div><br><br><br><b>lala</b></div>')
  83. should = '<div><b>lala</b></div>'
  84. App.Utils.htmlStrip(source)
  85. equal(source.get(0).outerHTML, should)
  86. source = $('<div><br><br><br><b>lala</b><br><br></div>')
  87. should = '<div><b>lala</b></div>'
  88. App.Utils.htmlStrip(source)
  89. equal(source.get(0).outerHTML, should)
  90. source = $('<div><br><br><div><br></div><b>lala</b><br><br></div>')
  91. should = '<div><div><br></div><b>lala</b></div>'
  92. App.Utils.htmlStrip(source)
  93. equal(source.get(0).outerHTML, should)
  94. });
  95. // lastLineEmpty
  96. test("htmlLastLineEmpty", function() {
  97. var source = $('<div><br><b>lala</b></div>')
  98. equal(App.Utils.htmlLastLineEmpty(source), false)
  99. source = $('<div><br><b>lala</b><br></div>')
  100. equal(App.Utils.htmlLastLineEmpty(source), true)
  101. });
  102. // html2text
  103. test("html2text", function() {
  104. var source = "<div>Some</div><div>Value</div><div><br></div><div>Test</div>"
  105. var should = "Some\nValue\n\nTest"
  106. var result = App.Utils.html2text(source)
  107. equal(result, should, source)
  108. source = "<div>Some</div><div>Value</div>"
  109. should = "Some\nValue"
  110. result = App.Utils.html2text(source)
  111. equal(result, should, source)
  112. source = "<div>Some<br/>Value</div>"
  113. should = "Some\nValue"
  114. result = App.Utils.html2text(source)
  115. equal(result, should, source)
  116. source = "<div>Some &amp; &lt;Value&gt;</div>"
  117. should = "Some & <Value>"
  118. result = App.Utils.html2text(source)
  119. equal(result, should, source)
  120. source = "<div>Some</div><div>&lt;b&gt;Value&lt;/b&gt;</div>"
  121. should = "Some\n<b>Value</b>"
  122. result = App.Utils.html2text(source)
  123. equal(result, should, source)
  124. source = "<div>&gt; Welcome!</div><div>&gt;</div><div>&gt; Thank you for installing Zammad.</div><div>&gt;</div><div>&gt; You will find ...</div>"
  125. should = "> Welcome!\n>\n> Thank you for installing Zammad.\n>\n> You will find ..."
  126. result = App.Utils.html2text(source)
  127. equal(result, should, source)
  128. source = "<div>test 123 <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>--<br/>Bob Smith</div>"
  129. should = "test 123 \n\n--\nBob Smith"
  130. result = App.Utils.html2text(source)
  131. equal(result, should, source)
  132. source = "test 123 <br><br><br><br><br><br><br><br><br><br><br>--<br>Bob Smith"
  133. should = "test 123 \n\n--\nBob Smith"
  134. result = App.Utils.html2text(source)
  135. equal(result, should, source)
  136. source = "<div>1<br><br><br><br><br><br><br><br><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>"
  137. should = "1\n\nVon: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]\nGesendet: Donnerstag, 2. April 2015 11:32"
  138. result = App.Utils.html2text(source)
  139. equal(result, should, source)
  140. source = "<div>test 123<br/>lalala<p>--</p>some test</div>"
  141. should = "test 123\nlalala\n--\nsome test"
  142. result = App.Utils.html2text(source)
  143. equal(result, should, source)
  144. source = "<p><span>Was\nsoll verbessert werden:</span></p>"
  145. should = "Was soll verbessert werden:"
  146. result = App.Utils.html2text(source)
  147. equal(result, should, source)
  148. // in raw format, without cleanup
  149. source = "<div>Some</div><div>1234</div>"
  150. should = "Some\n1234\n"
  151. result = App.Utils.html2text(source, true)
  152. equal(result, should, source)
  153. source = "<div>Some</div><div> 1234</div>"
  154. should = "Some\n 1234\n"
  155. result = App.Utils.html2text(source, true)
  156. equal(result, should, source)
  157. source = "\n\n<div>Some</div>\n<div> 1234</div>"
  158. should = "Some\n 1234\n"
  159. result = App.Utils.html2text(source, true)
  160. equal(result, should, source)
  161. source = "<div>Some</div><div> 1234</div>"
  162. should = "Some\n 1234\n"
  163. result = App.Utils.html2text(source, true)
  164. equal(result, should, source)
  165. source = "<div>Some</div>\n\n<div> 1234</div>\n"
  166. should = "Some\n 1234\n"
  167. result = App.Utils.html2text(source, true)
  168. equal(result, should, source)
  169. source = "<div>test<br>new line<br></div>"
  170. should = "test\nnew line\n\n"
  171. result = App.Utils.html2text(source, true)
  172. equal(result, should, source)
  173. source = "<p><span>Was\nsoll verbessert werden:</span></p>"
  174. should = "Was soll verbessert werden:\n"
  175. result = App.Utils.html2text(source, true)
  176. equal(result, should, source)
  177. });
  178. // phoneify
  179. test("phoneify", function() {
  180. var source = "+1 123 123 123-123"
  181. var should = 'tel:+1123123123123'
  182. var result = App.Utils.phoneify(source)
  183. equal(result, should, source)
  184. source = "+1 123 123 A 123-123<>"
  185. should = 'tel:+1123123123123'
  186. result = App.Utils.phoneify(source)
  187. equal(result, should, source)
  188. source = "+1 (123) 123 123-123"
  189. should = 'tel:+1123123123123'
  190. result = App.Utils.phoneify(source)
  191. equal(result, should, source)
  192. source = "+1 (123) 123 1#23-123"
  193. should = 'tel:+11231231#23123'
  194. result = App.Utils.phoneify(source)
  195. equal(result, should, source)
  196. source = "+1 (123) 12*3 1#23-123"
  197. should = 'tel:+112312*31#23123'
  198. result = App.Utils.phoneify(source)
  199. equal(result, should, source)
  200. source = "+1 (123) 12+3"
  201. should = 'tel:+1123123'
  202. result = App.Utils.phoneify(source)
  203. equal(result, should, source)
  204. source = "+1 (123) 123 "
  205. should = 'tel:+1123123'
  206. result = App.Utils.phoneify(source)
  207. equal(result, should, source)
  208. source = " +1 (123) 123 "
  209. should = 'tel:+1123123'
  210. result = App.Utils.phoneify(source)
  211. equal(result, should, source)
  212. })
  213. // linkify
  214. test("linkify", function() {
  215. var source = "http://example.com"
  216. var should = '<a href="http://example.com" title="http://example.com" target="_blank">http://example.com</a>'
  217. var result = App.Utils.linkify(source)
  218. equal(result, should, source)
  219. source = "http://example.com?some_param=lalala"
  220. should = '<a href="http://example.com?some_param=lalala" title="http://example.com?some_param=lalala" target="_blank">http://example.com?some_param=lalala</a>'
  221. result = App.Utils.linkify(source)
  222. equal(result, should, source)
  223. source = "example.com"
  224. should = '<a href="http://example.com" title="http://example.com" target="_blank">example.com</a>'
  225. result = App.Utils.linkify(source)
  226. equal(result, should, source)
  227. source = "some text example.com"
  228. should = 'some text <a href="http://example.com" title="http://example.com" target="_blank">example.com</a>'
  229. result = App.Utils.linkify(source)
  230. equal(result, should, source)
  231. source = "example.com some text"
  232. should = '<a href="http://example.com" title="http://example.com" target="_blank">example.com</a> some text'
  233. result = App.Utils.linkify(source)
  234. equal(result, should, source)
  235. source = "test@example.com some text"
  236. should = 'test@example.com some text'
  237. result = App.Utils.linkify(source)
  238. equal(result, should, source)
  239. source = "abc test@example.com some text"
  240. should = 'abc test@example.com some text'
  241. result = App.Utils.linkify(source)
  242. equal(result, should, source)
  243. /*
  244. source = "<b>example.com</b>"
  245. should = '<b><a href="http://example.com" title="http://example.com" target="_blank">http://example.com</a></b>'
  246. result = App.Utils.linkify(source)
  247. equal(result, should, source)
  248. */
  249. });
  250. // htmlEscape
  251. test("htmlEscape", function() {
  252. var source = "<"
  253. var should = "&lt;"
  254. var result = App.Utils.htmlEscape(source)
  255. equal(result, should, source)
  256. source = ">"
  257. should = "&gt;"
  258. result = App.Utils.htmlEscape(source)
  259. equal(result, should, source)
  260. source = "&"
  261. should = "&amp;"
  262. result = App.Utils.htmlEscape(source)
  263. equal(result, should, source)
  264. source = "&amp;"
  265. should = "&amp;amp;"
  266. result = App.Utils.htmlEscape(source)
  267. equal(result, should, source)
  268. source = "&amp ;"
  269. should = "&amp;amp ;"
  270. result = App.Utils.htmlEscape(source)
  271. equal(result, should, source)
  272. source = "& amp;"
  273. should = "&amp; amp;"
  274. result = App.Utils.htmlEscape(source)
  275. equal(result, should, source)
  276. source = "'test'"
  277. should = "&#39;test&#39;"
  278. result = App.Utils.htmlEscape(source)
  279. equal(result, should, source)
  280. source = '"test"'
  281. should = "&quot;test&quot;"
  282. result = App.Utils.htmlEscape(source)
  283. equal(result, should, source)
  284. source = "<>"
  285. should = "&lt;&gt;"
  286. result = App.Utils.htmlEscape(source)
  287. equal(result, should, source)
  288. source = "<&lt;>"
  289. should = "&lt;&amp;lt;&gt;"
  290. result = App.Utils.htmlEscape(source)
  291. equal(result, should, source)
  292. });
  293. // htmlRemoveTags
  294. test("htmlRemoveTags", function() {
  295. var source = "<div>test</div>"
  296. //var should = "<div>test</div>"
  297. var should = "test"
  298. var result = App.Utils.htmlRemoveTags($(source))
  299. equal(result.html(), should, source)
  300. source = "<div>test<!-- some comment --></div>"
  301. //should = "<div>test</div>"
  302. should = "test"
  303. result = App.Utils.htmlRemoveTags($(source))
  304. equal(result.html(), should, source)
  305. source = "<a href=\"some_link\">some link to somewhere</a>"
  306. should = "some link to somewhere"
  307. result = App.Utils.htmlRemoveTags($(source))
  308. equal(result.html(), should, source)
  309. source = "<div><a href=\"some_link\">some link to somewhere</a></div>"
  310. //should = "<div>some link to somewhere</div>"
  311. should = "some link to somewhere"
  312. result = App.Utils.htmlRemoveTags($(source))
  313. equal(result.html(), should, source)
  314. source = "<div><a href=\"some_link\">some link to somewhere</a><input value=\"should not be shown\"></div>"
  315. //should = "<div>some link to somewhere</div>"
  316. should = "some link to somewhere"
  317. result = App.Utils.htmlRemoveTags($(source))
  318. equal(result.html(), should, source)
  319. source = "<div><a href=\"some_link\">some link to somewhere</a> <div><hr></div> <span>123</span> <img src=\"some_image\"/></div>"
  320. //should = "<div>some link to somewhere 123 </div>"
  321. should = "some link to somewhere 123 "
  322. result = App.Utils.htmlRemoveTags($(source))
  323. equal(result.html(), should, source)
  324. });
  325. // htmlRemoveRichtext
  326. test("htmlRemoveRichtext", function() {
  327. source = "<div><form class=\"xxx\">test 123</form><svg><use xlink:href=\"assets/images/icons.svg#icon-status\"></svg></div>"
  328. //should = "<div>test 123</div>"
  329. should = "test 123"
  330. result = App.Utils.htmlRemoveRichtext($(source))
  331. equal(result.html(), should, source)
  332. source = "<div><textarea class=\"xxx\">test 123</textarea></div>"
  333. //should = "<div>test 123</div>"
  334. should = "test 123"
  335. result = App.Utils.htmlRemoveRichtext($(source))
  336. equal(result.html(), should, source)
  337. source = "<div><p wrap=\"\">test 123</p></div>"
  338. should = "<p>test 123</p>"
  339. result = App.Utils.htmlRemoveRichtext($(source))
  340. equal(result.html(), should, source)
  341. source = "<div><font size=\"3\" color=\"red\">This is some text!</font></div>"
  342. should = "This is some text!"
  343. result = App.Utils.htmlRemoveRichtext($(source))
  344. equal(result.html(), should, source)
  345. should = "This is some text!"
  346. result = App.Utils.htmlRemoveRichtext(source)
  347. equal(result.html(), should, source)
  348. var source = "<div><!--test comment--><a href=\"test\">test</a></div>"
  349. //var should = "<div>test</div>"
  350. var should = "test"
  351. var result = App.Utils.htmlRemoveRichtext($(source))
  352. equal(result.html(), should, source)
  353. source = "<div><!--[if !supportLists]--><span lang=\"DE\">1.1.1<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><!--[endif]--><span lang=\"DE\">Description</span></div>"
  354. //should = "<div><span>1.1.1<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span>Description</span></div>"
  355. should = "<span>1.1.1<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span>Description</span>"
  356. //should = '1.1.1 Description'
  357. result = App.Utils.htmlRemoveRichtext($(source))
  358. equal(result.html(), should, source)
  359. source = "<a href=\"some_link\">some link to somewhere</a>"
  360. should = "some link to somewhere"
  361. result = App.Utils.htmlRemoveRichtext($(source))
  362. equal(result.html(), should, source)
  363. source = "<div><a href=\"some_link\"></a> test </div>"
  364. //should = "<div> test </div>"
  365. should = " test "
  366. result = App.Utils.htmlRemoveRichtext($(source))
  367. equal(result.html(), should, source)
  368. source = "<div><b></b> test </div>"
  369. //should = "<div> test </div>"
  370. should = " test "
  371. result = App.Utils.htmlRemoveRichtext($(source))
  372. equal(result.html(), should, source)
  373. source = "<div><div><b></b> test </div></div>"
  374. //should = "<div><div> test </div></div>"
  375. should = "<div> test </div>"
  376. result = App.Utils.htmlRemoveRichtext($(source))
  377. equal(result.html(), should, source)
  378. source = "<div><div><b></b> test <input value=\"should not be shown\"></div></div>"
  379. //should = "<div><div> test </div></div>"
  380. should = "<div> test </div>"
  381. result = App.Utils.htmlRemoveRichtext($(source))
  382. equal(result.html(), should, source)
  383. source = "<div><div><b></b> test </div><span>123</span></div>"
  384. //should = "<div><div> test </div><span>123</span></div>"
  385. should = "<div> test </div><span>123</span>"
  386. //should = '<div> test </div>123'
  387. result = App.Utils.htmlRemoveRichtext($(source))
  388. equal(result.html(), should, source)
  389. source = "<div><div class=\"xxx\" title=\"some title\" lang=\"en\"><b></b> test </div></div>"
  390. //should = "<div><div> test </div></div>"
  391. should = "<div> test </div>"
  392. result = App.Utils.htmlRemoveRichtext($(source))
  393. equal(result.html(), should, source)
  394. source = "<div><textarea class=\"xxx\"> test </textarea></div>"
  395. //should = "<div> test </div>"
  396. should = " test "
  397. result = App.Utils.htmlRemoveRichtext($(source))
  398. equal(result.html(), should, source)
  399. source = "<div><br></div>"
  400. //should = "<div><br></div>"
  401. should = "<br>"
  402. result = App.Utils.htmlRemoveRichtext($(source))
  403. equal(result.html(), should, source)
  404. source = "<div><div class=\"xxx\"><br></div></div>"
  405. //should = "<div><div><br></div></div>"
  406. should = "<div><br></div>"
  407. result = App.Utils.htmlRemoveRichtext($(source))
  408. equal(result.html(), should, source)
  409. source = "<div><form class=\"xxx\">test 123</form></div>"
  410. //should = "<div>test 123</div>"
  411. should = "test 123"
  412. result = App.Utils.htmlRemoveRichtext($(source))
  413. equal(result.html(), should, source)
  414. source = "<div><div><label for=\"Ticket_888344_group_id\">Gruppe <span>*</span></label></div><div><div></div></div><div><div><span></span><span></span></div></div><div><div><label for=\"Ticket_888344_owner_id\">Besitzer <span></span></label></div><div><div></div></div></div><div><div><div><svg><use xlink:href=\"http://localhost:3000/assets/images/icons.svg#icon-arrow-down\"></use></svg></div><span></span><span></span></div></div><div><div> <label for=\"Ticket_888344_state_id\">Status <span>*</span></label></div></div></div>\n"
  415. //should = "<div>test 123</div>"
  416. should = '<div>Gruppe <span>*</span></div><div><div></div></div><div><div><span></span><span></span></div></div><div><div>Besitzer <span></span></div><div><div></div></div></div><div><div><div></div><span></span><span></span></div></div><div><div> Status <span>*</span></div></div>'
  417. result = App.Utils.htmlRemoveRichtext(source)
  418. equal(result.html(), should, source)
  419. source = "<div><font size=\"3\" color=\"red\">This is some text!</font><svg><use xlink:href=\"assets/images/icons.svg#icon-status\"></svg></div>"
  420. should = "This is some text!"
  421. result = App.Utils.htmlRemoveRichtext($(source))
  422. equal(result.html(), should, source)
  423. should = "This is some text!"
  424. result = App.Utils.htmlRemoveRichtext(source)
  425. equal(result.html(), should, source)
  426. var source = "<div><!--test comment--><a href=\"test\">test</a></div>"
  427. var should = "<div>test</div>"
  428. var result = App.Utils.htmlRemoveRichtext($(source))
  429. equal(result.get(0).outerHTML, should, source)
  430. source = "<div><small>some link to somewhere</small></a>"
  431. should = "<div>some link to somewhere</div>"
  432. result = App.Utils.htmlRemoveRichtext($(source))
  433. equal(result.get(0).outerHTML, should, source)
  434. source = "<div><div class=\"xxx\"><br></div></div>"
  435. should = "<div><div><br></div></div>"
  436. result = App.Utils.htmlRemoveRichtext($(source))
  437. equal(result.get(0).outerHTML, should, source)
  438. source = "<div><table bgcolor=\"green\" aaa=\"1\"><thead><tr><th>111</th><th colspan=\"2\" abc=\"a\">aaa</th></tr></thead><tbody><tr><td>key</td><td>value</td></tr></tbody></table></div>"
  439. should = "<div>111aaakeyvalue</div>"
  440. result = App.Utils.htmlRemoveRichtext(source, true)
  441. equal(result.get(0).outerHTML, should, source)
  442. });
  443. // htmlCleanup
  444. test("htmlCleanup", function() {
  445. var source = "<div><!--test comment--><a href=\"test\">test</a></div>"
  446. //var should = "<div>test</div>"
  447. var should = "<a href=\"test\">test</a>"
  448. var result = App.Utils.htmlCleanup($(source))
  449. equal(result.html(), should, source)
  450. source = "<div><!--test comment--><a href=\"test\">test</a></div>"
  451. should = "<a href=\"test\">test</a>"
  452. result = App.Utils.htmlCleanup(source)
  453. equal(result.html(), should, source)
  454. source = "some link to somewhere"
  455. should = "some link to somewhere"
  456. result = App.Utils.htmlCleanup(source)
  457. equal(result.html(), should, source)
  458. source = "<li>a</li><li>b</li>"
  459. should = "<li>a</li><li>b</li>"
  460. result = App.Utils.htmlCleanup(source)
  461. equal(result.html(), should, source)
  462. source = "<a href=\"some_link\">some link to somewhere</a>"
  463. should = "some link to somewhere"
  464. result = App.Utils.htmlCleanup($(source))
  465. equal(result.html(), should, source)
  466. source = "<p><a href=\"some_link\">some link to somewhere</a><p>"
  467. should = "<a href=\"some_link\">some link to somewhere</a>"
  468. result = App.Utils.htmlCleanup($(source))
  469. equal(result.html(), should, source)
  470. source = "<div><h1>some link to somewhere</h1></div>"
  471. should = "<h1>some link to somewhere</h1>"
  472. result = App.Utils.htmlCleanup($(source))
  473. equal(result.html(), should, source)
  474. source = "<div><p id=\"123\" data-id=\"abc\">some link to somewhere</p></div>"
  475. should = "<p>some link to somewhere</p>"
  476. result = App.Utils.htmlCleanup($(source))
  477. equal(result.html(), should, source)
  478. source = "<div><small>some link to somewhere</small></a>"
  479. //should = "<div>some link to somewhere</div>"
  480. should = "some link to somewhere"
  481. result = App.Utils.htmlCleanup($(source))
  482. equal(result.html(), should, source)
  483. source = "<div><time>some link to somewhere</time></a>"
  484. //should = "<div>some link to somewhere</div>"
  485. should = "some link to somewhere"
  486. result = App.Utils.htmlCleanup($(source))
  487. equal(result.html(), should, source)
  488. source = "<div><h1>some h1 for somewhere</h1><p><hr></p></div>"
  489. should = "<h1>some h1 for somewhere</h1><p></p><hr><p></p>"
  490. result = App.Utils.htmlCleanup($(source))
  491. equal(result.html(), should, source)
  492. source = "<div><br></div>"
  493. //should = "<div><br></div>"
  494. should = "<br>"
  495. result = App.Utils.htmlCleanup($(source))
  496. equal(result.html(), should, source)
  497. source = "<div><div class=\"xxx\"><br></div></div>"
  498. //should = "<div><div><br></div></div>"
  499. should = "<div><br></div>"
  500. result = App.Utils.htmlCleanup($(source))
  501. equal(result.html(), should, source)
  502. source = "<div><form class=\"xxx\">test 123</form></div>"
  503. //should = "<div>test 123<br></div>"
  504. should = "test 123"
  505. result = App.Utils.htmlCleanup($(source))
  506. equal(result.html(), should, source)
  507. source = "<div><form class=\"xxx\">test 123</form> some other value</div>"
  508. //should = "<div>test 123 some other value</div>"
  509. should = "test 123 some other value"
  510. result = App.Utils.htmlCleanup($(source))
  511. equal(result.html(), should, source)
  512. source = "<div><form class=\"xxx\">test 123</form> some other value<input value=\"should not be shown\"></div>"
  513. //should = "<div>test 123 some other value</div>"
  514. should = "test 123 some other value"
  515. result = App.Utils.htmlCleanup($(source))
  516. equal(result.html(), should, source)
  517. source = "<div><font size=\"3\" color=\"red\">This is some text!</font><svg><use xlink:href=\"assets/images/icons.svg#icon-status\"></svg></div>"
  518. //should = "<div>This is some text!</div>"
  519. should = "This is some text!"
  520. result = App.Utils.htmlCleanup($(source))
  521. equal(result.html(), should, source)
  522. source = "<div><p>some link to somewhere from word<w:sdt>abc</w:sdt></p><o:p></o:p></a>"
  523. //should = "<div><p>some link to somewhere from wordabc</p></div>"
  524. should = '<p>some link to somewhere from wordabc</p>'
  525. result = App.Utils.htmlCleanup($(source))
  526. equal(result.html(), should, source)
  527. source = "<div><div><label for=\"Ticket_888344_group_id\">Gruppe <span>*</span></label></div><div><div></div></div><div><div><span></span><span></span></div></div><div><div><label for=\"Ticket_888344_owner_id\">Besitzer <span></span></label></div><div><div></div></div></div><div><div><div><svg><use xlink:href=\"http://localhost:3000/assets/images/icons.svg#icon-arrow-down\"></use></svg></div><span></span><span></span></div></div><div><div> <label for=\"Ticket_888344_state_id\">Status <span>*</span></label></div></div></div>\n"
  528. //should = "<div>test 123</div>"
  529. should = '<div>Gruppe <span>*</span></div><div><div></div></div><div><div><span></span><span></span></div></div><div><div>Besitzer <span></span></div><div><div></div></div></div><div><div><div></div><span></span><span></span></div></div><div><div> Status <span>*</span></div></div>'
  530. result = App.Utils.htmlCleanup(source)
  531. equal(result.html(), should, source)
  532. source = "<html xmlns:o=\"urn:schemas-microsoft-com:office:office\"\nxmlns:w=\"urn:schemas-microsoft-com:office:word\"\nxmlns:m=\"http://schemas.microsoft.com/office/2004/12/omml\"\nxmlns=\"http://www.w3.org/TR/REC-html40\">\n\n<head>\n<meta name=Titel content=\"\">\n<meta name=Stichwörter content=\"\">\n<meta http-equiv=Content-Type content=\"text/html; charset=utf-8\">\n<meta name=ProgId content=Word.Document>\n<meta name=Generator content=\"Microsoft Word 15\">\n<meta name=Originator content=\"Microsoft Word 15\">\n<link rel=File-List\nhref=\"file://localhost/Users/johannes/Library/Group%20Containers/UBF8T346G9.Office/msoclip1/01/clip_filelist.xml\">\n<!--[if gte mso 9]><xml>\n <o:OfficeDocumentSettings>\n <o:AllowPNG/>\n <o:PixelsPerInch>96</o:PixelsPerInch>\n </o:OfficeDocumentSettings>\n</xml><![endif]-->\n<link rel=themeData\nhref=\"file://localhost/Users/johannes/Library/Group%20Containers/UBF8T346G9.Office/msoclip1/01/clip_themedata.thmx\">\n<!--[if gte mso 9]><xml>\n <w:WordDocument>\n <w:View>Normal</w:View>\n <w:Zoom>0</w:Zoom>\n <w:TrackMoves/>\n <w:TrackFormatting/>\n <w:HyphenationZone>21</w:HyphenationZone>\n <w:PunctuationKerning/>\n <w:ValidateAgainstSchemas/>\n <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>\n <w:IgnoreMixedContent>false</w:IgnoreMixedContent>\n <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>\n <w:DoNotPromoteQF/>\n <w:LidThemeOther>DE</w:LidThemeOther>\n <w:LidThemeAsian>X-NONE</w:LidThemeAsian>\n <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>\n <w:Compatibility>\n <w:BreakWrappedTables/>\n <w:SnapToGridInCell/>\n <w:WrapTextWithPunct/>\n <w:UseAsianBreakRules/>\n <w:DontGrowAutofit/>\n <w:SplitPgBreakAndParaMark/>\n <w:EnableOpenTypeKerning/>\n <w:DontFlipMirrorIndents/>\n <w:OverrideTableStyleHps/>\n </w:Compatibility>\n <m:mathPr>\n <m:mathFont m:val=\"Cambria Math\"/>\n <m:brkBin m:val=\"before\"/>\n <m:brkBinSub m:val=\"&#45;-\"/>\n <m:smallFrac m:val=\"off\"/>\n <m:dispDef/>\n <m:lMargin m:val=\"0\"/>\n <m:rMargin m:val=\"0\"/>\n <m:defJc m:val=\"centerGroup\"/>\n <m:wrapIndent m:val=\"1440\"/>\n <m:intLim m:val=\"subSup\"/>\n <m:naryLim m:val=\"undOvr\"/>\n </m:mathPr></w:WordDocument>\n</xml><![endif]--><!--[if gte mso 9]><xml>\n <w:LatentStyles DefLockedState=\"false\" DefUnhideWhenUsed=\"false\"\n DefSemiHidden=\"false\" DefQFormat=\"false\" DefPriority=\"99\"\n LatentStyleCount=\"380\">\n <w:LsdException Locked=\"false\" Priority=\"0\" QFormat=\"true\" Name=\"Normal\"/>\n <w:LsdException Locked=\"false\" Priority=\"0\" QFormat=\"true\" Name=\"heading 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"0\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"0\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"0\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"0\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"9\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"9\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 7\"/>\n <w:LsdException Locked=\"false\" Priority=\"9\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 8\"/>\n <w:LsdException Locked=\"false\" Priority=\"9\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 9\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 6\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 7\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 8\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 9\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 7\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 8\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 9\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Normal Indent\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"footnote text\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"annotation text\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"header\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"footer\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index heading\"/>\n <w:LsdException Locked=\"false\" Priority=\"35\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"caption\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"table of figures\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"envelope address\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"envelope return\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"footnote reference\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"annotation reference\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"line number\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"page number\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"endnote reference\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"endnote text\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"table of authorities\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"macro\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"toa heading\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Bullet\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Number\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Bullet 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Bullet 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Bullet 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Bullet 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Number 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Number 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Number 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Number 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"10\" QFormat=\"true\" Name=\"Title\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Closing\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Signature\"/>\n <w:LsdException Locked=\"false\" Priority=\"1\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"Default Paragraph Font\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text Indent\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Continue\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Continue 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Continue 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Continue 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Continue 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Message Header\"/>\n <w:LsdException Locked=\"false\" Priority=\"11\" QFormat=\"true\" Name=\"Subtitle\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Salutation\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Date\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text First Indent\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text First Indent 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Heading\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text Indent 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text Indent 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Block Text\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Hyperlink\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"FollowedHyperlink\"/>\n <w:LsdException Locked=\"false\" Priority=\"22\" QFormat=\"true\" Name=\"Strong\"/>\n <w:LsdException Locked=\"false\" Priority=\"20\" QFormat=\"true\" Name=\"Emphasis\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Document Map\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Plain Text\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"E-mail Signature\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Top of Form\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Bottom of Form\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Normal (Web)\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Acronym\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Address\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Cite\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Code\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Definition\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Keyboard\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Preformatted\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Sample\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Typewriter\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Variable\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Normal Table\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"annotation subject\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"No List\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Outline List 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Outline List 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Outline List 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Simple 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Simple 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Simple 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Classic 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Classic 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Classic 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Classic 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Colorful 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Colorful 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Colorful 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Columns 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Columns 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Columns 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Columns 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Columns 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 6\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 7\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 8\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 6\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 7\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 8\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table 3D effects 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table 3D effects 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table 3D effects 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Contemporary\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Elegant\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Professional\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Subtle 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Subtle 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Web 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Web 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Web 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Balloon Text\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" Name=\"Table Grid\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Theme\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 6\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 7\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 8\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 9\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" Name=\"Placeholder Text\"/>\n <w:LsdException Locked=\"false\" Priority=\"1\" QFormat=\"true\" Name=\"No Spacing\"/>\n <w:LsdException Locked=\"false\" Priority=\"60\" Name=\"Light Shading\"/>\n <w:LsdException Locked=\"false\" Priority=\"61\" Name=\"Light List\"/>\n <w:LsdException Locked=\"false\" Priority=\"62\" Name=\"Light Grid\"/>\n <w:LsdException Locked=\"false\" Priority=\"63\" Name=\"Medium Shading 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"64\" Name=\"Medium Shading 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"65\" Name=\"Medium List 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"66\" Name=\"Medium List 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"67\" Name=\"Medium Grid 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"68\" Name=\"Medium Grid 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"69\" Name=\"Medium Grid 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"70\" Name=\"Dark List\"/>\n <w:LsdException Locked=\"false\" Priority=\"71\" Name=\"Colorful Shading\"/>\n <w:LsdException Locked=\"false\" Priority=\"72\" Name=\"Colorful List\"/>\n <w:LsdException Locked=\"false\" Priority=\"73\" Name=\"Colorful Grid\"/>\n <w:LsdException Locked=\"false\" Priority=\"60\" Name=\"Light Shading Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"61\" Name=\"Light List Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"62\" Name=\"Light Grid Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"63\" Name=\"Medium Shading 1 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"64\" Name=\"Medium Shading 2 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"65\" Name=\"Medium List 1 Accent 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" Name=\"Revision\"/>\n <w:LsdException Locked=\"false\" Priority=\"34\" QFormat=\"true\"\n Name=\"List Paragraph\"/>\n <w:LsdException Locked=\"false\" Priority=\"29\" QFormat=\"true\" Name=\"Quote\"/>\n <w:LsdException Locked=\"false\" Priority=\"30\" QFormat=\"true\"\n Name=\"Intense Quote\"/>\n <w:LsdException Locked=\"false\" Priority=\"66\" Name=\"Medium List 2 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"67\" Name=\"Medium Grid 1 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"68\" Name=\"Medium Grid 2 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"69\" Name=\"Medium Grid 3 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"70\" Name=\"Dark List Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"71\" Name=\"Colorful Shading Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"72\" Name=\"Colorful List Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"73\" Name=\"Colorful Grid Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"60\" Name=\"Light Shading Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"61\" Name=\"Light List Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"62\" Name=\"Light Grid Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"63\" Name=\"Medium Shading 1 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"64\" Name=\"Medium Shading 2 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"65\" Name=\"Medium List 1 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"66\" Name=\"Medium List 2 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"67\" Name=\"Medium Grid 1 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"68\" Name=\"Medium Grid 2 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"69\" Name=\"Medium Grid 3 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"70\" Name=\"Dark List Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"71\" Name=\"Colorful Shading Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"72\" Name=\"Colorful List Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"73\" Name=\"Colorful Grid Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"60\" Name=\"Light Shading Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"61\" Name=\"Light List Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"62\" Name=\"Light Grid Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"63\" Name=\"Medium Shading 1 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"64\" Name=\"Medium Shading 2 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"65\" Name=\"Medium List 1 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"66\" Name=\"Medium List 2 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"67\" Name=\"Medium Grid 1 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"68\" Name=\"Medium Grid 2 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"69\" Name=\"Medium Grid 3 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"70\" Name=\"Dark List Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"71\" Name=\"Colorful Shading Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"72\" Name=\"Colorful List Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"73\" Name=\"Colorful Grid Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"60\" Name=\"Light Shading Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"61\" Name=\"Light List Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"62\" Name=\"Light Grid Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"63\" Name=\"Medium Shading 1 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"64\" Name=\"Medium Shading 2 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"65\" Name=\"Medium List 1 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"66\" Name=\"Medium List 2 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"67\" Name=\"Medium Grid 1 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"68\" Name=\"Medium Grid 2 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"69\" Name=\"Medium Grid 3 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"70\" Name=\"Dark List Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"71\" Name=\"Colorful Shading Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"72\" Name=\"Colorful List Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"73\" Name=\"Colorful Grid Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"60\" Name=\"Light Shading Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"61\" Name=\"Light List Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"62\" Name=\"Light Grid Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"63\" Name=\"Medium Shading 1 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"64\" Name=\"Medium Shading 2 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"65\" Name=\"Medium List 1 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"66\" Name=\"Medium List 2 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"67\" Name=\"Medium Grid 1 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"68\" Name=\"Medium Grid 2 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"69\" Name=\"Medium Grid 3 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"70\" Name=\"Dark List Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"71\" Name=\"Colorful Shading Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"72\" Name=\"Colorful List Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"73\" Name=\"Colorful Grid Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"60\" Name=\"Light Shading Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"61\" Name=\"Light List Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"62\" Name=\"Light Grid Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"63\" Name=\"Medium Shading 1 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"64\" Name=\"Medium Shading 2 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"65\" Name=\"Medium List 1 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"66\" Name=\"Medium List 2 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"67\" Name=\"Medium Grid 1 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"68\" Name=\"Medium Grid 2 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"69\" Name=\"Medium Grid 3 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"70\" Name=\"Dark List Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"71\" Name=\"Colorful Shading Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"72\" Name=\"Colorful List Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"73\" Name=\"Colorful Grid Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"19\" QFormat=\"true\"\n Name=\"Subtle Emphasis\"/>\n <w:LsdException Locked=\"false\" Priority=\"21\" QFormat=\"true\"\n Name=\"Intense Emphasis\"/>\n <w:LsdException Locked=\"false\" Priority=\"31\" QFormat=\"true\"\n Name=\"Subtle Reference\"/>\n <w:LsdException Locked=\"false\" Priority=\"32\" QFormat=\"true\"\n Name=\"Intense Reference\"/>\n <w:LsdException Locked=\"false\" Priority=\"33\" QFormat=\"true\" Name=\"Book Title\"/>\n <w:LsdException Locked=\"false\" Priority=\"37\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"Bibliography\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"TOC Heading\"/>\n <w:LsdException Locked=\"false\" Priority=\"41\" Name=\"Plain Table 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"42\" Name=\"Plain Table 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"43\" Name=\"Plain Table 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"44\" Name=\"Plain Table 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"45\" Name=\"Plain Table 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"40\" Name=\"Grid Table Light\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\" Name=\"Grid Table 1 Light\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"Grid Table 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"Grid Table 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"Grid Table 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"Grid Table 5 Dark\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\" Name=\"Grid Table 6 Colorful\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\" Name=\"Grid Table 7 Colorful\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"Grid Table 1 Light Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"Grid Table 2 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"Grid Table 3 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"Grid Table 4 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"Grid Table 5 Dark Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"Grid Table 6 Colorful Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"Grid Table 7 Colorful Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"Grid Table 1 Light Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"Grid Table 2 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"Grid Table 3 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"Grid Table 4 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"Grid Table 5 Dark Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"Grid Table 6 Colorful Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"Grid Table 7 Colorful Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"Grid Table 1 Light Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"Grid Table 2 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"Grid Table 3 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"Grid Table 4 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"Grid Table 5 Dark Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"Grid Table 6 Colorful Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"Grid Table 7 Colorful Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"Grid Table 1 Light Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"Grid Table 2 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"Grid Table 3 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"Grid Table 4 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"Grid Table 5 Dark Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"Grid Table 6 Colorful Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"Grid Table 7 Colorful Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"Grid Table 1 Light Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"Grid Table 2 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"Grid Table 3 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"Grid Table 4 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"Grid Table 5 Dark Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"Grid Table 6 Colorful Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"Grid Table 7 Colorful Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"Grid Table 1 Light Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"Grid Table 2 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"Grid Table 3 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"Grid Table 4 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"Grid Table 5 Dark Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"Grid Table 6 Colorful Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"Grid Table 7 Colorful Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\" Name=\"List Table 1 Light\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"List Table 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"List Table 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"List Table 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"List Table 5 Dark\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\" Name=\"List Table 6 Colorful\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\" Name=\"List Table 7 Colorful\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"List Table 1 Light Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"List Table 2 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"List Table 3 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"List Table 4 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"List Table 5 Dark Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"List Table 6 Colorful Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"List Table 7 Colorful Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"List Table 1 Light Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"List Table 2 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"List Table 3 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"List Table 4 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"List Table 5 Dark Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"List Table 6 Colorful Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"List Table 7 Colorful Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"List Table 1 Light Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"List Table 2 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"List Table 3 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"List Table 4 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"List Table 5 Dark Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"List Table 6 Colorful Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"List Table 7 Colorful Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"List Table 1 Light Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"List Table 2 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"List Table 3 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"List Table 4 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"List Table 5 Dark Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"List Table 6 Colorful Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"List Table 7 Colorful Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"List Table 1 Light Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"List Table 2 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"List Table 3 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"List Table 4 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"List Table 5 Dark Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"List Table 6 Colorful Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"List Table 7 Colorful Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"List Table 1 Light Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"List Table 2 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"List Table 3 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"List Table 4 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"List Table 5 Dark Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"List Table 6 Colorful Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"List Table 7 Colorful Accent 6\"/>\n </w:LatentStyles>\n</xml><![endif]-->\n<style>\n<!--\n /* Font Definitions */\n@font-face\n {font-family:\"Courier New\";\n panose-1:2 7 3 9 2 2 5 2 4 4;\n mso-font-charset:0;\n mso-generic-font-family:auto;\n mso-font-pitch:variable;\n mso-font-signature:-536859905 -1073711037 9 0 511 0;}\n@font-face\n {font-family:Wingdings;\n panose-1:5 0 0 0 0 0 0 0 0 0;\n mso-font-charset:2;\n mso-generic-font-family:auto;\n mso-font-pitch:variable;\n mso-font-signature:0 268435456 0 0 -2147483648 0;}\n@font-face\n {font-family:\"Cambria Math\";\n panose-1:2 4 5 3 5 4 6 3 2 4;\n mso-font-charset:0;\n mso-generic-font-family:auto;\n mso-font-pitch:variable;\n mso-font-signature:-536870145 1107305727 0 0 415 0;}\n@font-face\n {font-family:Calibri;\n panose-1:2 15 5 2 2 2 4 3 2 4;\n mso-font-charset:0;\n mso-generic-font-family:auto;\n mso-font-pitch:variable;\n mso-font-signature:-536870145 1073786111 1 0 415 0;}\n /* Style Definitions */\np.MsoNormal, li.MsoNormal, div.MsoNormal\n {mso-style-unhide:no;\n mso-style-qformat:yes;\n mso-style-parent:\"\";\n margin:0cm;\n margin-bottom:.0001pt;\n mso-pagination:widow-orphan;\n font-size:12.0pt;\n font-family:Calibri;\n mso-ascii-font-family:Calibri;\n mso-ascii-theme-font:minor-latin;\n mso-fareast-font-family:Calibri;\n mso-fareast-theme-font:minor-latin;\n mso-hansi-font-family:Calibri;\n mso-hansi-theme-font:minor-latin;\n mso-bidi-font-family:\"Times New Roman\";\n mso-bidi-theme-font:minor-bidi;\n mso-fareast-language:EN-US;}\np.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph\n {mso-style-priority:34;\n mso-style-unhide:no;\n mso-style-qformat:yes;\n margin-top:0cm;\n margin-right:0cm;\n margin-bottom:0cm;\n margin-left:36.0pt;\n margin-bottom:.0001pt;\n mso-add-space:auto;\n mso-pagination:widow-orphan;\n font-size:12.0pt;\n font-family:Calibri;\n mso-ascii-font-family:Calibri;\n mso-ascii-theme-font:minor-latin;\n mso-fareast-font-family:Calibri;\n mso-fareast-theme-font:minor-latin;\n mso-hansi-font-family:Calibri;\n mso-hansi-theme-font:minor-latin;\n mso-bidi-font-family:\"Times New Roman\";\n mso-bidi-theme-font:minor-bidi;\n mso-fareast-language:EN-US;}\np.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst\n {mso-style-priority:34;\n mso-style-unhide:no;\n mso-style-qformat:yes;\n mso-style-type:export-only;\n margin-top:0cm;\n margin-right:0cm;\n margin-bottom:0cm;\n margin-left:36.0pt;\n margin-bottom:.0001pt;\n mso-add-space:auto;\n mso-pagination:widow-orphan;\n font-size:12.0pt;\n font-family:Calibri;\n mso-ascii-font-family:Calibri;\n mso-ascii-theme-font:minor-latin;\n mso-fareast-font-family:Calibri;\n mso-fareast-theme-font:minor-latin;\n mso-hansi-font-family:Calibri;\n mso-hansi-theme-font:minor-latin;\n mso-bidi-font-family:\"Times New Roman\";\n mso-bidi-theme-font:minor-bidi;\n mso-fareast-language:EN-US;}\np.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle\n {mso-style-priority:34;\n mso-style-unhide:no;\n mso-style-qformat:yes;\n mso-style-type:export-only;\n margin-top:0cm;\n margin-right:0cm;\n margin-bottom:0cm;\n margin-left:36.0pt;\n margin-bottom:.0001pt;\n mso-add-space:auto;\n mso-pagination:widow-orphan;\n font-size:12.0pt;\n font-family:Calibri;\n mso-ascii-font-family:Calibri;\n mso-ascii-theme-font:minor-latin;\n mso-fareast-font-family:Calibri;\n mso-fareast-theme-font:minor-latin;\n mso-hansi-font-family:Calibri;\n mso-hansi-theme-font:minor-latin;\n mso-bidi-font-family:\"Times New Roman\";\n mso-bidi-theme-font:minor-bidi;\n mso-fareast-language:EN-US;}\np.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast\n {mso-style-priority:34;\n mso-style-unhide:no;\n mso-style-qformat:yes;\n mso-style-type:export-only;\n margin-top:0cm;\n margin-right:0cm;\n margin-bottom:0cm;\n margin-left:36.0pt;\n margin-bottom:.0001pt;\n mso-add-space:auto;\n mso-pagination:widow-orphan;\n font-size:12.0pt;\n font-family:Calibri;\n mso-ascii-font-family:Calibri;\n mso-ascii-theme-font:minor-latin;\n mso-fareast-font-family:Calibri;\n mso-fareast-theme-font:minor-latin;\n mso-hansi-font-family:Calibri;\n mso-hansi-theme-font:minor-latin;\n mso-bidi-font-family:\"Times New Roman\";\n mso-bidi-theme-font:minor-bidi;\n mso-fareast-language:EN-US;}\n.MsoChpDefault\n {mso-style-type:export-only;\n mso-default-props:yes;\n font-family:Calibri;\n mso-ascii-font-family:Calibri;\n mso-ascii-theme-font:minor-latin;\n mso-fareast-font-family:Calibri;\n mso-fareast-theme-font:minor-latin;\n mso-hansi-font-family:Calibri;\n mso-hansi-theme-font:minor-latin;\n mso-bidi-font-family:\"Times New Roman\";\n mso-bidi-theme-font:minor-bidi;\n mso-fareast-language:EN-US;}\n@page WordSection1\n {size:595.0pt 842.0pt;\n margin:70.85pt 70.85pt 2.0cm 70.85pt;\n mso-header-margin:35.4pt;\n mso-footer-margin:35.4pt;\n mso-paper-source:0;}\ndiv.WordSection1\n {page:WordSection1;}\n /* List Definitions */\n@list l0\n {mso-list-id:240799396;\n mso-list-type:hybrid;\n mso-list-template-ids:1377200210 67567617 67567619 67567621 67567617 67567619 67567621 67567617 67567619 67567621;}\n@list l0:level1\n {mso-level-number-format:bullet;\n mso-level-text:;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:Symbol;}\n@list l0:level2\n {mso-level-number-format:bullet;\n mso-level-text:o;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:\"Courier New\";}\n@list l0:level3\n {mso-level-number-format:bullet;\n mso-level-text:;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:Wingdings;}\n@list l0:level4\n {mso-level-number-format:bullet;\n mso-level-text:;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:Symbol;}\n@list l0:level5\n {mso-level-number-format:bullet;\n mso-level-text:o;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:\"Courier New\";}\n@list l0:level6\n {mso-level-number-format:bullet;\n mso-level-text:;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:Wingdings;}\n@list l0:level7\n {mso-level-number-format:bullet;\n mso-level-text:;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:Symbol;}\n@list l0:level8\n {mso-level-number-format:bullet;\n mso-level-text:o;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:\"Courier New\";}\n@list l0:level9\n {mso-level-number-format:bullet;\n mso-level-text:;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:Wingdings;}\nol\n {margin-bottom:0cm;}\nul\n {margin-bottom:0cm;}\n-->\n</style>\n<!--[if gte mso 10]>\n<style>\n /* Style Definitions */\ntable.MsoNormalTable\n {mso-style-name:\"Normale Tabelle\";\n mso-tstyle-rowband-size:0;\n mso-tstyle-colband-size:0;\n mso-style-noshow:yes;\n mso-style-priority:99;\n mso-style-parent:\"\";\n mso-padding-alt:0cm 5.4pt 0cm 5.4pt;\n mso-para-margin:0cm;\n mso-para-margin-bottom:.0001pt;\n mso-pagination:widow-orphan;\n font-size:12.0pt;\n font-family:Calibri;\n mso-ascii-font-family:Calibri;\n mso-ascii-theme-font:minor-latin;\n mso-hansi-font-family:Calibri;\n mso-hansi-theme-font:minor-latin;\n mso-fareast-language:EN-US;}\n</style>\n<![endif]-->\n</head>\n\n<body bgcolor=white lang=DE style='tab-interval:35.4pt'>\n<!--StartFragment-->\n\n<p class=MsoListParagraphCxSpFirst style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span\nstyle='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:\nSymbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n</span></span></span><![endif]>Test 1<o:p></o:p></p>\n\n<p class=MsoListParagraphCxSpMiddle style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span\nstyle='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:\nSymbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n</span></span></span><![endif]>Test 2<o:p></o:p></p>\n\n<p class=MsoListParagraphCxSpMiddle style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span\nstyle='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:\nSymbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n</span></span></span><![endif]><i style='mso-bidi-font-style:normal'>Test 3<o:p></o:p></i></p>\n\n<p class=MsoListParagraphCxSpMiddle style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span\nstyle='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:\nSymbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n</span></span></span><![endif]>Test 4<o:p></o:p></p>\n\n<p class=MsoListParagraphCxSpLast style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span\nstyle='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:\nSymbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n</span></span></span><![endif]><b style='mso-bidi-font-weight:normal'>Test5<o:p></o:p></b></p>\n\n<!--EndFragment-->\n</body>\n\n</html>"
  533. should = "<ul><li>Test 1</li><li>Test 2</li><li><i>Test 3</i></li><li>Test 4</li><li><b>Test5</b></li></ul>"
  534. result = App.Utils.htmlCleanup(source)
  535. equal(result.html().trim(), should, source)
  536. source = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n<html>\n<head>\n <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/>\n <title></title>\n <meta name=\"generator\" content=\"LibreOffice 4.4.7.2 (MacOSX)\"/>\n <style type=\"text/css\">\n @page { margin: 0.79in }\n p { margin-bottom: 0.1in; line-height: 120% }\n a:link { so-language: zxx }\n </style>\n</head>\n<body lang=\"en-US\" dir=\"ltr\">\n<p align=\"center\" style=\"margin-bottom: 0in; line-height: 100%\">1.\nGehe a<b>uf </b><b>https://www.pfe</b>rdiathek.ge</p>\n<p align=\"center\" style=\"margin-bottom: 0in; line-height: 100%\"><br/>\n\n</p>\n<p align=\"center\" style=\"margin-bottom: 0in; line-height: 100%\">2.\nMel<font color=\"#800000\">de Dich mit folgende</font> Zugangsdaten an:</p>\n<p align=\"center\" style=\"margin-bottom: 0in; line-height: 100%\">Benutzer:\nme@xxx.net</p>\n<p align=\"center\" style=\"margin-bottom: 0in; line-height: 100%\">Passwort:\nxxx.</p>\n</body>\n</html>"
  537. should = "\n\n\n \n \n \n \n\n\n<p>1.\nGehe a<b>uf </b><b>https://www.pfe</b>rdiathek.ge</p>\n<p><br>\n\n</p>\n<p>2.\nMelde Dich mit folgende Zugangsdaten an:</p>\n<p>Benutzer:\nme@xxx.net</p>\n<p>Passwort:\nxxx.</p>\n\n"
  538. result = App.Utils.htmlCleanup(source)
  539. equal(result.html(), should, source)
  540. source = "<table bgcolor=\"green\" aaa=\"1\"><thead><tr><th colspan=\"2\" abc=\"a\">aaa</th></tr></thead><tbody><tr><td>value</td></tr></tbody></table>"
  541. should = "<table bgcolor=\"green\"><thead><tr><th colspan=\"2\">aaa</th></tr></thead><tbody><tr><td>value</td></tr></tbody></table>"
  542. result = App.Utils.htmlCleanup(source)
  543. equal(result.get(0).outerHTML, should, source)
  544. // strip out browser-inserted (broken) link (see https://github.com/zammad/zammad/issues/2019)
  545. source = "<div><a href=\"https://example.com/#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}\">test</a></div>"
  546. should = "<a href=\"#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}\">test</a>"
  547. result = App.Utils.htmlCleanup(source)
  548. equal(result.html(), should, source)
  549. source = "<table bgcolor=\"green\" aaa=\"1\" style=\"color: red\"><thead><tr style=\"margin-top: 10px\"><th colspan=\"2\" abc=\"a\" style=\"margin-top: 12px\">aaa</th></tr></thead><tbody><tr><td>value</td></tr></tbody></table>"
  550. should = "<table bgcolor=\"green\" style=\"color:red;\"><thead><tr style=\"margin-top:10px;\"><th colspan=\"2\" style=\"margin-top:12px;\">aaa</th></tr></thead><tbody><tr><td>value</td></tr></tbody></table>"
  551. result = App.Utils.htmlCleanup(source)
  552. result.get(0).outerHTML
  553. //equal(result.get(0).outerHTML, should, source) / string order is different on browsers
  554. equal(result.first().attr('bgcolor'), 'green')
  555. equal(result.first().attr('style'), 'color:red;')
  556. equal(result.first().attr('aaa'), undefined)
  557. equal(result.find('tr').first().attr('style'), 'margin-top:10px;')
  558. equal(result.find('th').first().attr('colspan'), '2')
  559. equal(result.find('th').first().attr('abc'), undefined)
  560. equal(result.find('th').first().attr('style'), 'margin-top:12px;')
  561. source = "<table bgcolor=\"green\" aaa=\"1\" style=\"color:red; display: none;\"><thead><tr><th colspan=\"2\" abc=\"a\">aaa</th></tr></thead><tbody><tr><td>value</td></tr></tbody></table>"
  562. should = "<table bgcolor=\"green\" style=\"color:red;\"><thead><tr><th colspan=\"2\">aaa</th></tr></thead><tbody><tr><td>value</td></tr></tbody></table>"
  563. result = App.Utils.htmlCleanup(source)
  564. //equal(result.get(0).outerHTML, should, source) / string order is different on browsers
  565. equal(result.first().attr('bgcolor'), 'green')
  566. equal(result.first().attr('style'), 'color:red;')
  567. equal(result.first().attr('aaa'), undefined)
  568. equal(result.find('tr').first().attr('style'), undefined)
  569. equal(result.find('th').first().attr('colspan'), '2')
  570. equal(result.find('th').first().attr('abc'), undefined)
  571. equal(result.find('th').first().attr('style'), undefined)
  572. });
  573. // wrap
  574. test("wrap", function() {
  575. var source = "some text"
  576. var should = 'some text'
  577. var result = App.Utils.wrap(source)
  578. equal(result, should, source)
  579. source = "some text\nsome other text\n"
  580. should = "some text\nsome other text\n"
  581. result = App.Utils.wrap(source)
  582. equal(result, should, source)
  583. source = "some text with some line to wrap"
  584. should = "some text with\nsome line to\nwrap"
  585. result = App.Utils.wrap(source, 14)
  586. equal(result, should, source)
  587. source = "some text\nsome other text\n"
  588. should = "some text\nsome other text\n"
  589. result = App.Utils.wrap(source)
  590. equal(result, should, source)
  591. source = "1234567890 1234567890 1234567890 1234567890"
  592. should = "1234567890 1234567890 1234567890 1234567890"
  593. result = App.Utils.wrap(source)
  594. equal(result, should, source)
  595. source = "123456789012 123456789012 123456789012"
  596. should = "123456789012\n123456789012\n123456789012"
  597. result = App.Utils.wrap(source, 14)
  598. equal(result, should, source)
  599. });
  600. // remove empty lines
  601. test("remove empty lines", function() {
  602. var source = "\ntest 123\n"
  603. var should = "test 123\n"
  604. var result = App.Utils.removeEmptyLines(source)
  605. equal(result, should, source)
  606. source = "\ntest\n\n123\n"
  607. should = "test\n123\n"
  608. result = App.Utils.removeEmptyLines(source)
  609. equal(result, should, source)
  610. });
  611. // quote
  612. test("quote", function() {
  613. var source = "some text"
  614. var should = '> some text'
  615. var result = App.Utils.quote(source)
  616. equal(result, should, source)
  617. source = "some text\nsome other text\n"
  618. should = "> some text\n> some other text"
  619. result = App.Utils.quote(source)
  620. equal(result, should, source)
  621. source = "\n\nsome text\nsome other text\n \n"
  622. should = "> some text\n> some other text"
  623. result = App.Utils.quote(source)
  624. equal(result, should, source)
  625. source = "Welcome!\n\nThank you for installing Zammad.\n\nYou will find ..."
  626. should = "> Welcome!\n>\n> Thank you for installing Zammad.\n>\n> You will find ..."
  627. result = App.Utils.quote(source)
  628. equal(result, should, source)
  629. source = "Welcome! Thank you for installing Zammad. You will find ..."
  630. should = "> Welcome! Thank you\n> for installing\n> Zammad. You will\n> find ..."
  631. result = App.Utils.quote(source, 20)
  632. equal(result, should, source)
  633. });
  634. // check signature
  635. test("check signature", function() {
  636. var message = "<div>test 123 </div>"
  637. var signature = '<div>--<br>Some Signature<br>some department</div>'
  638. var result = App.Utils.signatureCheck(message, signature)
  639. equal(result, true)
  640. message = "<div>test 123 <div>--<br>Some Signature<br>some department\n</div></div>"
  641. signature = '<div>--<br>Some Signature<br>some department</div>'
  642. result = App.Utils.signatureCheck(message, signature)
  643. equal(result, false)
  644. message = "<div>test 123 <div>--<br>Some Signature\n<br>some department\n</div></div>"
  645. signature = '<div>--<br>Some Signature<br>some department</div>'
  646. result = App.Utils.signatureCheck(message, signature)
  647. equal(result, false)
  648. message = "<div>test 123 <div>--<p>Some Signature</p>\n<p><div>some department</div>\n</p>\n</div></div>"
  649. signature = '<div>--<br>Some Signature<br>some department</div>'
  650. result = App.Utils.signatureCheck(message, signature)
  651. equal(result, false)
  652. message = ""
  653. signature = '<div>--<br>Some Signature<br>some department</div>'
  654. result = App.Utils.signatureCheck(message, signature)
  655. equal(result, true)
  656. message = ""
  657. signature = "--\nSome Signature\nsome department"
  658. result = App.Utils.signatureCheck(message, signature)
  659. equal(result, true)
  660. });
  661. // identify signature
  662. test("identify signature by plaintext", function() {
  663. var message = "<div>test 123 </div>"
  664. var should = '<div>test 123 </div>'
  665. var result = App.Utils.signatureIdentifyByPlaintext(message)
  666. equal(result, should)
  667. message = "<div>test 123 <br/>--<br/>Bob Smith</div>"
  668. should = '<div>test 123 <br/>--<br/>Bob Smith</div>'
  669. result = App.Utils.signatureIdentifyByPlaintext(message)
  670. equal(result, should)
  671. message = "<div>test 123 <br/>1<br/>2<br/>3<br/>4<br/>5<br/>6<br/>7<br/>8<br/>9<br/><br/>--<br/>Bob Smith</div>"
  672. should = '<div>test 123 <br/>1<br/>2<br/>3<br/>4<br/>5<br/>6<br/>7<br/>8<br/>9<br/><br/><span class="js-signatureMarker"></span>--<br/>Bob Smith</div>'
  673. result = App.Utils.signatureIdentifyByPlaintext(message)
  674. equal(result, should)
  675. message = "<div>test 123 <br/><br/>--no not match--<br/>--<br/>Bob Smith</div>"
  676. should = '<div>test 123 <br/><br/>--no not match--<br/><span class="js-signatureMarker"></span>--<br/>Bob Smith</div>'
  677. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  678. equal(result, should)
  679. message = "<div>test 123 <br/><br/>--no not match--<br/> -- <br/>Bob Smith</div>"
  680. should = '<div>test 123 <br/><br/>--no not match--<br/><span class="js-signatureMarker"></span> -- <br/>Bob Smith</div>'
  681. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  682. equal(result, should)
  683. message = "<div>test 123 <br/><br/>--<br/>Bob Smith<br/><br/><br/><br/><br/>--<br/>Bob Smith</div>"
  684. should = '<div>test 123 <br/><br/><span class="js-signatureMarker"></span>--<br/>Bob Smith<br/><br/><br/><br/><br/>--<br/>Bob Smith</div>'
  685. //should = '<div>test 123 <br><br><br><br><br><br><br><br><br><br><br><span class="js-signatureMarker"></span>--<br>Bob Smith<br/><br/><br/><br/><br/>--<br/>Bob Smith</div>'
  686. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  687. equal(result, should)
  688. message = "<div>test 123</div><div>test 123</div><div>--</div><div>Bob Smith</div>"
  689. should = "<div>test 123</div><div>test 123</div><div><span class=\"js-signatureMarker\"></span>--</div><div>Bob Smith</div>"
  690. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  691. equal(result, should)
  692. message = "<p><span>test 123</span></p><p><span>test 123</span></p><p><span>--</span></p><p><span>Bob Smith</span></p><div></div>"
  693. should = "<p><span>test 123</span></p><p><span>test 123</span></p><p><span><span class=\"js-signatureMarker\"></span>--</span></p><p><span>Bob Smith</span></p><div></div>"
  694. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  695. equal(result, should)
  696. message = "Test reply to zammad<br><br>Am 24.10.2016 18:55 schrieb &quot;Android Support&quot; &lt;android-support@example.com&gt;:<br><br>&gt; <u></u><br>&gt; Sehr geehrte Damen"
  697. should = "Test reply to zammad<br><br><span class=\"js-signatureMarker\"></span>Am 24.10.2016 18:55 schrieb &quot;Android Support&quot; &lt;android-support@example.com&gt;:<br><br>&gt; <u></u><br>&gt; Sehr geehrte Damen"
  698. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  699. equal(result, should)
  700. message = "<br>&lt; On 20 Oct 2016, at 12:23, Martin Edenhofer via Zammad Helpdesk wrote:<br>"
  701. should = "<br><span class=\"js-signatureMarker\"></span>&lt; On 20 Oct 2016, at 12:23, Martin Edenhofer via Zammad Helpdesk wrote:<br>"
  702. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  703. equal(result, should)
  704. // apple
  705. // en
  706. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>On 01/04/15 10:55, Bob Smith wrote:<br/>lalala<p>--</p>some test</div>"
  707. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>On 01/04/15 10:55, Bob Smith wrote:<br/>lalala<p>--</p>some test</div>'
  708. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  709. equal(result, should)
  710. // de
  711. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Am 03.04.2015 um 20:58 schrieb Bob Smith &lt;bob@example.com&gt;:<br/>lalala</div>"
  712. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>Am 03.04.2015 um 20:58 schrieb Bob Smith &lt;bob@example.com&gt;:<br/>lalala</div>'
  713. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  714. equal(result, should)
  715. // ms
  716. // en
  717. 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>"
  718. 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>'
  719. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  720. equal(result, should)
  721. 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>"
  722. 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>'
  723. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  724. equal(result, should)
  725. 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>"
  726. 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>'
  727. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  728. equal(result, should)
  729. // de
  730. 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>"
  731. 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>'
  732. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  733. equal(result, should)
  734. 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>"
  735. 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>"
  736. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  737. equal(result, should)
  738. 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>"
  739. 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>"
  740. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  741. equal(result, should)
  742. 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>"
  743. 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>"
  744. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  745. equal(result, should)
  746. message = "<div>Von: &quot;Johannes Nickel via Znuny Projects&quot; &lt;<a href=\"mailto:projects@znuny.inc\" title=\"mailto:projects@znuny.inc\">projects@znuny.inc</a>&gt;</div><div>An: \"Lisa Smith\" &lt;<a href=\"mailto:lisa.smith@example.com\" title=\"mailto:lisa.smith@example.com\">lisa.smith@example.com</a>&gt;</div><div>Gesendet: Donnerstag, 2. April 2015 10:11:12</div><div>Betreff: Angebot Redundanz / Paket mit Silver Subscription [Ticket#424242]</div><div><br></div><div>Hallo Frau Smith,</div>"
  747. should = "<div><span class=\"js-signatureMarker\"></span>Von: &quot;Johannes Nickel via Znuny Projects&quot; &lt;<a href=\"mailto:projects@znuny.inc\" title=\"mailto:projects@znuny.inc\">projects@znuny.inc</a>&gt;</div><div>An: \"Lisa Smith\" &lt;<a href=\"mailto:lisa.smith@example.com\" title=\"mailto:lisa.smith@example.com\">lisa.smith@example.com</a>&gt;</div><div>Gesendet: Donnerstag, 2. April 2015 10:11:12</div><div>Betreff: Angebot Redundanz / Paket mit Silver Subscription [Ticket#424242]</div><div><br></div><div>Hallo Frau Smith,</div>"
  748. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  749. equal(result, should)
  750. message = "<div>Hi Johannes,</div><div><br></div><div>das Angebot für den halben Tag bitte an uns.</div><div>Der Termin hat sich jetzt auf 10-12 Uhr verschoben, hab ich dir weitergeleitet.</div><div><br></div><div>Viele Grüße</div><div>Max</div><div><br></div><div>&gt; On 07 Oct 2015, at 11:55, Johannes Smith &lt;<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>smith@example.com</a> &lt;<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>mailto:smith@example.com</a>&gt;&gt; wrote:</div><div>&gt;</div><div>&gt; Hi,</div><div>&gt;</div><div>&gt; OK. Wer kriegt das Angebot? Ist das wirklich nur ein halber Tag?</div></div>"
  751. should = "<div>Hi Johannes,</div><div><br></div><div>das Angebot für den halben Tag bitte an uns.</div><div>Der Termin hat sich jetzt auf 10-12 Uhr verschoben, hab ich dir weitergeleitet.</div><div><br></div><div>Viele Grüße</div><div>Max</div><div><br></div><div><span class=\"js-signatureMarker\"></span>&gt; On 07 Oct 2015, at 11:55, Johannes Smith &lt;<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>smith@example.com</a> &lt;<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>mailto:smith@example.com</a>&gt;&gt; wrote:</div><div>&gt;</div><div>&gt; Hi,</div><div>&gt;</div><div>&gt; OK. Wer kriegt das Angebot? Ist das wirklich nur ein halber Tag?</div></div>"
  752. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  753. equal(result, should)
  754. message = "Dear Mr. Smith,<div><br></div><div>it seems to be, dass Sie den AutoIncrement Nummerngenerator für Ihre ITSMChangeManagement Installation verwenden. Seit ABC 3.2 wird führend vor der sich in der Datei&nbsp;<span style=\"line-height: 1.45; background-color: initial;\">&lt;ABC_CONFIG_Home&gt;/war/log/ITSMChangeCounter.log &nbsp;befindenden Zahl die SystemID (SysConfig) geschrieben. Dies ist ein Standardverhalten, dass auch bei der Ticketnummer verwendet wird.<br><br>Please ask me if you have questions.</span></div><div><span style=\"line-height: 1.45; background-color: initial;\"><br></span></div><div><span style=\"line-height: 1.45; background-color: initial;\">Viele Grüße,</span></div><div><div data-signature=\"true\" data-signature-id=\"1\">&nbsp; Thorsten Smith\n<br>\n<br>--\n<br>Enterprise Services for ABC\n<br>\n<br>Znuny GmbH // Marienstraße 11 // 10117 Berlin // Germany\n<br>\n<br>P: +49 (0) 30 111 111 111-0\n<br>F: +49 (0) 30 111 111 111-8\n<br>W: http://znuny.com \n<br>\n<br>Location: Berlin - HRB 12345678 B Amtsgericht Berlin-Charlottenburg\n<br>Managing Director: Martin Edenhofer\n<br></div></div>"
  755. should = "Dear Mr. Smith,<div><br></div><div>it seems to be, dass Sie den AutoIncrement Nummerngenerator für Ihre ITSMChangeManagement Installation verwenden. Seit ABC 3.2 wird führend vor der sich in der Datei&nbsp;<span style=\"line-height: 1.45; background-color: initial;\">&lt;ABC_CONFIG_Home&gt;/war/log/ITSMChangeCounter.log &nbsp;befindenden Zahl die SystemID (SysConfig) geschrieben. Dies ist ein Standardverhalten, dass auch bei der Ticketnummer verwendet wird.<br><br>Please ask me if you have questions.</span></div><div><span style=\"line-height: 1.45; background-color: initial;\"><br></span></div><div><span style=\"line-height: 1.45; background-color: initial;\">Viele Grüße,</span></div><div><span class=\"js-signatureMarker\"></span><div data-signature=\"true\" data-signature-id=\"1\">&nbsp; Thorsten Smith\n<br>\n<br>--\n<br>Enterprise Services for ABC\n<br>\n<br>Znuny GmbH // Marienstraße 11 // 10117 Berlin // Germany\n<br>\n<br>P: +49 (0) 30 111 111 111-0\n<br>F: +49 (0) 30 111 111 111-8\n<br>W: http://znuny.com \n<br>\n<br>Location: Berlin - HRB 12345678 B Amtsgericht Berlin-Charlottenburg\n<br>Managing Director: Martin Edenhofer\n<br></div></div>"
  756. result = App.Utils.signatureIdentifyByPlaintext(message, true, true)
  757. equal(result, should)
  758. message = "Dear Mr. Smith, nice to read you,<div><div data-signature=\"true\" data-signature-id=\"1\">&nbsp; Thorsten Smith\n<br>\n<br>--\n</div></div>"
  759. should = "Dear Mr. Smith, nice to read you,<div><span class=\"js-signatureMarker\"></span><div data-signature=\"true\" data-signature-id=\"1\">&nbsp; Thorsten Smith\n<br>\n<br>--\n</div></div>"
  760. result = App.Utils.signatureIdentifyByPlaintext(message, true, true)
  761. equal(result, should)
  762. message = "Dear Mr. Smith, nice to read you,<div><div data-signature=\"true\" data-signature-id=\"9999\">&nbsp; Thorsten Smith\n<br>\n<br>--\n</div></div>"
  763. should = "Dear Mr. Smith, nice to read you,<div><div data-signature=\"true\" data-signature-id=\"9999\">&nbsp; Thorsten Smith\n<br>\n<br>--\n</div></div>"
  764. result = App.Utils.signatureIdentifyByPlaintext(message, false, true)
  765. equal(result, should)
  766. // fr
  767. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>De : Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Envoyé : mercredi 29 avril 2015 17:31<br/>Objet : lalala</div>"
  768. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>De : Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Envoyé : mercredi 29 avril 2015 17:31<br/>Objet : lalala</div>'
  769. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  770. equal(result, should)
  771. // thunderbird
  772. // de
  773. message = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div>Am 04.03.2015 um 12:47 schrieb Martin Edenhofer via Znuny Sales:</div><div>&gt; Hallo Christian,</div>"
  774. should = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div><span class=\"js-signatureMarker\"></span>Am 04.03.2015 um 12:47 schrieb Martin Edenhofer via Znuny Sales:</div><div>&gt; Hallo Christian,</div>"
  775. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  776. equal(result, should)
  777. // en - Thunderbird default - http://kb.mozillazine.org/Reply_header_settings
  778. message = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div>On 01-01-2007 11:00 AM, Alf Aardvark wrote:</div><div>&gt; Hallo Christian,</div>"
  779. should = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div><span class=\"js-signatureMarker\"></span>On 01-01-2007 11:00 AM, Alf Aardvark wrote:</div><div>&gt; Hallo Christian,</div>"
  780. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  781. equal(result, should)
  782. // en - http://kb.mozillazine.org/Reply_header_settings
  783. message = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div>Alf Aardvark wrote, on 01-01-2007 11:00 AM:</div><div>&gt; Hallo Christian,</div>"
  784. should = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div><span class=\"js-signatureMarker\"></span>Alf Aardvark wrote, on 01-01-2007 11:00 AM:</div><div>&gt; Hallo Christian,</div>"
  785. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  786. equal(result, should)
  787. // otrs
  788. // en
  789. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>01/04/15 10:55 - Bob Smith wrote:<br/>lalala</div>"
  790. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>01/04/15 10:55 - Bob Smith wrote:<br/>lalala</div>'
  791. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  792. equal(result, should)
  793. // de
  794. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>01/04/15 10:55 - Bob Smith schrieb:<br/>lalala</div>"
  795. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>01/04/15 10:55 - Bob Smith schrieb:<br/>lalala</div>'
  796. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  797. equal(result, should)
  798. message = "<div>test 123 <br/><br/></div><div>24.02.2015 14:20 - Roy Kaldung via Znuny Sales schrieb: &nbsp;</div>"
  799. should = "<div>test 123 <br/><br/></div><div><span class=\"js-signatureMarker\"></span>24.02.2015 14:20 - Roy Kaldung via Znuny Sales schrieb: &nbsp;</div>"
  800. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  801. equal(result, should)
  802. // zammad
  803. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><div data-signature=\"true\" data-signature-id=\"5\">lalala</div></div>"
  804. should = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class=\"js-signatureMarker\"></span><div data-signature=\"true\" data-signature-id=\"5\">lalala</div></div>"
  805. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  806. equal(result, should)
  807. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><blockquote type=\"cite\">lalala</blockquote></div>"
  808. should = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class=\"js-signatureMarker\"></span><blockquote type=\"cite\">lalala</blockquote></div>"
  809. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  810. equal(result, should)
  811. // gmail
  812. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><blockquote class=\"ecxgmail_quote\">lalala</blockquote></div>"
  813. should = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class=\"js-signatureMarker\"></span><blockquote class=\"ecxgmail_quote\">lalala</blockquote></div>"
  814. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  815. equal(result, should)
  816. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><blockquote class=\"gmail_quote\">lalala</blockquote></div>"
  817. should = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class=\"js-signatureMarker\"></span><blockquote class=\"gmail_quote\">lalala</blockquote></div>"
  818. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  819. equal(result, should)
  820. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Am 24. Dezember 2015 um 07:45 schrieb kathrine &lt;kathrine@example.com&gt;:<br/>lalala</div>"
  821. should = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class=\"js-signatureMarker\"></span>Am 24. Dezember 2015 um 07:45 schrieb kathrine &lt;kathrine@example.com&gt;:<br/>lalala</div>"
  822. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  823. equal(result, should)
  824. // word 14
  825. // en
  826. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Bob Smith wrote:<br/>lalala</div>"
  827. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>Bob Smith wrote:<br/>lalala</div>'
  828. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  829. equal(result, should)
  830. // de
  831. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Bob Smith schrieb:<br/>lalala</div>"
  832. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>Bob Smith schrieb:<br/>lalala</div>'
  833. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  834. equal(result, should)
  835. });
  836. test("identify signature by HTML", function() {
  837. var message = "<div>test 123 </div>"
  838. var should = message
  839. var result = App.Utils.signatureIdentifyByHtml(message)
  840. equal(result, should)
  841. // simple case 1
  842. message = '<div>actual content</div><blockquote>quoted content</blockquote>'
  843. should = '<div>actual content</div><span class="js-signatureMarker"></span><blockquote>quoted content</blockquote>'
  844. result = App.Utils.signatureIdentifyByHtml(message)
  845. equal(result, should)
  846. // simple case 2
  847. message = '<div>actual content</div><blockquote>quoted content</blockquote><br><div><br></div><div><br> </div>'
  848. should = '<div>actual content</div><span class="js-signatureMarker"></span><blockquote>quoted content</blockquote><br><div><br></div><div><br> </div>'
  849. result = App.Utils.signatureIdentifyByHtml(message)
  850. equal(result, should)
  851. // simple case 3
  852. message = '<div>actual content</div><blockquote>quoted content</blockquote><br><div>actual content 2</div>'
  853. should = message
  854. result = App.Utils.signatureIdentifyByHtml(message)
  855. equal(result, should)
  856. // simple case 4
  857. message = ' content 0 <div>content 1</div> content 2 <blockquote>quoted content</blockquote><br><div><br></div><div><br> </div>'
  858. should = ' content 0 <div>content 1</div> content 2 <span class="js-signatureMarker"></span><blockquote>quoted content</blockquote><br><div><br></div><div><br> </div>'
  859. result = App.Utils.signatureIdentifyByHtml(message)
  860. equal(result, should)
  861. // Gmail via Safari on MacOS 10.12
  862. message = '<div dir="ltr">Reply with <b>gmail</b> via Safari on MacOS 10.12</div><br>\
  863. <div>\
  864. <div dir="ltr">Am Mi., 5. Sep. 2018 um 09:22 Uhr schrieb Billy Zhou &lt;bz@zammad.com&gt;:<br>\
  865. </div>\
  866. <blockquote>test email content<br>\
  867. <br>\
  868. </blockquote>\
  869. </div>'
  870. should = '<div dir="ltr">Reply with <b>gmail</b> via Safari on MacOS 10.12</div><br>\
  871. <span class=\"js-signatureMarker\"></span><div>\
  872. <div dir="ltr">Am Mi., 5. Sep. 2018 um 09:22 Uhr schrieb Billy Zhou &lt;bz@zammad.com&gt;:<br>\
  873. </div>\
  874. <blockquote>test email content<br>\
  875. <br>\
  876. </blockquote>\
  877. </div>'
  878. result = App.Utils.signatureIdentifyByHtml(message)
  879. equal(result, should)
  880. // Yahoo Mail via Safari on MacOS 10.12
  881. message = '<div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1536132243868_2594"><span id="yui_3_16_0_ym19_1_1536132243868_2593">Reply with <b id="yui_3_16_0_ym19_1_1536132243868_2597">Yahoo Mail</b> via Safari on MacOS 10.12</span></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"><font size="2" face="Arial"> Billy Zhou &lt;bz@zammad.com&gt; schrieb am 9:08 Mittwoch, 5.September 2018:<br></font></div> <br><br> <div class="y_msg_container"><div dir="ltr">test email content<br></div><div dir="ltr"><br></div><br><br></div> </div> </div> </div></div>'
  882. should = '<div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1536132243868_2594"><span id="yui_3_16_0_ym19_1_1536132243868_2593">Reply with <b id="yui_3_16_0_ym19_1_1536132243868_2597">Yahoo Mail</b> via Safari on MacOS 10.12</span></div> <div class="qtdSeparateBR"><br><br></div><span class="js-signatureMarker"></span><div class="yahoo_quoted" style="display: block;"> <div style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"><font size="2" face="Arial"> Billy Zhou &lt;bz@zammad.com&gt; schrieb am 9:08 Mittwoch, 5.September 2018:<br></font></div> <br><br> <div class="y_msg_container"><div dir="ltr">test email content<br></div><div dir="ltr"><br></div><br><br></div> </div> </div> </div></div>'
  883. result = App.Utils.signatureIdentifyByHtml(message)
  884. equal(result, should)
  885. // Thunderbird 52 on MacOS 10.12
  886. message = 'Reply with <b>Thunderbird 52</b> on MacOS 10.12<br>\
  887. <br>\
  888. <div class="moz-cite-prefix">Am 04.09.18 um 15:32 schrieb Billy\
  889. Zhou:<br>\
  890. </div>\
  891. <blockquote type="cite"\
  892. cite="mid:da18ed01-b187-a383-bfe7-72663cf82a83@zammad.com">test\
  893. email content\
  894. <br>\
  895. <br>\
  896. </blockquote>\
  897. <br>'
  898. should = 'Reply with <b>Thunderbird 52</b> on MacOS 10.12<br>\
  899. <br>\
  900. <div class="moz-cite-prefix">Am 04.09.18 um 15:32 schrieb Billy\
  901. Zhou:<br>\
  902. </div>\
  903. <span class=\"js-signatureMarker\"></span><blockquote type="cite" cite="mid:da18ed01-b187-a383-bfe7-72663cf82a83@zammad.com">test\
  904. email content\
  905. <br>\
  906. <br>\
  907. </blockquote>\
  908. <br>'
  909. result = App.Utils.signatureIdentifyByHtml(message)
  910. equal(result, should)
  911. // Apple Mail on MacOS 10
  912. message = '<div class="">Reply by <b class="">Apple Mail</b> on MacOS 10.</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 4. Sep 2018, at 15:32, Billy Zhou &lt;<a href="mailto:bz@zammad.com" class="">bz@zammad.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">test email content<br class=""><br class=""></div></div></blockquote></div><br class="">'
  913. should = '<div class="">Reply by <b class="">Apple Mail</b> on MacOS 10.</div><div class=""><br class=""></div><br class=""><span class=\"js-signatureMarker\"></span><div><blockquote type="cite" class=""><div class="">On 4. Sep 2018, at 15:32, Billy Zhou &lt;<a href="mailto:bz@zammad.com" class="">bz@zammad.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">test email content<br class=""><br class=""></div></div></blockquote></div><br class="">'
  914. result = App.Utils.signatureIdentifyByHtml(message)
  915. equal(result, should)
  916. // Office 365 (10325.20118) on Windows 10 Build 1803
  917. // With German marker: -----Ursprüngliche Nachricht-----
  918. // Using fallback to signatureIdentifyByPlaintext
  919. message = '<div>\
  920. <p>Reply with Office 365 (10325.20118) on Windows 10 Build 1803</p>\
  921. <p> </p>\
  922. <p><b>fett</b></p>\
  923. <p> </p>\
  924. <span class="js-signatureMarker"></span><p>--</p>\
  925. <p>Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany</p>\
  926. <p> </p>\
  927. <p>P: +49 (0) 30 55 57 160-0</p>\
  928. <p>F: +49 (0) 30 55 57 160-99</p>\
  929. <p>W: <a href="https://zammad.com" rel="nofollow noreferrer noopener" target="_blank">https://zammad.com</a></p>\
  930. <p> </p>\
  931. <p>Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg</p>\
  932. <p>Managing Director: Martin Edenhofer</p>\
  933. <p> </p>\
  934. <p>-----Ursprüngliche Nachricht-----<br>Von: Billy Zhou &lt;bz@zammad.com&gt; <br>Gesendet: Dienstag, 4. September 2018 15:33<br>An: me@zammad.com<br>Betreff: test email title</p>\
  935. <p> </p>\
  936. <p>test email content</p>\
  937. <p> </p>\
  938. </div>'
  939. should = '<div>\
  940. <p>Reply with Office 365 (10325.20118) on Windows 10 Build 1803</p>\
  941. <p> </p>\
  942. <p><b>fett</b></p>\
  943. <p> </p>\
  944. <span class="js-signatureMarker"></span><p><span class=\"js-signatureMarker\"></span>--</p>\
  945. <p>Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany</p>\
  946. <p> </p>\
  947. <p>P: +49 (0) 30 55 57 160-0</p>\
  948. <p>F: +49 (0) 30 55 57 160-99</p>\
  949. <p>W: <a href="https://zammad.com" rel="nofollow noreferrer noopener" target="_blank">https://zammad.com</a></p>\
  950. <p> </p>\
  951. <p>Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg</p>\
  952. <p>Managing Director: Martin Edenhofer</p>\
  953. <p> </p>\
  954. <p>-----Ursprüngliche Nachricht-----<br>Von: Billy Zhou &lt;bz@zammad.com&gt; <br>Gesendet: Dienstag, 4. September 2018 15:33<br>An: me@zammad.com<br>Betreff: test email title</p>\
  955. <p> </p>\
  956. <p>test email content</p>\
  957. <p> </p>\
  958. </div>'
  959. result = App.Utils.signatureIdentifyByHtml(message)
  960. equal(result, should)
  961. // Office 365 (10325.20118) on Windows 10 Build 1803
  962. // With English marker: -----Original Message-----
  963. // Using fallback to signatureIdentifyByPlaintext
  964. message = '<div>\
  965. <p>Reply with Office 365 (10325.20118) on Windows 10 Build 1803</p>\
  966. <p> </p>\
  967. <p><b>fett</b></p>\
  968. <p> </p>\
  969. <span class="js-signatureMarker"></span><p>--</p>\
  970. <p>Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany</p>\
  971. <p> </p>\
  972. <p>P: +49 (0) 30 55 57 160-0</p>\
  973. <p>F: +49 (0) 30 55 57 160-99</p>\
  974. <p>W: <a href="https://zammad.com" rel="nofollow noreferrer noopener" target="_blank">https://zammad.com</a></p>\
  975. <p> </p>\
  976. <p>Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg</p>\
  977. <p>Managing Director: Martin Edenhofer</p>\
  978. <p> </p>\
  979. <p>-----Original Message-----<br>Von: Billy Zhou &lt;bz@zammad.com&gt; <br>Gesendet: Dienstag, 4. September 2018 15:33<br>An: me@zammad.com<br>Betreff: test email title</p>\
  980. <p> </p>\
  981. <p>test email content</p>\
  982. <p> </p>\
  983. </div>'
  984. should = '<div>\
  985. <p>Reply with Office 365 (10325.20118) on Windows 10 Build 1803</p>\
  986. <p> </p>\
  987. <p><b>fett</b></p>\
  988. <p> </p>\
  989. <span class="js-signatureMarker"></span><p><span class=\"js-signatureMarker\"></span>--</p>\
  990. <p>Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany</p>\
  991. <p> </p>\
  992. <p>P: +49 (0) 30 55 57 160-0</p>\
  993. <p>F: +49 (0) 30 55 57 160-99</p>\
  994. <p>W: <a href="https://zammad.com" rel="nofollow noreferrer noopener" target="_blank">https://zammad.com</a></p>\
  995. <p> </p>\
  996. <p>Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg</p>\
  997. <p>Managing Director: Martin Edenhofer</p>\
  998. <p> </p>\
  999. <p>-----Original Message-----<br>Von: Billy Zhou &lt;bz@zammad.com&gt; <br>Gesendet: Dienstag, 4. September 2018 15:33<br>An: me@zammad.com<br>Betreff: test email title</p>\
  1000. <p> </p>\
  1001. <p>test email content</p>\
  1002. <p> </p>\
  1003. </div>'
  1004. result = App.Utils.signatureIdentifyByHtml(message)
  1005. equal(result, should)
  1006. // Office 365 (10325.20118) on Windows 10 Build 1803
  1007. // With German marker: -----Ursprüngliche Nachricht-----
  1008. // Without any existing <span class="js-signatureMarker"></span>
  1009. // Using fallback to signatureIdentifyByPlaintext
  1010. message = '<div>\
  1011. <p>Reply with Office 365 (10325.20118) on Windows 10 Build 1803</p>\
  1012. <p> </p>\
  1013. <p><b>fett</b></p>\
  1014. <p> </p>\
  1015. <p>--</p>\
  1016. <p>Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany</p>\
  1017. <p> </p>\
  1018. <p>P: +49 (0) 30 55 57 160-0</p>\
  1019. <p>F: +49 (0) 30 55 57 160-99</p>\
  1020. <p>W: <a href="https://zammad.com" rel="nofollow noreferrer noopener" target="_blank">https://zammad.com</a></p>\
  1021. <p> </p>\
  1022. <p>Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg</p>\
  1023. <p>Managing Director: Martin Edenhofer</p>\
  1024. <p> </p>\
  1025. <p>-----Ursprüngliche Nachricht-----<br>Von: Billy Zhou &lt;bz@zammad.com&gt; <br>Gesendet: Dienstag, 4. September 2018 15:33<br>An: me@zammad.com<br>Betreff: test email title</p>\
  1026. <p> </p>\
  1027. <p>test email content</p>\
  1028. <p> </p>\
  1029. </div>'
  1030. should = '<div>\
  1031. <p>Reply with Office 365 (10325.20118) on Windows 10 Build 1803</p>\
  1032. <p> </p>\
  1033. <p><b>fett</b></p>\
  1034. <p> </p>\
  1035. <p><span class=\"js-signatureMarker\"></span>--</p>\
  1036. <p>Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany</p>\
  1037. <p> </p>\
  1038. <p>P: +49 (0) 30 55 57 160-0</p>\
  1039. <p>F: +49 (0) 30 55 57 160-99</p>\
  1040. <p>W: <a href="https://zammad.com" rel="nofollow noreferrer noopener" target="_blank">https://zammad.com</a></p>\
  1041. <p> </p>\
  1042. <p>Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg</p>\
  1043. <p>Managing Director: Martin Edenhofer</p>\
  1044. <p> </p>\
  1045. <p>-----Ursprüngliche Nachricht-----<br>Von: Billy Zhou &lt;bz@zammad.com&gt; <br>Gesendet: Dienstag, 4. September 2018 15:33<br>An: me@zammad.com<br>Betreff: test email title</p>\
  1046. <p> </p>\
  1047. <p>test email content</p>\
  1048. <p> </p>\
  1049. </div>'
  1050. result = App.Utils.signatureIdentifyByHtml(message)
  1051. equal(result, should)
  1052. });
  1053. // check attachment references
  1054. test("check check attachment reference", function() {
  1055. var message = 'some not existing'
  1056. var result = false
  1057. var verify = App.Utils.checkAttachmentReference(message)
  1058. equal(verify, result)
  1059. message = 'some attachment for you'
  1060. result = 'Attachment'
  1061. verify = App.Utils.checkAttachmentReference(message)
  1062. equal(verify, result)
  1063. message = 'your attachment.'
  1064. result = 'Attachment'
  1065. verify = App.Utils.checkAttachmentReference(message)
  1066. equal(verify, result)
  1067. message = 'some otherattachment for you'
  1068. result = false
  1069. verify = App.Utils.checkAttachmentReference(message)
  1070. equal(verify, result)
  1071. message = 'some attachmentother for you'
  1072. result = false
  1073. verify = App.Utils.checkAttachmentReference(message)
  1074. equal(verify, result)
  1075. message = 'someattachment'
  1076. result = false
  1077. verify = App.Utils.checkAttachmentReference(message)
  1078. equal(verify, result)
  1079. message = 'As enclosed you will find.'
  1080. result = 'Enclosed'
  1081. verify = App.Utils.checkAttachmentReference(message)
  1082. equal(verify, result)
  1083. message = '<div>Hi Test,</div><div><blockquote>On Monday, 22 July 2019, 14:07:54, Test User wrote:<br><br>Test attachment <br></blockquote></div>'
  1084. result = false
  1085. verify = App.Utils.checkAttachmentReference(message)
  1086. equal(verify, result)
  1087. message = '<div>Hi Test,</div><div><blockquote type="cite">cite attachment </blockquote></div>'
  1088. result = false
  1089. verify = App.Utils.checkAttachmentReference(message)
  1090. equal(verify, result)
  1091. message = '<div>Hi Test,</div><div><blockquote class="ecxgmail_quote">ecxgmail_quote attachment </blockquote></div>'
  1092. result = false
  1093. verify = App.Utils.checkAttachmentReference(message)
  1094. equal(verify, result)
  1095. });
  1096. // replace tags
  1097. test("check replace tags", function() {
  1098. var formatNumber = function(num, digits) {
  1099. while (num.toString().length < digits) {
  1100. num = '0' + num
  1101. }
  1102. return num
  1103. }
  1104. var formatTimestamp = function(timestamp) {
  1105. localTime = new Date(Date.parse(timestamp))
  1106. d = formatNumber(localTime.getDate(), 2)
  1107. m = formatNumber(localTime.getMonth() + 1, 2)
  1108. yfull = localTime.getFullYear()
  1109. M = formatNumber(localTime.getMinutes(), 2)
  1110. H = formatNumber(localTime.getHours(), 2)
  1111. return m + '/' + d + '/' + yfull + ' ' + H + ':' + M
  1112. }
  1113. var message = "<div>#{user.firstname} #{user.lastname}</div>"
  1114. var result = '<div>Bob Smith</div>'
  1115. var data = {
  1116. user: {
  1117. firstname: 'Bob',
  1118. lastname: 'Smith',
  1119. },
  1120. }
  1121. var verify = App.Utils.replaceTags(message, data)
  1122. equal(verify, result)
  1123. message = "<div>#{user.firstname} #{user.lastname}</div>"
  1124. result = '<div>Bob Smith</div>'
  1125. data = {
  1126. user: {
  1127. firstname: function() { return 'Bob' },
  1128. lastname: function() { return 'Smith' },
  1129. },
  1130. }
  1131. verify = App.Utils.replaceTags(message, data)
  1132. equal(verify, result)
  1133. message = "<div>#{user.firstname} #{user.lastname}</div>"
  1134. result = '<div>Bob -</div>'
  1135. data = {
  1136. user: {
  1137. firstname: 'Bob',
  1138. },
  1139. }
  1140. verify = App.Utils.replaceTags(message, data)
  1141. equal(verify, result)
  1142. message = "<div>#{user.firstname} #{user.lastname}</div>"
  1143. result = '<div>Bob 0</div>'
  1144. data = {
  1145. user: {
  1146. firstname: 'Bob',
  1147. lastname: 0,
  1148. },
  1149. }
  1150. verify = App.Utils.replaceTags(message, data)
  1151. equal(verify, result)
  1152. message = "<div>#{user.firstname} #{user.lastname}</div>"
  1153. result = '<div>Bob -</div>'
  1154. data = {
  1155. user: {
  1156. firstname: 'Bob',
  1157. lastname: '',
  1158. },
  1159. }
  1160. verify = App.Utils.replaceTags(message, data)
  1161. equal(verify, result)
  1162. message = "<div>#{user.firstname} #{user.not.existing.test}</div>"
  1163. result = '<div>Bob -</div>'
  1164. data = {
  1165. user: {
  1166. firstname: 'Bob',
  1167. },
  1168. }
  1169. verify = App.Utils.replaceTags(message, data)
  1170. equal(verify, result)
  1171. message = "<div>#{user.firstname} #{not.existing.test}</div>"
  1172. result = '<div>Bob -</div>'
  1173. data = {
  1174. user: {
  1175. firstname: 'Bob',
  1176. },
  1177. }
  1178. verify = App.Utils.replaceTags(message, data)
  1179. equal(verify, result)
  1180. message = "<div>#{user.firstname} #{not.existing.test}</div>"
  1181. result = '<div>Bob -</div>'
  1182. data = {
  1183. user: {
  1184. firstname: 'Bob',
  1185. not: null,
  1186. },
  1187. }
  1188. verify = App.Utils.replaceTags(message, data)
  1189. equal(verify, result)
  1190. message = "<div>#{user.firstname} #{not.existing.test}</div>"
  1191. result = '<div>Bob -</div>'
  1192. data = {
  1193. user: {
  1194. firstname: 'Bob',
  1195. not: {},
  1196. },
  1197. }
  1198. verify = App.Utils.replaceTags(message, data)
  1199. equal(verify, result)
  1200. message = "<div>#{user.firstname} #{<a href=\"/test\">user.lastname</a>}</div>"
  1201. result = '<div>Bob Smith</div>'
  1202. data = {
  1203. user: {
  1204. firstname: 'Bob',
  1205. lastname: 'Smith',
  1206. },
  1207. }
  1208. verify = App.Utils.replaceTags(message, data)
  1209. equal(verify, result)
  1210. user = new App.User({
  1211. firstname: 'Bob',
  1212. lastname: 'Smith Good',
  1213. created_at: '2018-10-31T10:00:00Z',
  1214. })
  1215. message = "<div>#{user.firstname} #{user.created_at}</div>"
  1216. result = '<div>Bob ' + formatTimestamp('2018-10-31T10:00:00Z') + '</div>'
  1217. data = {
  1218. user: user
  1219. }
  1220. verify = App.Utils.replaceTags(message, data)
  1221. equal(verify, result)
  1222. message = "<div>#{user.firstname} #{user.created_at.date}</div>"
  1223. result = '<div>Bob -</div>'
  1224. data = {
  1225. user: user
  1226. }
  1227. verify = App.Utils.replaceTags(message, data)
  1228. equal(verify, result)
  1229. message = "<div>#{user.firstname} #{user.created.date}</div>"
  1230. result = '<div>Bob -</div>'
  1231. data = {
  1232. user: user
  1233. }
  1234. verify = App.Utils.replaceTags(message, data)
  1235. equal(verify, result)
  1236. message = "<a href=\"https://example.co/q=#{user.lastname}\">some text</a>"
  1237. result = '<a href=\"https://example.co/q=Smith%20Good\">some text</a>'
  1238. data = {
  1239. user: user
  1240. }
  1241. verify = App.Utils.replaceTags(message, data, true)
  1242. equal(verify, result)
  1243. });
  1244. // check attibute validation
  1245. test("check attibute validation", function() {
  1246. var string = '123'
  1247. var result = '123'
  1248. var verify = App.Utils.htmlAttributeCleanup(string)
  1249. equal(verify, result, string)
  1250. string = '123!'
  1251. result = '123'
  1252. verify = App.Utils.htmlAttributeCleanup(string)
  1253. equal(verify, result, string)
  1254. string = '12 3!'
  1255. result = '123'
  1256. verify = App.Utils.htmlAttributeCleanup(string)
  1257. equal(verify, result, string)
  1258. string = '12-3!'
  1259. result = '12-3'
  1260. verify = App.Utils.htmlAttributeCleanup(string)
  1261. equal(verify, result, string)
  1262. string = '12_3!'
  1263. result = '12_3'
  1264. verify = App.Utils.htmlAttributeCleanup(string)
  1265. equal(verify, result, string)
  1266. string = '^12_3!'
  1267. result = '12_3'
  1268. verify = App.Utils.htmlAttributeCleanup(string)
  1269. equal(verify, result, string)
  1270. string = '^1\n 2_3!'
  1271. result = '12_3'
  1272. verify = App.Utils.htmlAttributeCleanup(string)
  1273. equal(verify, result, string)
  1274. string = 'abc?'
  1275. result = 'abc'
  1276. verify = App.Utils.htmlAttributeCleanup(string)
  1277. equal(verify, result, string)
  1278. string = 'abc."'
  1279. result = 'abc'
  1280. verify = App.Utils.htmlAttributeCleanup(string)
  1281. equal(verify, result, string)
  1282. string = '#abc!^'
  1283. result = 'abc'
  1284. verify = App.Utils.htmlAttributeCleanup(string)
  1285. equal(verify, result, string)
  1286. string = 'abc()=$'
  1287. result = 'abc'
  1288. verify = App.Utils.htmlAttributeCleanup(string)
  1289. equal(verify, result, string)
  1290. string = "abc()=$\n123\rß"
  1291. result = 'abc123'
  1292. verify = App.Utils.htmlAttributeCleanup(string)
  1293. equal(verify, result, string)
  1294. });
  1295. // check form diff
  1296. test("check form diff", function() {
  1297. var dataNow = {
  1298. owner_id: 1,
  1299. pending_date: '2015-01-28T09:39:00Z',
  1300. }
  1301. var dataLast = {
  1302. owner_id: '',
  1303. pending_date: '2015-01-28T09:39:00Z',
  1304. }
  1305. var diff = {}
  1306. var result = App.Utils.formDiff(dataNow, dataLast)
  1307. deepEqual(result, diff, 'check form diff')
  1308. dataNow = {
  1309. owner_id: '1',
  1310. pending_date: '2015-01-28T09:39:00Z',
  1311. }
  1312. dataLast = {
  1313. owner_id: '',
  1314. pending_date: '2015-01-28T09:39:00Z',
  1315. }
  1316. diff = {}
  1317. result = App.Utils.formDiff(dataNow, dataLast)
  1318. deepEqual(result, diff, 'check form diff')
  1319. dataNow = {
  1320. pending_date: '2015-01-28T09:39:00Z',
  1321. }
  1322. dataLast = {
  1323. owner_id: 1,
  1324. pending_date: '2015-01-28T09:39:00Z',
  1325. }
  1326. diff = {}
  1327. result = App.Utils.formDiff(dataNow, dataLast)
  1328. deepEqual(result, diff, 'check form diff')
  1329. dataNow = {
  1330. owner_id: '',
  1331. pending_date: '2015-01-28T09:39:00Z',
  1332. }
  1333. dataLast = {
  1334. pending_date: '2015-01-28T09:39:00Z',
  1335. }
  1336. diff = {
  1337. }
  1338. result = App.Utils.formDiff(dataNow, dataLast)
  1339. deepEqual(result, diff, 'check form diff')
  1340. dataNow = {
  1341. owner_id: '',
  1342. state_ids: [1,5,6,7],
  1343. }
  1344. dataLast = {}
  1345. diff = {
  1346. state_ids: ['1','5','6','7'],
  1347. }
  1348. result = App.Utils.formDiff(dataNow, dataLast)
  1349. deepEqual(result, diff, 'check form diff')
  1350. dataNow = {
  1351. owner_id: 1,
  1352. state_ids: [1,5,7,6],
  1353. }
  1354. dataLast = {
  1355. owner_id: '',
  1356. state_ids: [1,5,6,7],
  1357. }
  1358. diff = {}
  1359. result = App.Utils.formDiff(dataNow, dataLast)
  1360. deepEqual(result, diff, 'check form diff')
  1361. dataNow = {
  1362. owner_id: 1,
  1363. state_ids: [1,5,6,7],
  1364. }
  1365. dataLast = {
  1366. state_ids: ['1','5','7'],
  1367. }
  1368. diff = {
  1369. state_ids: ['6'],
  1370. }
  1371. result = App.Utils.formDiff(dataNow, dataLast)
  1372. deepEqual(result, diff, 'check form diff')
  1373. dataNow = {
  1374. owner_id: '',
  1375. state_ids: [1,5,6,7],
  1376. }
  1377. dataLast = {
  1378. owner_id: 1,
  1379. state_ids: [1,5,6,7],
  1380. }
  1381. diff = {}
  1382. result = App.Utils.formDiff(dataNow, dataLast)
  1383. deepEqual(result, diff, 'check form diff')
  1384. dataNow = {
  1385. owner_id: '',
  1386. state_ids: [1,5,6,7],
  1387. }
  1388. dataLast = {
  1389. owner_id: 5,
  1390. state_ids: [1,5,6,7],
  1391. }
  1392. diff = {
  1393. owner_id: ''
  1394. }
  1395. result = App.Utils.formDiff(dataNow, dataLast)
  1396. deepEqual(result, diff, 'check form diff')
  1397. dataNow = {
  1398. state_id: 4,
  1399. pending_time: '2015-01-28T11:34:00Z'
  1400. }
  1401. dataLast = {
  1402. state_id: 5,
  1403. pending_time: undefined
  1404. }
  1405. diff = {
  1406. state_id: '4',
  1407. pending_time: '2015-01-28T11:34:00Z'
  1408. }
  1409. result = App.Utils.formDiff(dataNow, dataLast)
  1410. deepEqual(result, diff, 'check form diff')
  1411. dataNow = {
  1412. pending_time: undefined
  1413. }
  1414. dataLast = {
  1415. pending_time: null
  1416. }
  1417. diff = {}
  1418. result = App.Utils.formDiff(dataNow, dataLast)
  1419. deepEqual(result, diff, 'check form diff')
  1420. dataNow = {
  1421. ticket: {
  1422. pending_time: undefined,
  1423. },
  1424. }
  1425. dataLast = {
  1426. ticket: {
  1427. pending_time: null,
  1428. },
  1429. }
  1430. diff = {}
  1431. result = App.Utils.formDiff(dataNow, dataLast)
  1432. deepEqual(result, diff, 'check form diff')
  1433. dataNow = {
  1434. test: '123',
  1435. ticket: {
  1436. pending_time: undefined,
  1437. },
  1438. }
  1439. dataLast = {
  1440. test: '123',
  1441. ticket: {
  1442. pending_time: null,
  1443. },
  1444. }
  1445. diff = {}
  1446. result = App.Utils.formDiff(dataNow, dataLast)
  1447. deepEqual(result, diff, 'check form diff')
  1448. dataNow = {
  1449. test: '123',
  1450. }
  1451. dataLast = {}
  1452. diff = {
  1453. test: '123',
  1454. }
  1455. result = App.Utils.formDiff(dataNow, dataLast)
  1456. deepEqual(result, diff, 'check form diff')
  1457. dataNow = {
  1458. test: '123',
  1459. }
  1460. dataLast = {
  1461. test: [1,2,3,4]
  1462. }
  1463. diff = {
  1464. test: '123',
  1465. }
  1466. result = App.Utils.formDiff(dataNow, dataLast)
  1467. deepEqual(result, diff, 'check form diff')
  1468. dataNow = {
  1469. test: '123',
  1470. }
  1471. dataLast = {
  1472. test: {
  1473. 1: 1,
  1474. 2: 2,
  1475. }
  1476. }
  1477. diff = {
  1478. test: '123',
  1479. }
  1480. result = App.Utils.formDiff(dataNow, dataLast)
  1481. deepEqual(result, diff, 'check form diff')
  1482. dataNow = {
  1483. test: [1,2,3,'4']
  1484. }
  1485. dataLast = {
  1486. test: '123',
  1487. }
  1488. diff = {
  1489. test: ['1','2','3','4']
  1490. }
  1491. result = App.Utils.formDiff(dataNow, dataLast)
  1492. deepEqual(result, diff, 'check form diff')
  1493. dataNow = {
  1494. test: {
  1495. 1: 1,
  1496. 2: 2,
  1497. }
  1498. }
  1499. dataLast = {
  1500. test: '123',
  1501. }
  1502. diff = {
  1503. test: {
  1504. 1: '1',
  1505. 2: '2',
  1506. }
  1507. }
  1508. result = App.Utils.formDiff(dataNow, dataLast)
  1509. deepEqual(result, diff, 'check form diff')
  1510. // regression test for issue #2042 - incorrect notification when closing a tab after setting up an object
  1511. // A newly created attribute will have the empty string as its value, this should be ignored for formDiff comparison
  1512. dataNow = {
  1513. test: '',
  1514. }
  1515. dataLast = {}
  1516. diff = {}
  1517. result = App.Utils.formDiff(dataNow, dataLast)
  1518. deepEqual(result, diff, 'check form diff for a newly created attribute that is blank')
  1519. dataNow = {
  1520. test: '',
  1521. }
  1522. dataLast = {
  1523. test: '123',
  1524. }
  1525. diff = {
  1526. test: '',
  1527. }
  1528. result = App.Utils.formDiff(dataNow, dataLast)
  1529. deepEqual(result, diff, 'check form diff for setting a previously valid value to blank')
  1530. dataNow = {
  1531. test: '123',
  1532. ticket: {
  1533. pending_time: undefined,
  1534. },
  1535. }
  1536. dataLast = {
  1537. ticket: {
  1538. pending_time: null,
  1539. },
  1540. }
  1541. diff = {
  1542. test: '123',
  1543. }
  1544. result = App.Utils.formDiff(dataNow, dataLast)
  1545. deepEqual(result, diff, 'check form diff')
  1546. dataNow = undefined
  1547. dataLast = undefined
  1548. diff = {}
  1549. result = App.Utils.formDiff(dataNow, dataLast)
  1550. deepEqual(result, diff, 'check form diff')
  1551. dataNow = {}
  1552. dataLast = {"number":"10012","title":"some subject 123äöü","group_id":1,"owner_id":1,"customer_id":2,"state_id":3,"priority_id":2,"article":{"from":"Test Master Agent","to":"","cc":"","body":"dasdad","content_type":"text/html","ticket_id":12,"type_id":9,"sender_id":1,"internal":false,"form_id":"523405147"},"updated_at":"2015-01-29T09:22:23.000Z","pending_time":"2015-01-28T22:22:00.000Z","id":12}
  1553. diff = {}
  1554. result = App.Utils.formDiff(dataNow, dataLast)
  1555. deepEqual(result, diff, 'check form diff')
  1556. // do not compare content of data instances/objects
  1557. no = function test_object() {
  1558. this.a = function() { return 123; }
  1559. this.b = function() { return '1234'; }
  1560. this.c = function() { return [123]; }
  1561. this.d = [1,2,3];
  1562. this.e = 'abc';
  1563. }
  1564. no1 = new no()
  1565. no2 = new no()
  1566. no3 = new no()
  1567. dataNow = {
  1568. number:'10013',
  1569. Article: [no1],
  1570. }
  1571. dataLast = {
  1572. number: "10012",
  1573. title: "some subject 123äöü",
  1574. Article: [ no2, no3 ],
  1575. }
  1576. diff = {
  1577. number:'10013',
  1578. }
  1579. result = App.Utils.formDiff(dataNow, dataLast)
  1580. deepEqual(result, diff, 'check form diff')
  1581. dataNow = {
  1582. number:'10013',
  1583. Article: [no1,2],
  1584. }
  1585. dataLast = {
  1586. number: "10012",
  1587. title: "some subject 123äöü",
  1588. Article: [ no2, no3 ],
  1589. }
  1590. diff = {
  1591. number:'10013',
  1592. Article: ['2'],
  1593. }
  1594. result = App.Utils.formDiff(dataNow, dataLast)
  1595. deepEqual(result, diff, 'check form diff')
  1596. });
  1597. // check decimal format
  1598. test("check decimal format", function() {
  1599. var string = '123'
  1600. var result = '123.00'
  1601. var verify = App.Utils.decimal(string)
  1602. equal(verify, result, string)
  1603. string = '0.6'
  1604. result = '0.60'
  1605. verify = App.Utils.decimal(string)
  1606. equal(verify, result, string)
  1607. string = '6'
  1608. result = '6.00'
  1609. verify = App.Utils.decimal(string)
  1610. equal(verify, result, string)
  1611. string = 6.5
  1612. result = '6.50'
  1613. verify = App.Utils.decimal(string)
  1614. equal(verify, result, string)
  1615. string = '111111.6'
  1616. result = '111111.60'
  1617. verify = App.Utils.decimal(string)
  1618. equal(verify, result, string)
  1619. string = '111111.622'
  1620. result = '111111.62'
  1621. verify = App.Utils.decimal(string)
  1622. equal(verify, result, string)
  1623. string = 'abc.6'
  1624. result = 'abc.6'
  1625. verify = App.Utils.decimal(string)
  1626. equal(verify, result, string)
  1627. string = ''
  1628. result = ''
  1629. verify = App.Utils.decimal(string)
  1630. equal(verify, result, string)
  1631. string = undefined
  1632. result = ''
  1633. verify = App.Utils.decimal(string)
  1634. equal(verify, result, string)
  1635. string = null
  1636. result = ''
  1637. verify = App.Utils.decimal(string)
  1638. equal(verify, result, string)
  1639. });
  1640. // check formatTime format
  1641. test("check formatTime format", function() {
  1642. var string = '123'
  1643. var result = '123'
  1644. var verify = App.Utils.formatTime(string, 0)
  1645. equal(verify, result, string)
  1646. string = '6'
  1647. result = '06'
  1648. verify = App.Utils.formatTime(string, 2)
  1649. equal(verify, result, string)
  1650. string = ''
  1651. result = '00'
  1652. verify = App.Utils.formatTime(string, 2)
  1653. equal(verify, result, string)
  1654. string = undefined
  1655. result = ''
  1656. verify = App.Utils.formatTime(string, 2)
  1657. equal(verify, result, string)
  1658. string = null
  1659. result = ''
  1660. verify = App.Utils.formatTime(string, 2)
  1661. equal(verify, result, string)
  1662. });
  1663. // check diffPosition
  1664. test("check diffPosition format", function() {
  1665. var a = [1,2,3,4]
  1666. var b = [1,2,3,4,5]
  1667. var result = [
  1668. {
  1669. position: 4,
  1670. id: 5,
  1671. },
  1672. ]
  1673. var verify = App.Utils.diffPositionAdd(a, b)
  1674. deepEqual(verify, result)
  1675. a = [2,3,4]
  1676. b = [1,2,3,4]
  1677. result = [
  1678. {
  1679. position: 0,
  1680. id: 1,
  1681. },
  1682. ]
  1683. verify = App.Utils.diffPositionAdd(a, b)
  1684. deepEqual(verify, result)
  1685. a = [2,3,4]
  1686. b = [1,2,3,4,5]
  1687. result = [
  1688. {
  1689. position: 0,
  1690. id: 1,
  1691. },
  1692. {
  1693. position: 4,
  1694. id: 5,
  1695. },
  1696. ]
  1697. verify = App.Utils.diffPositionAdd(a, b)
  1698. deepEqual(verify, result)
  1699. a = [2,3,4]
  1700. b = [1,99,12,2,3,4,5]
  1701. result = [
  1702. {
  1703. position: 0,
  1704. id: 1,
  1705. },
  1706. {
  1707. position: 1,
  1708. id: 99,
  1709. },
  1710. {
  1711. position: 2,
  1712. id: 12,
  1713. },
  1714. {
  1715. position: 6,
  1716. id: 5,
  1717. },
  1718. ]
  1719. verify = App.Utils.diffPositionAdd(a, b)
  1720. deepEqual(verify, result)
  1721. a = [4,3,1]
  1722. b = [1,2,3,4,5]
  1723. result = false
  1724. verify = App.Utils.diffPositionAdd(a, b)
  1725. deepEqual(verify, result)
  1726. a = ['Ticket-347', 'TicketCreateScreen-2217']
  1727. b = ['Ticket-347', 'TicketCreateScreen-2217', 'TicketCreateScreen-71517']
  1728. result = [
  1729. {
  1730. position: 2,
  1731. id: 'TicketCreateScreen-71517',
  1732. },
  1733. ]
  1734. verify = App.Utils.diffPositionAdd(a, b)
  1735. deepEqual(verify, result)
  1736. });
  1737. // check textLengthWithUrl format
  1738. test("check textLengthWithUrl format", function() {
  1739. var string = '123'
  1740. var result = 3
  1741. var verify = App.Utils.textLengthWithUrl(string)
  1742. equal(verify, result)
  1743. string = '123 http is not here'
  1744. result = 20
  1745. verify = App.Utils.textLengthWithUrl(string)
  1746. equal(verify, result)
  1747. string = '123 http://host is not here'
  1748. result = 39
  1749. verify = App.Utils.textLengthWithUrl(string)
  1750. equal(verify, result)
  1751. string = '123 http://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX is not here'
  1752. result = 39
  1753. verify = App.Utils.textLengthWithUrl(string)
  1754. equal(verify, result)
  1755. string = 'http://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
  1756. result = 23
  1757. verify = App.Utils.textLengthWithUrl(string)
  1758. equal(verify, result)
  1759. string = 'http://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX, some other text'
  1760. result = 23 + 17
  1761. verify = App.Utils.textLengthWithUrl(string)
  1762. equal(verify, result)
  1763. string = 'some other text,http://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
  1764. result = 23 + 16
  1765. verify = App.Utils.textLengthWithUrl(string)
  1766. equal(verify, result)
  1767. string = 'some other text, http://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX?abc=123;aaa=ab+c usw'
  1768. result = 23 + 21
  1769. verify = App.Utils.textLengthWithUrl(string)
  1770. equal(verify, result)
  1771. });
  1772. // check getRecipientArticle format
  1773. test('check getRecipientArticle format', function() {
  1774. var customer = {
  1775. login: 'login',
  1776. firstname: 'firstname',
  1777. lastname: 'lastname',
  1778. email: 'customer@example.com',
  1779. }
  1780. var ticket = {
  1781. customer: customer,
  1782. }
  1783. var article = {
  1784. type: {
  1785. name: 'phone',
  1786. },
  1787. sender: {
  1788. name: 'Customer',
  1789. },
  1790. from: customer.email,
  1791. to: 'some group',
  1792. message_id: 'message_id1',
  1793. created_by: {
  1794. login: 'login',
  1795. firstname: 'firstname',
  1796. lastname: 'lastname',
  1797. email: 'article_created_by@example.com',
  1798. },
  1799. }
  1800. var result = {
  1801. to: 'customer@example.com',
  1802. cc: '',
  1803. body: '',
  1804. in_reply_to: 'message_id1',
  1805. }
  1806. var verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  1807. deepEqual(verify, result)
  1808. customer = {
  1809. login: 'login',
  1810. firstname: 'firstname',
  1811. lastname: 'lastname',
  1812. email: 'customer@example.com',
  1813. }
  1814. ticket = {
  1815. customer: customer,
  1816. }
  1817. article = {
  1818. type: {
  1819. name: 'phone',
  1820. },
  1821. sender: {
  1822. name: 'Customer',
  1823. },
  1824. from: customer.email,
  1825. message_id: 'message_id2',
  1826. created_by: {
  1827. login: 'login',
  1828. firstname: 'firstname',
  1829. lastname: 'lastname',
  1830. email: 'article_created_by@example.com',
  1831. },
  1832. }
  1833. result = {
  1834. to: customer.email,
  1835. cc: '',
  1836. body: '',
  1837. in_reply_to: 'message_id2',
  1838. }
  1839. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  1840. deepEqual(verify, result)
  1841. customer = {
  1842. login: 'login',
  1843. firstname: 'firstname',
  1844. lastname: 'lastname',
  1845. email: 'customer@example.com',
  1846. }
  1847. ticket = {
  1848. customer: customer,
  1849. }
  1850. article = {
  1851. message_id: 'message_id3',
  1852. type: {
  1853. name: 'phone',
  1854. },
  1855. sender: {
  1856. name: 'Agent',
  1857. },
  1858. from: 'article_created_by@example.com',
  1859. created_by: {
  1860. login: 'login',
  1861. firstname: 'firstname',
  1862. lastname: 'lastname',
  1863. email: 'article_created_by@example.com',
  1864. },
  1865. }
  1866. result = {
  1867. to: 'customer@example.com',
  1868. cc: '',
  1869. body: '',
  1870. in_reply_to: 'message_id3',
  1871. }
  1872. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  1873. deepEqual(verify, result)
  1874. customer = {
  1875. login: 'login',
  1876. firstname: 'firstname',
  1877. lastname: 'lastname',
  1878. email: 'customer@example.com',
  1879. }
  1880. ticket = {
  1881. customer: customer,
  1882. }
  1883. article = {
  1884. message_id: 'message_id4',
  1885. created_by: customer,
  1886. type: {
  1887. name: 'web',
  1888. },
  1889. sender: {
  1890. name: 'Customer',
  1891. },
  1892. from: customer.email,
  1893. to: 'some group',
  1894. created_by: {
  1895. login: 'login',
  1896. firstname: 'firstname',
  1897. lastname: 'lastname',
  1898. email: 'article_created_by@example.com',
  1899. },
  1900. }
  1901. result = {
  1902. to: 'customer@example.com',
  1903. cc: '',
  1904. body: '',
  1905. in_reply_to: 'message_id4',
  1906. }
  1907. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  1908. deepEqual(verify, result)
  1909. customer = {
  1910. login: 'login',
  1911. firstname: 'firstname',
  1912. lastname: 'lastname',
  1913. email: 'customer@example.com',
  1914. }
  1915. ticket = {
  1916. customer: customer,
  1917. }
  1918. article = {
  1919. message_id: 'message_id5',
  1920. type: {
  1921. name: 'web',
  1922. },
  1923. sender: {
  1924. name: 'Customer',
  1925. },
  1926. from: customer.email,
  1927. created_by: {
  1928. login: 'login',
  1929. firstname: 'firstname',
  1930. lastname: 'lastname',
  1931. email: 'article_created_by@example.com',
  1932. }
  1933. }
  1934. result = {
  1935. to: 'customer@example.com',
  1936. cc: '',
  1937. body: '',
  1938. in_reply_to: 'message_id5',
  1939. }
  1940. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  1941. deepEqual(verify, result)
  1942. customer = {
  1943. login: 'login',
  1944. firstname: 'firstname',
  1945. lastname: 'lastname',
  1946. email: 'customer@example.com',
  1947. }
  1948. ticket = {
  1949. customer: customer,
  1950. }
  1951. article = {
  1952. message_id: 'message_id6',
  1953. type: {
  1954. name: 'email',
  1955. },
  1956. sender: {
  1957. name: 'Customer',
  1958. },
  1959. from: customer.email,
  1960. to: 'some group',
  1961. created_by: {
  1962. login: 'login',
  1963. firstname: 'firstname',
  1964. lastname: 'lastname',
  1965. email: 'article_created_by@example.com',
  1966. }
  1967. }
  1968. result = {
  1969. to: 'customer@example.com',
  1970. cc: '',
  1971. body: '',
  1972. in_reply_to: 'message_id6',
  1973. }
  1974. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  1975. deepEqual(verify, result)
  1976. customer = {
  1977. login: 'login',
  1978. firstname: 'firstname',
  1979. lastname: 'lastname',
  1980. email: 'customer@example.com',
  1981. }
  1982. ticket = {
  1983. customer: customer,
  1984. }
  1985. article = {
  1986. message_id: 'message_id7',
  1987. type: {
  1988. name: 'email',
  1989. },
  1990. sender: {
  1991. name: 'Customer',
  1992. },
  1993. from: 'some other invalid part, ' + customer.email,
  1994. to: 'some group',
  1995. created_by: {
  1996. login: 'login',
  1997. firstname: 'firstname',
  1998. lastname: 'lastname',
  1999. email: 'article_created_by@example.com',
  2000. }
  2001. }
  2002. result = {
  2003. to: 'customer@example.com',
  2004. cc: '',
  2005. body: '',
  2006. in_reply_to: 'message_id7',
  2007. }
  2008. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2009. console.log(verify)
  2010. deepEqual(verify, result)
  2011. customer = {
  2012. login: 'login',
  2013. firstname: 'firstname',
  2014. lastname: 'lastname',
  2015. email: 'customer@example.com',
  2016. }
  2017. ticket = {
  2018. customer: customer,
  2019. }
  2020. article = {
  2021. message_id: 'message_id7.1',
  2022. type: {
  2023. name: 'email',
  2024. },
  2025. sender: {
  2026. name: 'Customer',
  2027. },
  2028. from: 'some other invalid part, Some Realname ' + customer.email,
  2029. to: 'some group',
  2030. created_by: {
  2031. login: 'login',
  2032. firstname: 'firstname',
  2033. lastname: 'lastname',
  2034. email: 'article_created_by@example.com',
  2035. }
  2036. }
  2037. result = {
  2038. to: 'customer@example.com',
  2039. cc: '',
  2040. body: '',
  2041. in_reply_to: 'message_id7.1',
  2042. }
  2043. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2044. console.log(verify)
  2045. deepEqual(verify, result)
  2046. customer = {
  2047. login: 'login',
  2048. firstname: 'firstname',
  2049. lastname: 'lastname',
  2050. email: 'customer@example.com',
  2051. }
  2052. ticket = {
  2053. customer: customer,
  2054. }
  2055. article = {
  2056. message_id: 'message_id7.2',
  2057. type: {
  2058. name: 'email',
  2059. },
  2060. sender: {
  2061. name: 'Customer',
  2062. },
  2063. from: 'some other invalid part, Some Realname ' + customer.email + ' , abc',
  2064. to: 'some group',
  2065. created_by: {
  2066. login: 'login',
  2067. firstname: 'firstname',
  2068. lastname: 'lastname',
  2069. email: 'article_created_by@example.com',
  2070. }
  2071. }
  2072. result = {
  2073. to: 'customer@example.com',
  2074. cc: '',
  2075. body: '',
  2076. in_reply_to: 'message_id7.2',
  2077. }
  2078. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2079. console.log(verify)
  2080. deepEqual(verify, result)
  2081. customer = {
  2082. login: 'login',
  2083. firstname: 'firstname',
  2084. lastname: 'lastname',
  2085. email: 'customer@example.com',
  2086. }
  2087. agent = {
  2088. login: 'login',
  2089. firstname: 'firstname',
  2090. lastname: 'lastname',
  2091. email: 'agent@example.com',
  2092. }
  2093. ticket = {
  2094. customer: customer,
  2095. }
  2096. article = {
  2097. message_id: 'message_id8',
  2098. created_by: agent,
  2099. type: {
  2100. name: 'email',
  2101. },
  2102. sender: {
  2103. name: 'Agent',
  2104. },
  2105. from: 'customer2@example.com',
  2106. to: 'customer@example.com',
  2107. }
  2108. result = {
  2109. to: 'customer2@example.com',
  2110. cc: '',
  2111. body: '',
  2112. in_reply_to: 'message_id8',
  2113. }
  2114. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2115. deepEqual(verify, result)
  2116. customer = {
  2117. login: 'login',
  2118. firstname: 'firstname',
  2119. lastname: 'lastname',
  2120. email: 'customer@example.com',
  2121. }
  2122. agent = {
  2123. login: 'login',
  2124. firstname: 'firstname',
  2125. lastname: 'lastname',
  2126. email: 'agent@example.com',
  2127. }
  2128. ticket = {
  2129. customer: customer,
  2130. }
  2131. article = {
  2132. message_id: 'message_id9',
  2133. created_by: agent,
  2134. type: {
  2135. name: 'email',
  2136. },
  2137. sender: {
  2138. name: 'Agent',
  2139. },
  2140. from: 'agent@example.com',
  2141. to: 'customer@example.com',
  2142. }
  2143. result = {
  2144. to: 'customer@example.com',
  2145. cc: '',
  2146. body: '',
  2147. in_reply_to: 'message_id9',
  2148. }
  2149. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2150. deepEqual(verify, result)
  2151. customer = {
  2152. login: 'login',
  2153. firstname: 'firstname',
  2154. lastname: 'lastname',
  2155. email: 'customer@example.com',
  2156. }
  2157. agent = {
  2158. login: 'login',
  2159. firstname: 'firstname',
  2160. lastname: 'lastname',
  2161. email: 'agent@example.com',
  2162. }
  2163. ticket = {
  2164. customer: customer,
  2165. }
  2166. article = {
  2167. message_id: 'message_id10',
  2168. created_by: agent,
  2169. type: {
  2170. name: 'email',
  2171. },
  2172. sender: {
  2173. name: 'Agent',
  2174. },
  2175. from: 'Agent@Example.com',
  2176. to: 'customer@example.com',
  2177. cc: 'zammad@example.com',
  2178. }
  2179. result = {
  2180. to: 'customer@example.com',
  2181. cc: '',
  2182. body: '',
  2183. in_reply_to: 'message_id10',
  2184. }
  2185. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2186. deepEqual(verify, result)
  2187. customer = {
  2188. login: 'login',
  2189. firstname: 'firstname',
  2190. lastname: 'lastname',
  2191. email: 'customer@example.com',
  2192. }
  2193. agent = {
  2194. login: 'login',
  2195. firstname: 'firstname',
  2196. lastname: 'lastname',
  2197. email: 'agent@example.com',
  2198. }
  2199. ticket = {
  2200. customer: customer,
  2201. }
  2202. article = {
  2203. message_id: 'message_id11',
  2204. created_by: agent,
  2205. type: {
  2206. name: 'email',
  2207. },
  2208. sender: {
  2209. name: 'Agent',
  2210. },
  2211. from: 'Agent@Example.com',
  2212. to: 'customer@example.com, agent@example.com',
  2213. cc: 'zammad@example.com',
  2214. }
  2215. result = {
  2216. to: 'customer@example.com, agent@example.com',
  2217. cc: 'zammad@example.com',
  2218. body: '',
  2219. in_reply_to: 'message_id11',
  2220. }
  2221. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type, [], true)
  2222. deepEqual(verify, result)
  2223. customer = {
  2224. login: 'login',
  2225. firstname: 'firstname',
  2226. lastname: 'lastname',
  2227. email: 'customer@example.com',
  2228. }
  2229. agent = {
  2230. login: 'login',
  2231. firstname: 'firstname',
  2232. lastname: 'lastname',
  2233. email: 'agent@example.com',
  2234. }
  2235. ticket = {
  2236. customer: customer,
  2237. }
  2238. article = {
  2239. message_id: 'message_id12',
  2240. created_by: agent,
  2241. type: {
  2242. name: 'email',
  2243. },
  2244. sender: {
  2245. name: 'Agent',
  2246. },
  2247. from: 'Agent@Example.com',
  2248. to: 'customeR@EXAMPLE.com, agent@example.com',
  2249. cc: 'zammad@example.com, customer@example.com',
  2250. }
  2251. result = {
  2252. to: 'customer@example.com, agent@example.com',
  2253. cc: 'zammad@example.com',
  2254. body: '',
  2255. in_reply_to: 'message_id12',
  2256. }
  2257. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, [], true)
  2258. deepEqual(verify, result)
  2259. customer = {
  2260. login: 'login',
  2261. firstname: 'firstname',
  2262. lastname: 'lastname',
  2263. email: 'customer@example.com',
  2264. }
  2265. agent = {
  2266. login: 'login',
  2267. firstname: 'firstname',
  2268. lastname: 'lastname',
  2269. email: 'agent@example.com',
  2270. }
  2271. ticket = {
  2272. customer: customer,
  2273. }
  2274. article = {
  2275. message_id: 'message_id13',
  2276. created_by: agent,
  2277. type: {
  2278. name: 'email',
  2279. },
  2280. sender: {
  2281. name: 'Agent',
  2282. },
  2283. from: 'Agent@Example.com',
  2284. to: 'customeR@EXAMPLE.com, agent@example.com, zammad2@EXAMPLE.com',
  2285. cc: 'zammad@example.com, customer2@example.com',
  2286. }
  2287. result = {
  2288. to: 'customer@example.com, agent@example.com',
  2289. cc: 'customer2@example.com',
  2290. body: '',
  2291. in_reply_to: 'message_id13',
  2292. }
  2293. email_addresses = [
  2294. {
  2295. email: 'zammad@example.com',
  2296. },
  2297. {
  2298. email: 'zammad2@example.com',
  2299. }
  2300. ]
  2301. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, true)
  2302. deepEqual(verify, result)
  2303. customer = {
  2304. login: 'login',
  2305. firstname: 'firstname',
  2306. lastname: 'lastname',
  2307. email: 'customer@example.com',
  2308. }
  2309. agent = {
  2310. login: 'login',
  2311. firstname: 'firstname',
  2312. lastname: 'lastname',
  2313. email: 'AGENT@example.com',
  2314. }
  2315. ticket = {
  2316. customer: customer,
  2317. }
  2318. article = {
  2319. message_id: 'message_id14',
  2320. created_by: agent,
  2321. type: {
  2322. name: 'email',
  2323. },
  2324. sender: {
  2325. name: 'Agent',
  2326. },
  2327. from: 'Agent@Example.com',
  2328. to: 'customeR@EXAMPLE.com, agent@example.com, zammad2@EXAMPLE.com',
  2329. cc: 'zammad@example.com, customer2@example.com',
  2330. }
  2331. result = {
  2332. to: 'customer@example.com, agent@example.com',
  2333. cc: 'customer2@example.com',
  2334. body: '',
  2335. in_reply_to: 'message_id14',
  2336. }
  2337. email_addresses = [
  2338. {
  2339. email: 'zammad@example.com',
  2340. },
  2341. {
  2342. email: 'zammad2@example.com',
  2343. }
  2344. ]
  2345. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, true)
  2346. deepEqual(verify, result)
  2347. customer = {
  2348. login: 'login',
  2349. firstname: 'firstname',
  2350. lastname: 'lastname',
  2351. email: 'zammad@example.com',
  2352. }
  2353. ticket = {
  2354. customer: customer,
  2355. }
  2356. article = {
  2357. message_id: 'message_id15',
  2358. created_by: customer,
  2359. type: {
  2360. name: 'email',
  2361. },
  2362. sender: {
  2363. name: 'Agent',
  2364. },
  2365. from: 'zammad@EXAMPLE.com',
  2366. to: 'customeR@EXAMPLE.com, agent@example.com, zammad2@EXAMPLE.com',
  2367. cc: 'zammad@example.com, customer2@example.com',
  2368. }
  2369. result = {
  2370. to: 'customer@example.com, agent@example.com',
  2371. cc: 'customer2@example.com',
  2372. body: '',
  2373. in_reply_to: 'message_id15',
  2374. }
  2375. email_addresses = [
  2376. {
  2377. email: 'zammad@example.com',
  2378. },
  2379. {
  2380. email: 'zammad2@example.com',
  2381. }
  2382. ]
  2383. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, true)
  2384. deepEqual(verify, result)
  2385. customer = {
  2386. login: 'login',
  2387. firstname: 'firstname',
  2388. lastname: 'lastname',
  2389. email: 'customer@example.com',
  2390. }
  2391. ticket = {
  2392. customer: customer,
  2393. }
  2394. article = {
  2395. message_id: 'message_id16',
  2396. created_by: customer,
  2397. type: {
  2398. name: 'email',
  2399. },
  2400. sender: {
  2401. name: 'Agent',
  2402. },
  2403. from: 'customer@example.com',
  2404. to: 'customer1@example.com, customer2@example.com, zammad@example.com',
  2405. cc: '',
  2406. }
  2407. result = {
  2408. to: 'customer1@example.com, customer2@example.com, customer@example.com',
  2409. cc: '',
  2410. body: '',
  2411. in_reply_to: 'message_id16',
  2412. }
  2413. email_addresses = [
  2414. {
  2415. email: 'zammad@example.com',
  2416. },
  2417. {
  2418. email: 'zammad2@example.com',
  2419. }
  2420. ]
  2421. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, true)
  2422. deepEqual(verify, result)
  2423. customer = {
  2424. login: 'login',
  2425. firstname: 'firstname',
  2426. lastname: 'lastname',
  2427. email: 'customer@example.com',
  2428. }
  2429. ticket = {
  2430. customer: customer,
  2431. }
  2432. article = {
  2433. message_id: 'message_id17',
  2434. created_by: customer,
  2435. type: {
  2436. name: 'email',
  2437. },
  2438. sender: {
  2439. name: 'Agent',
  2440. },
  2441. from: 'customer@example.com',
  2442. to: 'customer1@example.com, customer2@example.com, zammad@example.com, customer2+2@example.com',
  2443. cc: '',
  2444. }
  2445. result = {
  2446. to: 'customer1@example.com, customer2@example.com, customer2+2@example.com, customer@example.com',
  2447. cc: '',
  2448. body: '',
  2449. in_reply_to: 'message_id17',
  2450. }
  2451. email_addresses = [
  2452. {
  2453. email: 'zammad@example.com',
  2454. },
  2455. {
  2456. email: 'zammad2@example.com',
  2457. }
  2458. ]
  2459. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, true)
  2460. deepEqual(verify, result)
  2461. customer = {
  2462. login: 'login',
  2463. firstname: 'firstname',
  2464. lastname: 'lastname',
  2465. email: 'customer@example.com',
  2466. }
  2467. agent = {
  2468. login: 'login',
  2469. firstname: 'firstname',
  2470. lastname: 'lastname',
  2471. email: 'zammad@example.com',
  2472. }
  2473. ticket = {
  2474. customer: customer,
  2475. }
  2476. article = {
  2477. message_id: 'message_id18',
  2478. created_by: agent,
  2479. type: {
  2480. name: 'email',
  2481. },
  2482. sender: {
  2483. name: 'Agent',
  2484. },
  2485. from: 'zammad@example.com',
  2486. to: 'customer@example.com',
  2487. cc: '',
  2488. }
  2489. result = {
  2490. to: 'customer@example.com',
  2491. cc: '',
  2492. body: '',
  2493. in_reply_to: 'message_id18',
  2494. }
  2495. email_addresses = [
  2496. {
  2497. email: 'zammad@example.com',
  2498. },
  2499. {
  2500. email: 'zammad2@example.com',
  2501. }
  2502. ]
  2503. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, true)
  2504. deepEqual(verify, result)
  2505. customer = {
  2506. login: 'login',
  2507. firstname: 'firstname',
  2508. lastname: 'lastname',
  2509. email: 'customer@example.com',
  2510. }
  2511. agent = {
  2512. login: 'login',
  2513. firstname: 'firstname',
  2514. lastname: 'lastname',
  2515. email: 'zammad@example.com',
  2516. }
  2517. ticket = {
  2518. customer: customer,
  2519. }
  2520. article = {
  2521. message_id: 'message_id19',
  2522. created_by: agent,
  2523. type: {
  2524. name: 'email',
  2525. },
  2526. sender: {
  2527. name: 'Agent',
  2528. },
  2529. from: 'Sender <zammad@example.com>',
  2530. to: 'Customer <customer@example.com>',
  2531. cc: '',
  2532. }
  2533. result = {
  2534. to: 'customer@example.com',
  2535. cc: '',
  2536. body: '',
  2537. in_reply_to: 'message_id19',
  2538. }
  2539. email_addresses = [
  2540. {
  2541. email: 'zammad@example.com',
  2542. },
  2543. {
  2544. email: 'zammad2@example.com',
  2545. }
  2546. ]
  2547. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, false)
  2548. deepEqual(verify, result)
  2549. agent = {
  2550. login: 'login',
  2551. firstname: 'firstname',
  2552. lastname: 'lastname',
  2553. email: 'agent@example.com',
  2554. }
  2555. ticket = {
  2556. customer: agent,
  2557. }
  2558. article = {
  2559. message_id: 'message_id20',
  2560. created_by: agent,
  2561. type: {
  2562. name: 'email',
  2563. },
  2564. sender: {
  2565. name: 'Agent',
  2566. },
  2567. from: 'Agent <Agent@Example.com>',
  2568. to: 'Sender <zammad@example.com>',
  2569. cc: '',
  2570. }
  2571. result = {
  2572. to: 'agent@example.com',
  2573. cc: '',
  2574. body: '',
  2575. in_reply_to: 'message_id20',
  2576. }
  2577. email_addresses = [
  2578. {
  2579. email: 'zammad@example.com',
  2580. },
  2581. {
  2582. email: 'zammad2@example.com',
  2583. }
  2584. ]
  2585. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, false)
  2586. deepEqual(verify, result)
  2587. agent = {
  2588. login: 'login',
  2589. firstname: 'firstname',
  2590. lastname: 'lastname',
  2591. email: 'agent@example.com',
  2592. }
  2593. ticket = {
  2594. customer: agent,
  2595. }
  2596. article = {
  2597. message_id: 'message_id20',
  2598. created_by: agent,
  2599. type: {
  2600. name: 'email',
  2601. },
  2602. sender: {
  2603. name: 'Agent',
  2604. },
  2605. from: 'Agent <Agent@Example.com>',
  2606. to: 'somebodyelse@example.com, Zammad <zammad@example.com>',
  2607. cc: '',
  2608. }
  2609. result = {
  2610. to: 'agent@example.com',
  2611. cc: '',
  2612. body: '',
  2613. in_reply_to: 'message_id20',
  2614. }
  2615. email_addresses = [
  2616. {
  2617. email: 'zammad@example.com',
  2618. },
  2619. {
  2620. email: 'zammad2@example.com',
  2621. }
  2622. ]
  2623. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, false)
  2624. deepEqual(verify, result)
  2625. customer = {
  2626. login: 'login',
  2627. firstname: 'firstname',
  2628. lastname: 'lastname',
  2629. email: "'customer@example.com'",
  2630. }
  2631. agent = {
  2632. login: 'login',
  2633. firstname: 'firstname',
  2634. lastname: 'lastname',
  2635. email: 'agent@example.com',
  2636. }
  2637. ticket = {
  2638. customer: customer,
  2639. }
  2640. article = {
  2641. message_id: 'message_id21',
  2642. created_by: agent,
  2643. type: {
  2644. name: 'email',
  2645. },
  2646. sender: {
  2647. name: 'Agent',
  2648. },
  2649. from: customer.email,
  2650. to: 'agent@example.com',
  2651. }
  2652. result = {
  2653. to: 'customer@example.com',
  2654. cc: '',
  2655. body: '',
  2656. in_reply_to: 'message_id21',
  2657. }
  2658. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2659. deepEqual(verify, result)
  2660. // Regression test for issue #2184
  2661. // Case 1
  2662. // 1. Create a "Received Call" Ticket for article_customer
  2663. // 2. Change the Customer of the ticket to ticket_customer (but article.from still points to article_customer)
  2664. // 3. Reply to the first Article
  2665. // Recipient SHOULD BE Article.from
  2666. var article_customer = {
  2667. login: 'login',
  2668. firstname: 'article',
  2669. lastname: 'lastname',
  2670. email: 'article_customer@example.com',
  2671. }
  2672. var ticket_customer = {
  2673. login: 'login2',
  2674. firstname: 'ticket',
  2675. lastname: 'lastname',
  2676. email: 'ticket_customer@example.com',
  2677. }
  2678. ticket = {
  2679. customer: ticket_customer,
  2680. }
  2681. article = {
  2682. type: {
  2683. name: 'phone',
  2684. },
  2685. sender: {
  2686. name: 'Customer',
  2687. },
  2688. from: 'article lastname <article_customer@example.com>',
  2689. to: 'some group',
  2690. message_id: 'message_id22',
  2691. created_by: {
  2692. login: 'login',
  2693. firstname: 'firstname',
  2694. lastname: 'lastname',
  2695. email: 'article_created_by@example.com',
  2696. },
  2697. }
  2698. result = {
  2699. to: 'article_customer@example.com',
  2700. cc: '',
  2701. body: '',
  2702. in_reply_to: 'message_id22',
  2703. }
  2704. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2705. deepEqual(verify, result)
  2706. // Regression test for issue #2184
  2707. // Case 2
  2708. // 1. Create a "Outbound Call" Ticket for article_customer
  2709. // 2. Change the Customer of the Ticket to ticket_customer (but article.to still points to article_customer)
  2710. // 3. Reply to the first Article
  2711. // Recipient SHOULD BE Article.to
  2712. article_customer = {
  2713. login: 'login',
  2714. firstname: 'article',
  2715. lastname: 'lastname',
  2716. email: 'article_customer@example.com',
  2717. }
  2718. ticket_customer = {
  2719. login: 'login2',
  2720. firstname: 'ticket',
  2721. lastname: 'lastname',
  2722. email: 'ticket_customer@example.com',
  2723. }
  2724. ticket = {
  2725. customer: ticket_customer,
  2726. }
  2727. article = {
  2728. type: {
  2729. name: 'phone',
  2730. },
  2731. sender: {
  2732. name: 'Agent',
  2733. },
  2734. from: 'agent1@example.com',
  2735. to: article_customer.email,
  2736. message_id: 'message_id23',
  2737. created_by: {
  2738. login: 'login',
  2739. firstname: 'firstname',
  2740. lastname: 'lastname',
  2741. email: 'article_created_by@example.com',
  2742. },
  2743. }
  2744. result = {
  2745. to: 'article_customer@example.com',
  2746. cc: '',
  2747. body: '',
  2748. in_reply_to: 'message_id23',
  2749. }
  2750. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2751. deepEqual(verify, result)
  2752. });
  2753. test("contentTypeCleanup", function() {
  2754. var source = "image/png"
  2755. var should = "image/png"
  2756. var result = App.Utils.contentTypeCleanup(source)
  2757. equal(result, should, source)
  2758. source = "image/png; some.file"
  2759. should = "image/png"
  2760. result = App.Utils.contentTypeCleanup(source)
  2761. equal(result, should, source)
  2762. source = "image/png;some.file"
  2763. should = "image/png"
  2764. result = App.Utils.contentTypeCleanup(source)
  2765. equal(result, should, source)
  2766. source = "image/jpeg;some.file"
  2767. should = "image/jpeg"
  2768. result = App.Utils.contentTypeCleanup(source)
  2769. equal(result, should, source)
  2770. source = "image/jpg;some.file"
  2771. should = "image/jpg"
  2772. result = App.Utils.contentTypeCleanup(source)
  2773. equal(result, should, source)
  2774. source = "image/gif;some.file"
  2775. should = "image/gif"
  2776. result = App.Utils.contentTypeCleanup(source)
  2777. equal(result, should, source)
  2778. source = "image/gif\n;some.file"
  2779. should = "image/gif"
  2780. result = App.Utils.contentTypeCleanup(source)
  2781. equal(result, should, source)
  2782. });
  2783. // htmlImage2DataUrl
  2784. test("htmlImage2DataUrl", function() {
  2785. var source = '<div>test 13</div>'
  2786. var should = '<div>test 13</div>'
  2787. var result = App.Utils.htmlImage2DataUrl(source)
  2788. equal(result, should, source)
  2789. source = 'some test'
  2790. should = 'some test'
  2791. result = App.Utils.htmlImage2DataUrl(source)
  2792. equal(result, should, source)
  2793. source = '<img src="some url">some test'
  2794. should = '<img src="data:,">some test'
  2795. result = App.Utils.htmlImage2DataUrl(source)
  2796. equal(result, should, source)
  2797. source = '<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAADAAEDAREAAhEBAxEB/8QAFAABAAAAAAAAAAAAAAAAAAAACv/EABQQAQAAAAAAAAAAAAAAAAAAAAD/xAAUAQEAAAAAAAAAAAAAAAAAAAAF/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AbgQDv//Z">some test'
  2798. should = '<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAADAAEDAREAAhEBAxEB/8QAFAABAAAAAAAAAAAAAAAAAAAACv/EABQQAQAAAAAAAAAAAAAAAAAAAAD/xAAUAQEAAAAAAAAAAAAAAAAAAAAF/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AbgQDv//Z">some test'
  2799. result = App.Utils.htmlImage2DataUrl(source)
  2800. equal(result, should, source)
  2801. source = '<img src="data:image/jpeg;base64,some_data_123">some <img src="some url">test'
  2802. should = '<img src="data:image/jpeg;base64,some_data_123">some <img src="data:,">test'
  2803. result = App.Utils.htmlImage2DataUrl(source)
  2804. equal(result, should, source)
  2805. // GitHub issue #2305
  2806. source = '<img src="cid:1234">some test'
  2807. should = '<img src="cid:1234">some test'
  2808. result = App.Utils.htmlImage2DataUrl(source)
  2809. equal(result, should, source)
  2810. // GitHub issue #2701
  2811. source = '<img alt="foo">some test'
  2812. should = '<img alt="foo">some test'
  2813. result = App.Utils.htmlImage2DataUrl(source)
  2814. equal(result, should, source)
  2815. });
  2816. test('App.Utils.icon()', function() {
  2817. // When given no arguments,
  2818. // expect @icon() to return null
  2819. equal(App.Utils.icon(), null, 'with no arguments')
  2820. // On a modern browser and when given a single argument,
  2821. // expect @icon(name) to return an <svg> tag
  2822. window.svgPolyfill = false
  2823. svgTag = '<svg class="icon icon-foo "><use xlink:href="assets/images/icons.svg#icon-foo" /></svg>'
  2824. equal(App.Utils.icon('foo'), svgTag, 'with one arg / no SVG polyfill')
  2825. // On a modern browser and when given two arguments,
  2826. // expect @icon(name) to return an <svg> tag
  2827. // with second arg as add'l class name
  2828. window.svgPolyfill = false
  2829. svgTag = '<svg class="icon icon-foo bar"><use xlink:href="assets/images/icons.svg#icon-foo" /></svg>'
  2830. equal(App.Utils.icon('foo', 'bar'), svgTag, 'with two args / no SVG polyfill')
  2831. // On a browser requiring SVG polyfill and when given a single argument,
  2832. // expect @icon(name, class) to return an <svg> tag
  2833. // with pathless xlink:href attr
  2834. window.svgPolyfill = true
  2835. svgTag = '<svg class="icon icon-foo "><use xlink:href="#icon-foo" /></svg>'
  2836. equal(App.Utils.icon('foo'), svgTag, 'with one arg / SVG polyfill')
  2837. // On a browser requiring SVG polyfill and when given two arguments,
  2838. // expect @icon(name, class) to return an <svg> tag
  2839. // with pathless xlink:href attr and second arg as add'l class name
  2840. window.svgPolyfill = true
  2841. svgTag = '<svg class="icon icon-foo bar"><use xlink:href="#icon-foo" /></svg>'
  2842. equal(App.Utils.icon('foo', 'bar'), svgTag, 'with two args / SVG polyfill')
  2843. // For a left-to-right browser language and when given an argument containing '{start}' or '{end}',
  2844. // expect @icon(name) to return an <svg> tag
  2845. // replacing '{start}' with 'left' and '{end}' with 'right'
  2846. window.svgPolyfill = false
  2847. App.i18n.dir = function() { return 'ltr' }
  2848. svgTag = '<svg class="icon icon-arrow-left "><use xlink:href="assets/images/icons.svg#icon-arrow-left" /></svg>'
  2849. equal(App.Utils.icon('arrow-{start}'), svgTag, 'for ltr locale / name includes "{start}"')
  2850. svgTag = '<svg class="icon icon-arrow-right "><use xlink:href="assets/images/icons.svg#icon-arrow-right" /></svg>'
  2851. equal(App.Utils.icon('arrow-{end}'), svgTag, 'for ltr locale / name includes "{end}"')
  2852. // For a right-to-left browser language and when given an argument containing '{start}' or '{end}',
  2853. // expect @icon(name) to return an <svg> tag
  2854. // replacing '{start}' with 'left' and '{end}' with 'right'
  2855. window.svgPolyFill = false
  2856. App.i18n.dir = function() { return 'rtl' }
  2857. svgTag = '<svg class="icon icon-arrow-right "><use xlink:href="assets/images/icons.svg#icon-arrow-right" /></svg>'
  2858. equal(App.Utils.icon('arrow-{start}'), svgTag, 'for rtl locale / name includes "{start}"')
  2859. svgTag = '<svg class="icon icon-arrow-left "><use xlink:href="assets/images/icons.svg#icon-arrow-left" /></svg>'
  2860. equal(App.Utils.icon('arrow-{end}'), svgTag, 'for rtl locale / name includes "{end}"')
  2861. });
  2862. var source1 = '<img src="/assets/images/avatar-bg.png">some test'
  2863. $('#image2data1').html(source1)
  2864. var htmlImage2DataUrlTest1 = function() {
  2865. test("htmlImage2DataUrl1 async", function() {
  2866. var result1 = App.Utils.htmlImage2DataUrl(source1)
  2867. ok(result1.match(/some test/), source1)
  2868. ok(!result1.match(/avatar-bg.png/), source1)
  2869. ok(result1.match(/^\<img src=\"data:image\/png;base64,/), source1)
  2870. });
  2871. }
  2872. $('#image2data1 img').one('load', htmlImage2DataUrlTest1)
  2873. var source2 = '<img src="/assets/images/chat-demo-avatar.png">some test'
  2874. $('#image2data2').html(source2)
  2875. var htmlImage2DataUrlTest2 = function(element) {
  2876. test("htmlImage2DataUrl2 async", function() {
  2877. ok(!element.html().match(/chat-demo-avatar/), source2)
  2878. ok(element.get(0).outerHTML.match(/^\<img src=\"data:image\/png;base64,/), source2)
  2879. });
  2880. }
  2881. App.Utils.htmlImage2DataUrlAsyncInline($('#image2data2'), htmlImage2DataUrlTest2)
  2882. }
  2883. test('App.Utils.baseUrl()', function() {
  2884. // When FQDN is undefined or null,
  2885. // expect @baseUrl() to return window.location.origin
  2886. App.Config.get = function(key) { return undefined }
  2887. equal(App.Utils.baseUrl(), window.location.origin, 'with undefined FQDN')
  2888. App.Config.get = function(key) { return null }
  2889. equal(App.Utils.baseUrl(), window.location.origin, 'with null FQDN')
  2890. // When FQDN is zammad.example.com,
  2891. // expect @baseUrl() to return window.location.origin
  2892. App.Config.get = function(key) {
  2893. if (key === 'fqdn') {
  2894. return 'zammad.example.com'
  2895. }
  2896. }
  2897. equal(App.Utils.baseUrl(), window.location.origin, 'with FQDN zammad.example.com')
  2898. // Otherwise,
  2899. // expect @baseUrl() to return FQDN with current HTTP(S) scheme
  2900. App.Config.get = function(key) {
  2901. if (key === 'fqdn') {
  2902. return 'foo.zammad.com'
  2903. } else if (key === 'http_type') {
  2904. return 'https'
  2905. }
  2906. }
  2907. equal(App.Utils.baseUrl(), 'https://foo.zammad.com', 'with any other FQDN (and https scheme)')
  2908. App.Config.get = function(key) {
  2909. if (key === 'fqdn') {
  2910. return 'bar.zammad.com'
  2911. } else if (key === 'http_type') {
  2912. return 'http'
  2913. }
  2914. }
  2915. equal(App.Utils.baseUrl(), 'http://bar.zammad.com', 'with any other FQDN (and http scheme)')
  2916. });
  2917. test('App.Utils.joinUrlComponents()', function() {
  2918. // When given a list of strings,
  2919. // expect @joinUrlComponents() to join them with slashes
  2920. equal(App.Utils.joinUrlComponents('foo', 'bar', 'baz'), 'foo/bar/baz', 'with a destructured list of strings')
  2921. // When given an array of strings,
  2922. // expect @joinUrlComponents() to join them with slashes
  2923. equal(App.Utils.joinUrlComponents(['foo', 'bar', 'baz']), 'foo/bar/baz', 'with an array of strings')
  2924. // When given a list of many types,
  2925. // expect @joinUrlComponents() to join their string representations with slashes
  2926. equal(App.Utils.joinUrlComponents(0, 1, 'two', true, false, { foo: 'bar' }), '0/1/two/true/false/[object Object]', 'with a list of many types')
  2927. // When given a list including null or undefined,
  2928. // expect @joinUrlComponents() to filter them out of the results before joining the rest with slashes
  2929. equal(App.Utils.joinUrlComponents('foo', undefined, 'bar', null, 'baz'), 'foo/bar/baz', 'with a list including null or undefined')
  2930. });
  2931. test('App.Utils.clipboardHtmlIsWithText()', function() {
  2932. // no content with text
  2933. equal(App.Utils.clipboardHtmlIsWithText('<div></div>'), false)
  2934. equal(App.Utils.clipboardHtmlIsWithText('<div> </div>'), false)
  2935. equal(App.Utils.clipboardHtmlIsWithText('<div><img src="test.jpg"/></div>'), false)
  2936. equal(App.Utils.clipboardHtmlIsWithText('<div><!-- some comment --></div>'), false)
  2937. equal(App.Utils.clipboardHtmlIsWithText('<div><!-- some comment --> </div>'), false)
  2938. equal(App.Utils.clipboardHtmlIsWithText("<div><!-- some comment --> \n </div>"), false)
  2939. // content with text
  2940. equal(App.Utils.clipboardHtmlIsWithText('test'), true)
  2941. equal(App.Utils.clipboardHtmlIsWithText('<div>test</div>'), true)
  2942. equal(App.Utils.clipboardHtmlIsWithText('<meta http-equiv="content-type" content="text/html; charset=utf-8">sometext'), true)
  2943. });
  2944. test('App.Utils.clipboardHtmlInsertPreperation()', function() {
  2945. equal(App.Utils.clipboardHtmlInsertPreperation('<div></div>', {}), '')
  2946. equal(App.Utils.clipboardHtmlInsertPreperation('<div> </div>', {}), ' ')
  2947. equal(App.Utils.clipboardHtmlInsertPreperation('<div><img src="test.jpg"/></div>', {}), '<img src="test.jpg">')
  2948. equal(App.Utils.clipboardHtmlInsertPreperation('<div><!-- some comment --></div>', {}), '')
  2949. equal(App.Utils.clipboardHtmlInsertPreperation('<div><!-- some comment --> </div>', {}), ' ')
  2950. equal(App.Utils.clipboardHtmlInsertPreperation("<div><!-- some comment --> \n </div>", {}), " \n ")
  2951. equal(App.Utils.clipboardHtmlInsertPreperation('test', {}), 'test')
  2952. equal(App.Utils.clipboardHtmlInsertPreperation('<div>test</div>', {}), 'test')
  2953. equal(App.Utils.clipboardHtmlInsertPreperation('<meta http-equiv="content-type" content="text/html; charset=utf-8">sometext', {}), '<div>sometext</div>')
  2954. equal(App.Utils.clipboardHtmlInsertPreperation('<div><b>test</b> 123</div>', { mode: 'textonly' }), 'test 123')
  2955. equal(App.Utils.clipboardHtmlInsertPreperation('<div><b>test</b><br> 123</div>', { mode: 'textonly' }), 'test 123')
  2956. equal(App.Utils.clipboardHtmlInsertPreperation('<div><b>test</b><br> 123</div>', { mode: 'textonly', multiline: true }), 'test<br> 123')
  2957. });
  2958. test('App.Utils.signatureIdentifyByHtmlHelper()', function() {
  2959. result = App.Utils.signatureIdentifyByHtmlHelper("&lt;script&gt;alert('fish2');&lt;/script&gt;<blockquote></blockquote>")
  2960. equal(result, "&lt;script&gt;alert('fish2');&lt;/script&gt;<span class=\"js-signatureMarker\"></span><blockquote></blockquote>", 'signatureIdentifyByHtmlHelper does not reactivate alert')
  2961. });