summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-06-15 16:16:13 +0200
committerGitHub <noreply@github.com>2018-06-15 16:16:13 +0200
commitd82ef721611654aa3a3aab0ea3c8c85c7e0187d6 (patch)
tree2b75f2c5bad51beeec55f1da359a01abf1608048 /core/js
parenta0496b2a7802d7605063056999ab0f3d465957af (diff)
parent543188d0cb2f03e661ba937dcef5f56f739ea582 (diff)
downloadnextcloud-server-d82ef721611654aa3a3aab0ea3c8c85c7e0187d6.tar.gz
nextcloud-server-d82ef721611654aa3a3aab0ea3c8c85c7e0187d6.zip
Merge pull request #9197 from nextcloud/fix-avatar-center
Fix avatar generator centering
Diffstat (limited to 'core/js')
-rw-r--r--core/js/placeholder.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/core/js/placeholder.js b/core/js/placeholder.js
index a0dfe8491d4..81f0b12e61a 100644
--- a/core/js/placeholder.js
+++ b/core/js/placeholder.js
@@ -62,13 +62,16 @@
(function ($) {
String.prototype.toRgb = function() {
- var hash = this.toLowerCase().replace(/[^0-9a-f]+/g, '');
+ // Normalize hash
+ var hash = this.toLowerCase();
// Already a md5 hash?
- if( !hash.match(/^[0-9a-f]{32}$/g) ) {
+ if( hash.match(/^([0-9a-f]{4}-?){8}$/) === null ) {
hash = md5(hash);
}
+ hash = hash.replace(/[^0-9a-f]/g, '');
+
function Color(r,g,b) {
this.r = r;
this.g = g;
@@ -116,7 +119,7 @@
var result = Array();
// Splitting evenly the string
- for (var i in hash) {
+ for (var i=0; i<hash.length; i++) {
// chars in md5 goes up to f, hex:16
result.push(parseInt(hash.charAt(i), 16) % 16);
}