Close #1255.
This commit is contained in:
parent
132d94d441
commit
01146f85c5
@ -1,3 +1,5 @@
|
||||
- **New feature**: `Color user IDs`, enabled by default
|
||||
|
||||
## 3.10.0 - *2013-08-22*
|
||||
|
||||
- **New feature**: `Linkify` and `Clean Links`, enabled by default
|
||||
|
||||
@ -959,3 +959,12 @@ a.hide-announcement {
|
||||
.entry input {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* colored uid */
|
||||
|
||||
.posteruid.painted {
|
||||
padding: 0 5px;
|
||||
border-radius: 1em;
|
||||
font-size: 0.8em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@ -50,6 +50,7 @@ Config =
|
||||
'Thread Excerpt': [true, 'Show an excerpt of the thread in the tab title.']
|
||||
'Thread Stats': [true, 'Display reply, image, and page count.']
|
||||
'Thread Watcher': [true, 'Bookmark threads.']
|
||||
'Color user IDs': [true, 'Assign unique colors to user IDs on boards that use them.']
|
||||
'Posting':
|
||||
'Quick Reply': [true, 'All-in-one form to reply, create threads, automate dumping and more.']
|
||||
'Persistent QR': [false, 'The Quick reply won\'t disappear after posting.']
|
||||
|
||||
@ -107,6 +107,7 @@ Main =
|
||||
initFeature 'Mark OP Quotes', QuoteOP
|
||||
initFeature 'Mark Cross-thread Quotes', QuoteCT
|
||||
initFeature 'Anonymize', Anonymize
|
||||
initFeature 'Color user IDs', IDColor
|
||||
initFeature 'Time Formatting', Time
|
||||
initFeature 'Relative Post Dates', RelativeDates
|
||||
initFeature 'File Info Formatting', FileInfo
|
||||
|
||||
40
src/Miscellaneous/IDColor.coffee
Normal file
40
src/Miscellaneous/IDColor.coffee
Normal file
@ -0,0 +1,40 @@
|
||||
IDColor =
|
||||
init: ->
|
||||
return if g.VIEW is 'catalog' or !Conf['Color user IDs']
|
||||
@ids = {}
|
||||
|
||||
Post::callbacks.push
|
||||
name: 'Color user IDs'
|
||||
cb: @node
|
||||
|
||||
node: ->
|
||||
return if @isClone or !(uid = @info.uniqueID)
|
||||
rgb = IDColor.compute uid
|
||||
span = @nodes.uniqueID
|
||||
{style} = span
|
||||
style.color = rgb[3]
|
||||
style.backgroundColor = "rgb(#{rgb[0]},#{rgb[1]},#{rgb[2]})"
|
||||
$.addClass span, 'painted'
|
||||
span.textContent = uid
|
||||
span.title = 'Highlight posts by this ID'
|
||||
|
||||
compute: (uniqueID) ->
|
||||
if uniqueID of IDColor.ids
|
||||
return IDColor.ids[uniqueID]
|
||||
hash = @hash uniqueID
|
||||
rgb = [
|
||||
(hash >> 24) & 0xFF
|
||||
(hash >> 16) & 0xFF
|
||||
(hash >> 8) & 0xFF
|
||||
]
|
||||
rgb.push if (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 125
|
||||
'black'
|
||||
else
|
||||
'white'
|
||||
@ids[uniqueID] = rgb
|
||||
|
||||
hash: (uniqueID) ->
|
||||
msg = 0
|
||||
for i in [0...uniqueID.length]
|
||||
msg = (msg << 5) - msg + uniqueID.charCodeAt i
|
||||
msg
|
||||
Loading…
x
Reference in New Issue
Block a user