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:
commit
d9fb4b4a8b
@ -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,"<");
|
||||
str = str.replace(/>/g,">");
|
||||
element.innerHTML = str;
|
||||
str = element.textContent;
|
||||
element.textContent = '';
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
return decodeHTMLEntities;
|
||||
})();
|
||||
|
||||
Tomahawk.dumpResult = function (result) {
|
||||
var results = result.results,
|
||||
i = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user