The Thread Updater now updates the sticky/closed icons.

It will also open notifications when these change. Close #934.
This commit is contained in:
Nicolas Stepien 2013-02-23 00:49:44 +01:00
parent 02fc7fecb3
commit 9725a26807
3 changed files with 58 additions and 0 deletions

View File

@ -5316,9 +5316,37 @@
}
});
},
updateThreadStatus: function(title, OP) {
var icon, message, root, titleLC;
titleLC = title.toLowerCase();
if (ThreadUpdater.thread["is" + title] === !!OP[titleLC]) {
return;
}
if (!(ThreadUpdater.thread["is" + title] = !!OP[titleLC])) {
message = title === 'Sticky' ? 'The thread is not a sticky anymore.' : 'The thread is not closed anymore.';
new Notification('info', message, 30);
$.rm($("." + titleLC + "Icon", ThreadUpdater.thread.OP.nodes.info));
return;
}
message = title === 'Sticky' ? 'The thread is now a sticky.' : 'The thread is now closed.';
new Notification('info', message, 30);
icon = $.el('img', {
src: "//static.4chan.org/image/" + titleLC + ".gif",
alt: title,
title: title,
className: "" + titleLC + "Icon"
});
root = $('[title="Quote this post"]', ThreadUpdater.thread.OP.nodes.info);
if (title === 'Closed') {
root = $('.stickyIcon', ThreadUpdater.thread.OP.nodes.info) || root;
}
return $.after(root, [$.tn(' '), icon]);
},
parse: function(postObjects) {
var ID, count, deletedFiles, deletedPosts, files, index, node, nodes, num, post, postObject, posts, scroll, _i, _len, _ref;
Build.spoilerRange[ThreadUpdater.thread.board] = postObjects[0].custom_spoiler;
ThreadUpdater.updateThreadStatus('Sticky', postObjects[0]);
ThreadUpdater.updateThreadStatus('Closed', postObjects[0]);
nodes = [];
posts = [];
index = [];

View File

@ -20,6 +20,7 @@ beta
There is now a setting to allow expanding spoilers.
Thread Updater changes:
The Thread Updater will now notify of sticky/closed status change and update the icons.
The Thread Updater will pause when offline, and resume when online.
Added an option to always auto-scroll to the bottom.

View File

@ -3599,9 +3599,38 @@ ThreadUpdater =
ThreadUpdater.req = $.ajax url, onloadend: ThreadUpdater.cb.load,
headers: 'If-Modified-Since': ThreadUpdater.lastModified
updateThreadStatus: (title, OP) ->
titleLC = title.toLowerCase()
return if ThreadUpdater.thread["is#{title}"] is !!OP[titleLC]
unless ThreadUpdater.thread["is#{title}"] = !!OP[titleLC]
message = if title is 'Sticky'
'The thread is not a sticky anymore.'
else
'The thread is not closed anymore.'
new Notification 'info', message, 30
$.rm $ ".#{titleLC}Icon", ThreadUpdater.thread.OP.nodes.info
return
message = if title is 'Sticky'
'The thread is now a sticky.'
else
'The thread is now closed.'
new Notification 'info', message, 30
icon = $.el 'img',
src: "//static.4chan.org/image/#{titleLC}.gif"
alt: title
title: title
className: "#{titleLC}Icon"
root = $ '[title="Quote this post"]', ThreadUpdater.thread.OP.nodes.info
if title is 'Closed'
root = $('.stickyIcon', ThreadUpdater.thread.OP.nodes.info) or root
$.after root, [$.tn(' '), icon]
parse: (postObjects) ->
Build.spoilerRange[ThreadUpdater.thread.board] = postObjects[0].custom_spoiler
ThreadUpdater.updateThreadStatus 'Sticky', postObjects[0]
ThreadUpdater.updateThreadStatus 'Closed', postObjects[0]
nodes = [] # post container elements
posts = [] # post objects
index = [] # existing posts