Fix ID colors on Tinyboard/vichan sites. #2355
This commit is contained in:
parent
667495e641
commit
c28532f6f4
@ -23,13 +23,13 @@ IDColor =
|
|||||||
compute: (uid) ->
|
compute: (uid) ->
|
||||||
# Convert chars to integers, bitshift and math to create a larger integer
|
# Convert chars to integers, bitshift and math to create a larger integer
|
||||||
# Create a nice string of binary
|
# 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.
|
# Convert binary string to numerical values with bitshift and '&' truncation.
|
||||||
rgb = [
|
rgb = [
|
||||||
(hash >> 24) & 0xFF
|
|
||||||
(hash >> 16) & 0xFF
|
(hash >> 16) & 0xFF
|
||||||
(hash >> 8) & 0xFF
|
(hash >> 8) & 0xFF
|
||||||
|
hash & 0xFF
|
||||||
]
|
]
|
||||||
|
|
||||||
# Weight color luminance values, assign a font color that should be readable.
|
# Weight color luminance values, assign a font color that should be readable.
|
||||||
@ -40,10 +40,3 @@ IDColor =
|
|||||||
|
|
||||||
# Cache.
|
# Cache.
|
||||||
@ids[uid] = rgb
|
@ids[uid] = rgb
|
||||||
|
|
||||||
hash: (uid) ->
|
|
||||||
msg = 0
|
|
||||||
i = 0
|
|
||||||
while i < 8
|
|
||||||
msg = (msg << 5) - msg + uid.charCodeAt i++
|
|
||||||
msg
|
|
||||||
|
|||||||
@ -158,3 +158,10 @@ SW.yotsuba =
|
|||||||
|
|
||||||
sfwBoards: (sfw) ->
|
sfwBoards: (sfw) ->
|
||||||
BoardConfig.sfwBoards(sfw)
|
BoardConfig.sfwBoards(sfw)
|
||||||
|
|
||||||
|
uidColor: (uid) ->
|
||||||
|
msg = 0
|
||||||
|
i = 0
|
||||||
|
while i < 8
|
||||||
|
msg = (msg << 5) - msg + uid.charCodeAt i++
|
||||||
|
(msg >> 8) & 0xFFFFFF
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user