This commit is contained in:
noface 2013-08-22 23:09:15 +02:00
parent 132d94d441
commit 01146f85c5
5 changed files with 53 additions and 0 deletions

View File

@ -1,3 +1,5 @@
- **New feature**: `Color user IDs`, enabled by default
## 3.10.0 - *2013-08-22* ## 3.10.0 - *2013-08-22*
- **New feature**: `Linkify` and `Clean Links`, enabled by default - **New feature**: `Linkify` and `Clean Links`, enabled by default

View File

@ -959,3 +959,12 @@ a.hide-announcement {
.entry input { .entry input {
margin: 0; margin: 0;
} }
/* colored uid */
.posteruid.painted {
padding: 0 5px;
border-radius: 1em;
font-size: 0.8em;
cursor: pointer;
}

View File

@ -50,6 +50,7 @@ Config =
'Thread Excerpt': [true, 'Show an excerpt of the thread in the tab title.'] 'Thread Excerpt': [true, 'Show an excerpt of the thread in the tab title.']
'Thread Stats': [true, 'Display reply, image, and page count.'] 'Thread Stats': [true, 'Display reply, image, and page count.']
'Thread Watcher': [true, 'Bookmark threads.'] 'Thread Watcher': [true, 'Bookmark threads.']
'Color user IDs': [true, 'Assign unique colors to user IDs on boards that use them.']
'Posting': 'Posting':
'Quick Reply': [true, 'All-in-one form to reply, create threads, automate dumping and more.'] '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.'] 'Persistent QR': [false, 'The Quick reply won\'t disappear after posting.']

View File

@ -107,6 +107,7 @@ Main =
initFeature 'Mark OP Quotes', QuoteOP initFeature 'Mark OP Quotes', QuoteOP
initFeature 'Mark Cross-thread Quotes', QuoteCT initFeature 'Mark Cross-thread Quotes', QuoteCT
initFeature 'Anonymize', Anonymize initFeature 'Anonymize', Anonymize
initFeature 'Color user IDs', IDColor
initFeature 'Time Formatting', Time initFeature 'Time Formatting', Time
initFeature 'Relative Post Dates', RelativeDates initFeature 'Relative Post Dates', RelativeDates
initFeature 'File Info Formatting', FileInfo initFeature 'File Info Formatting', FileInfo

View 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