diff --git a/src/Miscellaneous/IDColor.coffee b/src/Miscellaneous/IDColor.coffee index 5fe4d804b..fa6e15c78 100644 --- a/src/Miscellaneous/IDColor.coffee +++ b/src/Miscellaneous/IDColor.coffee @@ -23,13 +23,13 @@ IDColor = compute: (uid) -> # Convert chars to integers, bitshift and math to create a larger integer # Create a nice string of binary - hash = IDColor.hash uid + hash = if Site.uidColor then Site.uidColor(uid) else parseInt(uid, 16) # Convert binary string to numerical values with bitshift and '&' truncation. rgb = [ - (hash >> 24) & 0xFF (hash >> 16) & 0xFF (hash >> 8) & 0xFF + hash & 0xFF ] # Weight color luminance values, assign a font color that should be readable. @@ -40,10 +40,3 @@ IDColor = # Cache. @ids[uid] = rgb - - hash: (uid) -> - msg = 0 - i = 0 - while i < 8 - msg = (msg << 5) - msg + uid.charCodeAt i++ - msg diff --git a/src/site/SW.yotsuba.coffee b/src/site/SW.yotsuba.coffee index 5b6d16d04..5a924ade4 100644 --- a/src/site/SW.yotsuba.coffee +++ b/src/site/SW.yotsuba.coffee @@ -158,3 +158,10 @@ SW.yotsuba = sfwBoards: (sfw) -> BoardConfig.sfwBoards(sfw) + + uidColor: (uid) -> + msg = 0 + i = 0 + while i < 8 + msg = (msg << 5) - msg + uid.charCodeAt i++ + (msg >> 8) & 0xFFFFFF