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:
parent
e4d489b9b9
commit
ab203eabb8
1 changed files with 8 additions and 0 deletions
|
@ -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');
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue