tao-test/app/taoQtiItem/views/js/qtiXmlRenderer/renderers/Container.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-08-29 20:14:13 +02:00
define(['tpl!taoQtiItem/qtiXmlRenderer/tpl/container'], function(tpl){
var xhtmlEntities = function(html){
//@todo : check other names entities
return html.replace(/ /g, ' ');
};
var xhtmlEncode = function(encodedStr){
var returnValue = '';
if(encodedStr){
//<br...> are replaced by <br... />
returnValue = encodedStr;
returnValue = returnValue.replace(/<br([^>]*)?>/ig, '<br />');
returnValue = returnValue.replace(/<hr([^>]*)?>/ig, '<hr />');
//<img...> are replaced by <img... />
returnValue = returnValue.replace(/(<img([^>]*)?\s?[^\/]>)+/ig,
function($0, $1){
return $0.replace('>', ' />');
});
}
return returnValue;
};
return {
qtiClass : '_container',
template : tpl,
getData:function(container, data){
data.body = xhtmlEntities(data.body);
data.body = xhtmlEncode(data.body);
return data;
}
};
});