Skip to content

Commit

Permalink
Fix check glossary with ph tags
Browse files Browse the repository at this point in the history
  • Loading branch information
riccio82 committed Dec 10, 2018
1 parent d49f065 commit 99c1ee5
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions public/js/cat_source/qa_check_glossary.js
Expand Up @@ -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;
});
Expand All @@ -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( '<span class="unusedGlossaryTerm">$1</span>' );
if ( !check ){
newHTML = newHTML.replace(
Expand All @@ -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);
}


}
Expand Down

0 comments on commit 99c1ee5

Please sign in to comment.