diff options
author | Corey Hulen <corey@hulen.com> | 2015-08-30 20:58:00 -0700 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-08-30 20:58:00 -0700 |
commit | 07bdbf21f5dd14ecab85f1cfdced701a5e981d2f (patch) | |
tree | b169f94ae813d5ac111bacf290a36da5e76b09ec /web/react/utils/utils.jsx | |
parent | 9ed32b2128c26db1417b6e2b6d03337f8fb373a4 (diff) | |
parent | 023b286930d16fe94c0c77295c09f51910a74fcc (diff) | |
download | chat-07bdbf21f5dd14ecab85f1cfdced701a5e981d2f.tar.gz chat-07bdbf21f5dd14ecab85f1cfdced701a5e981d2f.tar.bz2 chat-07bdbf21f5dd14ecab85f1cfdced701a5e981d2f.zip |
Merge pull request #519 from rgarmsen2295/fix-slow-type
[Performance Fix] Removes warning message when at the max character limit
Diffstat (limited to 'web/react/utils/utils.jsx')
-rw-r--r-- | web/react/utils/utils.jsx | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 34a0d55da..5266b1381 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -1001,43 +1001,6 @@ module.exports.isBrowserEdge = function() { return window.naviagtor && navigator.userAgent && navigator.userAgent.toLowerCase().indexOf('edge') > -1; }; -// Gets text length consistent with maxlength property of textarea html tag -module.exports.getLengthOfTextInTextarea = function(messageText) { - // Need to get length with carriage returns counting as two characters to match textbox maxlength behavior - // unless ie10/ie11/edge which already do - - var len = messageText.length; - if (!module.exports.isBrowserIE() && !module.exports.isBrowserEdge()) { - len = messageText.replace(/\r(?!\n)|\n(?!\r)/g, '--').length; - } - - return len; -}; - -module.exports.checkMessageLengthError = function(message, currentError, newError) { - var updatedError = currentError; - var len = module.exports.getLengthOfTextInTextarea(message); - - if (!currentError && len >= Constants.MAX_POST_LEN) { - updatedError = newError; - } else if (currentError === newError && len < Constants.MAX_POST_LEN) { - updatedError = ''; - } - - return updatedError; -}; - -// Necessary due to issues with textarea max length and pasting newlines -module.exports.truncateText = function(message) { - var lengthDifference = module.exports.getLengthOfTextInTextarea(message) - message.length; - - if (lengthDifference > 0) { - return message.substring(0, Constants.MAX_POST_LEN - lengthDifference); - } - - return message.substring(0, Constants.MAX_POST_LEN); -}; - // Used to get the id of the other user from a DM channel module.exports.getUserIdFromChannelName = function(channel) { var ids = channel.name.split('__'); |