1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-30 04:58:40 +01:00

Merge pull request #311 from theli-ua/htmldecode

Add htmldecode function
This commit is contained in:
Dominik Schmidt 2015-08-12 00:29:50 +02:00
commit d9fb4b4a8b

View File

@ -109,6 +109,25 @@ Tomahawk.timestamp = function () {
return Math.round(new Date() / 1000);
};
Tomahawk.htmlDecode = (function() {
// this prevents any overhead from creating the object each time
var element = document.createElement('textarea');
function decodeHTMLEntities (str) {
if(str && typeof str === 'string') {
str = str.replace(/</g,"&lt;");
str = str.replace(/>/g,"&gt;");
element.innerHTML = str;
str = element.textContent;
element.textContent = '';
}
return str;
}
return decodeHTMLEntities;
})();
Tomahawk.dumpResult = function (result) {
var results = result.results,
i = 0;