Highlight watched threads with unread posts quoting you.

This commit is contained in:
ccd0 2014-10-16 20:29:58 -07:00
parent f7a4197891
commit a0e9c832fb
7 changed files with 52 additions and 8 deletions

View File

@ -66,6 +66,11 @@
background: rgba(255, 255, 255, .33);
}
/* Thread Watcher */
:root.burichan .unread-quoting-you > a {
color: #F00;
}
/* Watcher Favicon */
:root.burichan .watch-thread-link
{

View File

@ -66,6 +66,11 @@
background: rgba(255, 255, 255, .33);
}
/* Thread Watcher */
:root.futaba .unread-quoting-you > a {
color: #F00;
}
/* Watcher Favicon */
:root.futaba .watch-thread-link
{

View File

@ -66,6 +66,11 @@
background: rgba(255, 255, 255, .33);
}
/* Thread Watcher */
:root.photon .unread-quoting-you > a {
color: #00F !important;
}
/* Watcher Favicon */
:root.photon .watch-thread-link
{

View File

@ -72,6 +72,11 @@
background: rgba(0, 0, 0, .33);
}
/* Thread Watcher */
:root.tomorrow .unread-quoting-you > a {
color: #F00 !important;
}
/* Watcher Favicon */
:root.tomorrow .watch-thread-link
{

View File

@ -67,6 +67,11 @@
background: rgba(255, 255, 255, .33);
}
/* Thread Watcher */
:root.yotsuba-b .unread-quoting-you > a {
color: #F00;
}
/* Watcher Favicon */
:root.yotsuba-b .watch-thread-link
{

View File

@ -66,6 +66,11 @@
background: rgba(255, 255, 255, .33);
}
/* Thread Watcher */
:root.yotsuba .unread-quoting-you > a {
color: #F00;
}
/* Watcher Favicon */
:root.yotsuba .watch-thread-link
{

View File

@ -149,15 +149,27 @@ ThreadWatcher =
threadID: threadID
defaultValue: 0
unread = 0
unread = unreadQY = 0
for postObj in @response.posts[1..]
if postObj.no > lastReadPost and !QR.db?.get {boardID, threadID, postID: postObj.no}
unread++
continue unless postObj.no > lastReadPost
continue if QR.db?.get {boardID, threadID, postID: postObj.no}
unread++
continue unless QR.db and postObj.com
regexp = /<a [^>]*\bhref="(?:\/([^\/]+)\/thread\/(\d+))?(?:#p(\d+))?"/g
while match = regexp.exec postObj.com
if QR.db.get {
boardID: match[1] or boardID
threadID: match[2] or threadID
postID: match[3] or match[2] or threadID
}
unreadQY++
continue
if isDead isnt data.isDead or unread isnt data.unread
data.isDead = isDead
data.unread = unread
if isDead isnt data.isDead or unread isnt data.unread or unreadQY isnt data.unreadQY
data.isDead = isDead
data.unread = unread
data.unreadQY = unreadQY
ThreadWatcher.db.set {boardID, threadID, val: data}
ThreadWatcher.refresh()
@ -167,6 +179,7 @@ ThreadWatcher =
else
data.isDead = true
delete data.unread
delete data.unreadQY
ThreadWatcher.db.set {boardID, threadID, val: data}
ThreadWatcher.refresh()
@ -202,8 +215,9 @@ ThreadWatcher =
div = $.el 'div'
fullID = "#{boardID}.#{threadID}"
div.dataset.fullID = fullID
$.addClass div, 'current' if g.VIEW is 'thread' and fullID is "#{g.BOARD}.#{g.THREADID}"
$.addClass div, 'dead-thread' if data.isDead
$.addClass div, 'current' if g.VIEW is 'thread' and fullID is "#{g.BOARD}.#{g.THREADID}"
$.addClass div, 'unread-quoting-you' if data.unreadQY
$.addClass div, 'dead-thread' if data.isDead
$.add div, [x, $.tn(' '), link]
div
refresh: ->