Added H5P.htmlspecialchars()

namespaces
Pål Jørgensen 2014-09-23 12:00:21 +02:00
parent 7cb2ebe17c
commit 212f8c6f0f
1 changed files with 7 additions and 0 deletions

View File

@ -975,6 +975,13 @@ H5P.setFinished = function (contentId, points, maxPoints) {
} }
}; };
/**
* Mimics how php's htmlspecialchars works (the way we use it)
*/
H5P.htmlspecialchars = function(string) {
return string.toString().replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/'/g, '&#039;').replace(/"/g, '&quot;');
};
// Add indexOf to browsers that lack them. (IEs) // Add indexOf to browsers that lack them. (IEs)
if (!Array.prototype.indexOf) { if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (needle) { Array.prototype.indexOf = function (needle) {