From 99c1ee5f71901cbde83d625803d6f8eb943f8ad9 Mon Sep 17 00:00:00 2001 From: riccio82 Date: Mon, 10 Dec 2018 15:01:06 +0100 Subject: [PATCH] Fix check glossary with ph tags --- public/js/cat_source/qa_check_glossary.js | 27 +++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/public/js/cat_source/qa_check_glossary.js b/public/js/cat_source/qa_check_glossary.js index c9f995f67c..de5717a104 100644 --- a/public/js/cat_source/qa_check_glossary.js +++ b/public/js/cat_source/qa_check_glossary.js @@ -95,6 +95,13 @@ if ( QaCheckGlossary.enabled() ) } container.find('.inside-attribute').remove(); var newHTML = htmlEncode(container.text()); + + //Replace ph tags + var base64Tags=[]; + newHTML = newHTML.replace( /<ph.*?equiv-text="base64:(.*?)".*?\/>/gi, function (match, text) { + base64Tags.push(match); + return "###" + text +"###"; + }); unusedMatches = unusedMatches.sort(function(a, b){ return b.raw_segment.length - a.raw_segment.length; }); @@ -103,7 +110,7 @@ if ( QaCheckGlossary.enabled() ) value = escapeRegExp( value ); value = value.replace(/ /g, '(?: *<\/*(?:mark)*(?:span *)*(?: (data-id="(.*?)" )*class="(unusedGlossaryTerm)*(inGlossary)*")*> *)* *'); var re = new RegExp( sprintf( matchRegExp, value ), QaCheckGlossary.qaCheckRegExpFlags); - //Check if value match inside the span (Ex: ID, class, data, span) + var check = re.test( '$1' ); if ( !check ){ newHTML = newHTML.replace( @@ -116,12 +123,18 @@ if ( QaCheckGlossary.enabled() ) ); } }); - (function (cont, html, matches) { - setTimeout(function ( ) { - SegmentActions.replaceSourceText(UI.getSegmentId(cont), UI.getSegmentFileId(cont), UI.transformTextForLockTags(html)); - bindEvents( cont, matches ); - }, 200); - })(segment.el, newHTML, unusedMatches); + newHTML = newHTML.replace( /###(.*?)###/gi, function (match, text) { + var tag = base64Tags.shift(); + return tag; + }); + if ( newHTML.indexOf('unusedGlossaryTerm') > -1 ) { + (function (cont, html, matches) { + setTimeout(function ( ) { + SegmentActions.replaceSourceText(UI.getSegmentId(cont), UI.getSegmentFileId(cont), UI.transformTextForLockTags(html)); + bindEvents( cont, matches ); + }, 200); + })(segment.el, newHTML, unusedMatches); + } }