diff options
author | =Corey Hulen <corey@hulen.com> | 2016-01-22 16:31:58 -0600 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2016-01-22 16:31:58 -0600 |
commit | c2d98c2c1f4860c11aedf43aff5e360256a89835 (patch) | |
tree | 4304f7584025477d74e5e70677c4f5a70c26bb58 /web/react/utils/utils.jsx | |
parent | 6e2c1b7fd5248c6a4a91edcd59fa124c8d3c744a (diff) | |
parent | d352c5b64dddfb8e46b18edbd7352c41495078a1 (diff) | |
download | chat-c2d98c2c1f4860c11aedf43aff5e360256a89835.tar.gz chat-c2d98c2c1f4860c11aedf43aff5e360256a89835.tar.bz2 chat-c2d98c2c1f4860c11aedf43aff5e360256a89835.zip |
merging
Diffstat (limited to 'web/react/utils/utils.jsx')
-rw-r--r-- | web/react/utils/utils.jsx | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 24042321f..82e9bc447 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -879,8 +879,8 @@ export function isValidUsername(name) { var error = ''; if (!name) { error = 'This field is required'; - } else if (name.length < 3 || name.length > 15) { - error = 'Must be between 3 and 15 characters'; + } else if (name.length < Constants.MIN_USERNAME_LENGTH || name.length > Constants.MAX_USERNAME_LENGTH) { + error = 'Must be between ' + Constants.MIN_USERNAME_LENGTH + ' and ' + Constants.MAX_USERNAME_LENGTH + ' characters'; } else if (!(/^[a-z0-9\.\-\_]+$/).test(name)) { error = "Must contain only letters, numbers, and the symbols '.', '-', and '_'."; } else if (!(/[a-z]/).test(name.charAt(0))) { //eslint-disable-line no-negated-condition @@ -1091,8 +1091,9 @@ export function fileSizeToString(bytes) { } // Converts a filename (like those attached to Post objects) to a url that can be used to retrieve attachments from the server. -export function getFileUrl(filename) { - return getWindowLocationOrigin() + '/api/v1/files/get' + filename + '?' + getSessionIndex(); +export function getFileUrl(filename, isDownload) { + const downloadParam = isDownload ? '&download=1' : ''; + return getWindowLocationOrigin() + '/api/v1/files/get' + filename + '?' + getSessionIndex() + downloadParam; } // Gets the name of a file (including extension) from a given url or file path. @@ -1101,6 +1102,17 @@ export function getFileName(path) { return split[split.length - 1]; } +// Gets the websocket port to use. Configurable on the server. +export function getWebsocketPort(protocol) { + if ((/^wss:/).test(protocol)) { // wss:// + return ':' + global.window.mm_config.WebsocketSecurePort; + } + if ((/^ws:/).test(protocol)) { + return ':' + global.window.mm_config.WebsocketPort; + } + return ''; +} + export function getSessionIndex() { if (global.window.mm_session_token_index >= 0) { return 'session_token_index=' + global.window.mm_session_token_index; @@ -1309,6 +1321,10 @@ export function fillArray(value, length) { // Checks if a data transfer contains files not text, folders, etc.. // Slightly modified from http://stackoverflow.com/questions/6848043/how-do-i-detect-a-file-is-being-dragged-rather-than-a-draggable-element-on-my-pa export function isFileTransfer(files) { + if (isBrowserIE()) { + return files.types != null && files.types.contains('Files'); + } + return files.types != null && (files.types.indexOf ? files.types.indexOf('Files') !== -1 : files.types.contains('application/x-moz-file')); } @@ -1324,3 +1340,18 @@ export function clearFileInput(elm) { // Do nothing } } + +export function languages() { + return ( + [ + { + value: 'en', + name: 'English' + }, + { + value: 'es', + name: 'EspaƱol' + } + ] + ); +} |