1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-04 10:19:24 +02:00

add nl2br JS function

This commit is contained in:
daniel 2018-10-27 10:24:13 -03:00
parent e4d489b9b9
commit ab203eabb8

View file

@ -372,4 +372,12 @@ function copyToClipboard(text) {
$('#elementToCopy').focus();
$('#elementToCopy').select();
document.execCommand('copy');
}
function nl2br (str, is_xhtml) {
if (typeof str === 'undefined' || str === null) {
return '';
}
var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
}