summaryrefslogtreecommitdiffstats
path: root/webapp/utils/utils.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/utils/utils.jsx')
-rw-r--r--webapp/utils/utils.jsx50
1 files changed, 11 insertions, 39 deletions
diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx
index 2f728226c..978f231df 100644
--- a/webapp/utils/utils.jsx
+++ b/webapp/utils/utils.jsx
@@ -34,38 +34,6 @@ export function cleanUpUrlable(input) {
return cleaned;
}
-export function isTestDomain() {
- if ((/^localhost/).test(window.location.hostname)) {
- return true;
- }
-
- if ((/^dockerhost/).test(window.location.hostname)) {
- return true;
- }
-
- if ((/^test/).test(window.location.hostname)) {
- return true;
- }
-
- if ((/^127.0./).test(window.location.hostname)) {
- return true;
- }
-
- if ((/^192.168./).test(window.location.hostname)) {
- return true;
- }
-
- if ((/^10./).test(window.location.hostname)) {
- return true;
- }
-
- if ((/^176./).test(window.location.hostname)) {
- return true;
- }
-
- return false;
-}
-
export function isChrome() {
if (navigator.userAgent.indexOf('Chrome') > -1) {
return true;
@@ -457,7 +425,7 @@ export function replaceHtmlEntities(text) {
};
var newtext = text;
for (var tag in tagsToReplace) {
- if ({}.hasOwnProperty.call(tagsToReplace, tag)) {
+ if (Reflect.apply({}.hasOwnProperty, this, [tagsToReplace, tag])) {
var regex = new RegExp(tag, 'g');
newtext = newtext.replace(regex, tagsToReplace[tag]);
}
@@ -473,7 +441,7 @@ export function insertHtmlEntities(text) {
};
var newtext = text;
for (var tag in tagsToReplace) {
- if ({}.hasOwnProperty.call(tagsToReplace, tag)) {
+ if (Reflect.apply({}.hasOwnProperty, this, [tagsToReplace, tag])) {
var regex = new RegExp(tag, 'g');
newtext = newtext.replace(regex, tagsToReplace[tag]);
}
@@ -682,7 +650,7 @@ export function applyTheme(theme) {
changeCss('.app__body .post-list__arrows', 'fill:' + changeOpacity(theme.centerChannelColor, 0.3), 1);
changeCss('.app__body .sidebar--left, .app__body .sidebar--right .sidebar--right__header, .app__body .suggestion-list__content .command', 'border-color:' + changeOpacity(theme.centerChannelColor, 0.2), 1);
changeCss('.app__body .app__content, .app__body .post-create__container .post-create-body .btn-file, .app__body .post-create__container .post-create-footer .msg-typing, .app__body .suggestion-list__content .command, .app__body .modal .modal-content, .app__body .dropdown-menu, .app__body .popover, .app__body .mentions__name, .app__body .tip-overlay', 'color:' + theme.centerChannelColor, 1);
- changeCss('.app__body #archive-link-home', 'background:' + changeOpacity(theme.centerChannelColor, 0.15), 1);
+ changeCss('.app__body #archive-link-home, .video-div .video-thumbnail__error', 'background:' + changeOpacity(theme.centerChannelColor, 0.15), 1);
changeCss('.app__body #post-create', 'color:' + theme.centerChannelColor, 2);
changeCss('.app__body .mentions--top, .app__body .suggestion-list', 'box-shadow:' + changeOpacity(theme.centerChannelColor, 0.2) + ' 1px -3px 12px', 3);
changeCss('.app__body .mentions--top, .app__body .suggestion-list', '-webkit-box-shadow:' + changeOpacity(theme.centerChannelColor, 0.2) + ' 1px -3px 12px', 2);
@@ -734,7 +702,7 @@ export function applyTheme(theme) {
changeCss('.app__body .scrollbar--horizontal, .app__body .scrollbar--vertical', 'background:' + changeOpacity(theme.centerChannelColor, 0.5), 2);
changeCss('.app__body .post-list__new-messages-below', 'background:' + changeColor(theme.centerChannelColor, 0.5), 2);
changeCss('.app__body .post.post--comment .post__body', 'border-color:' + changeOpacity(theme.centerChannelColor, 0.2), 1);
- changeCss('.app__body .post.post--comment.current--user .post__body', 'border-color:' + changeOpacity(theme.centerChannelColor, 0.13), 1);
+ changeCss('.app__body .post.post--comment.current--user .post__body', 'border-color:' + changeOpacity(theme.centerChannelColor, 0.2), 1);
}
if (theme.newMessageSeparator) {
@@ -924,7 +892,7 @@ export function isValidUsername(name) {
error = 'This field is required';
} 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)) {
+ } 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
error = 'First character must be a letter.';
@@ -977,7 +945,7 @@ Image.prototype.load = function imageLoad(url, progressCallback) {
xmlHTTP.responseType = 'arraybuffer';
xmlHTTP.onload = function onLoad() {
var h = xmlHTTP.getAllResponseHeaders();
- var m = h.match(/^Content-Type\:\s*(.*?)$/mi);
+ var m = h.match(/^Content-Type:\s*(.*?)$/mi);
var mimeType = m[1] || 'image/png';
var blob = new Blob([this.response], {type: mimeType});
@@ -1142,7 +1110,7 @@ export function generateId() {
// implementation taken from http://stackoverflow.com/a/2117523
var id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
- id = id.replace(/[xy]/g, function replaceRandom(c) {
+ id = id.replace(/[xy]/g, (c) => {
var r = Math.floor(Math.random() * 16);
var v;
@@ -1408,6 +1376,10 @@ export function localizeMessage(id, defaultMessage) {
return id;
}
+export function mod(a, b) {
+ return ((a % b) + b) % b;
+}
+
export function getProfilePicSrcForPost(post, timestamp) {
let src = Client.getUsersRoute() + '/' + post.user_id + '/image?time=' + timestamp;
if (post.props && post.props.from_webhook && global.window.mm_config.EnablePostIconOverride === 'true') {