'use strict';
/**
 * @ngdoc filter
 * @name annotationAppApp.filter:reviewHtmlEntitiesReplacer.js
 * @function
 * @description
 * # reviewHtmlEntitiesReplacer.js
 * Filter in the annotationAppApp.
 */
const MODULE_NAME = 'app';
angular.module(MODULE_NAME).filter('reviewHtmlEntitiesReplacer', function() {
    function replaceHtmlEntitiesByString(str) {
        return $('<textarea />').html(str).text();
    }
    return function(review) {
        var html, pros, cons;
        html = review.review.html;
        pros = review.review.pros;
        cons = review.review.cons;
        if (html) {
            html = replaceHtmlEntitiesByString(html);
            review.review.html = html;
        }
        if (pros) {
        	pros = replaceHtmlEntitiesByString(pros);
            review.review.pros = pros;
        }
        if (cons) {
        	cons = replaceHtmlEntitiesByString(cons);
            review.review.cons = cons;
        }

        return review;
    };
});