mirror of
https://github.com/moebooru/moebooru
synced 2025-08-29 13:07:41 +00:00
Javascript back utils/dom
This commit is contained in:
parent
a26a92c89d
commit
3c9aa7042e
@ -1,17 +1,26 @@
|
|||||||
export escapeHtml = (str) -> str.replace(/[&<>"']/g, (str) => ({
|
export function escapeHtml (str) {
|
||||||
'&': '&',
|
return str.replace(/[&<>"']/g, function (str) {
|
||||||
'<': '<',
|
return {
|
||||||
'>': '>',
|
'&': '&',
|
||||||
'"': '"',
|
'<': '<',
|
||||||
"'": ''',
|
'>': '>',
|
||||||
})[str])
|
'"': '"',
|
||||||
|
"'": '''
|
||||||
|
}[str];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export hideEl = (el) -> el.style.display = 'none'
|
export function hideEl (el) {
|
||||||
|
el.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
export showEl = (el) -> el.style.display = ''
|
export function showEl (el) {
|
||||||
|
el.style.display = '';
|
||||||
|
}
|
||||||
|
|
||||||
export stringToDom = (str) ->
|
export function stringToDom (str) {
|
||||||
container = document.createElement('div')
|
const container = document.createElement('div');
|
||||||
container.innerHTML = str
|
container.innerHTML = str;
|
||||||
|
|
||||||
container.firstChild
|
return container.firstChild;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user