diff options
author | Phie <phie@phie.ovh> | 2020-03-13 01:39:37 +0300 |
---|---|---|
committer | Phie <phie@phie.ovh> | 2020-03-13 01:39:37 +0300 |
commit | bedd7e17ab99789c793be0e6de507de90132ce61 (patch) | |
tree | 81311122fdc47ab51888f9e2c0db00f74cf78c11 /utils | |
parent | 924016a2efd47070bec3fa6771445dcb72f348c8 (diff) |
new design by Xananax
Diffstat (limited to 'utils')
-rw-r--r-- | utils/utils.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/utils/utils.js b/utils/utils.js index 2898937..d0e4f72 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -76,6 +76,15 @@ Utils.srt = function (desc) { return desc ? ~~(a < b) : ~~(a > b); } } + +Utils.nl2br = function (str, is_xhtml) { + //https://stackoverflow.com/questions/7467840/nl2br-equivalent-in-javascript + 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'); +} Utils.applyCss = function (url, onloaded) { //content is for nextcloud.. var head = (document.getElementById("content") != undefined) ? document.getElementById("content") : document.getElementsByTagName('head')[0]; |