forked from 0x2620/oxjs
updates for html parsing, request handling, and editable elements
This commit is contained in:
parent
a949ad2cf4
commit
62f8a907ea
6 changed files with 153 additions and 69 deletions
|
|
@ -288,11 +288,31 @@
|
|||
'äbçdê'
|
||||
> Ox.decodeHTML('äbçdê')
|
||||
'äbçdê'
|
||||
> Ox.decodeHTML('<b>bold</b>')
|
||||
'<b>bold</b>'
|
||||
@*/
|
||||
Ox.decodeHTML = function(str) {
|
||||
// relies on dom, but shorter than using this:
|
||||
// http://www.w3.org/TR/html5/named-character-references.html
|
||||
return Ox.element('<div>').html(str)[0].childNodes[0].nodeValue;
|
||||
return Ox.decodeHTMLEntities(Ox.element('<div>').html(str).html());
|
||||
};
|
||||
|
||||
Ox.encodeHTMLEntities = function(str) {
|
||||
return str.replace(
|
||||
new RegExp('(' + Object.keys(Ox.HTML_ENTITIES).join('|') + ')', 'g'),
|
||||
function(match) {
|
||||
return Ox.HTML_ENTITIES[match];
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
Ox.decodeHTMLEntities = function(str) {
|
||||
return str.replace(
|
||||
new RegExp('(' + Ox.values(Ox.HTML_ENTITIES).join('|') + ')', 'g'),
|
||||
function(match) {
|
||||
return Ox.keyOf(Ox.HTML_ENTITIES, match);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/*@
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue