diff options
author | =Corey Hulen <corey@hulen.com> | 2015-07-15 10:22:05 -0800 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-07-15 10:22:05 -0800 |
commit | e017babc5ddd66e65469326bf723d5359875c2d1 (patch) | |
tree | 0da7ee5d9f4039eeb20f70940483c40943c9aa23 /web/react/utils/utils.jsx | |
parent | 252d0f3924dd19aa4dd1900c6c00c41c84755d1e (diff) | |
parent | 38f9e140e98123eb256968fb31f7fbb2aef978e0 (diff) | |
download | chat-e017babc5ddd66e65469326bf723d5359875c2d1.tar.gz chat-e017babc5ddd66e65469326bf723d5359875c2d1.tar.bz2 chat-e017babc5ddd66e65469326bf723d5359875c2d1.zip |
fixing merge
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 5ded0e76f..19c074606 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -225,7 +225,7 @@ module.exports.extractLinks = function(text) { } return { "links": links, "text": text }; -} +} module.exports.escapeRegExp = function(string) { return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); @@ -671,13 +671,13 @@ module.exports.isValidUsername = function (name) { error = "First character must be a letter."; } - else + else { var lowerName = name.toLowerCase().trim(); - for (var i = 0; i < Constants.RESERVED_USERNAMES.length; i++) + for (var i = 0; i < Constants.RESERVED_USERNAMES.length; i++) { - if (lowerName === Constants.RESERVED_USERNAMES[i]) + if (lowerName === Constants.RESERVED_USERNAMES[i]) { error = "Cannot use a reserved word as a username."; break; @@ -782,3 +782,34 @@ module.exports.getHomeLink = function() { parts[0] = "www"; return window.location.protocol + "//" + parts.join("."); } + + +module.exports.changeColor =function(col, amt) { + + var usePound = false; + + if (col[0] == "#") { + col = col.slice(1); + usePound = true; + } + + var num = parseInt(col,16); + + var r = (num >> 16) + amt; + + if (r > 255) r = 255; + else if (r < 0) r = 0; + + var b = ((num >> 8) & 0x00FF) + amt; + + if (b > 255) b = 255; + else if (b < 0) b = 0; + + var g = (num & 0x0000FF) + amt; + + if (g > 255) g = 255; + else if (g < 0) g = 0; + + return (usePound?"#":"") + String("000000" + (g | (b << 8) | (r << 16)).toString(16)).slice(-6); + +}; |