Get Auto Watch on Reply done. Refactor un/watch while I'm at it.
This commit is contained in:
parent
e26546df79
commit
ba8ae38d0a
@ -1539,7 +1539,7 @@
|
||||
return $.add(d.body, qr.el);
|
||||
},
|
||||
submit: function(e) {
|
||||
var captcha, captchas, challenge, err, file, m, now, post, reader, reply, response;
|
||||
var captcha, captchas, challenge, err, file, m, now, post, reader, reply, response, threadID;
|
||||
if (e != null) e.preventDefault();
|
||||
qr.message.send({
|
||||
abort: true
|
||||
@ -1571,13 +1571,17 @@
|
||||
return;
|
||||
}
|
||||
qr.cleanError();
|
||||
threadID = g.THREAD_ID || $('select', qr.el).value;
|
||||
if (conf['Auto Hide QR'] && qr.replies.length === 1) {
|
||||
$.id('autohide').checked = true;
|
||||
qr.hide();
|
||||
}
|
||||
if (conf['Thread Watcher'] && conf['Auto Watch Reply'] && threadID !== 'new') {
|
||||
watcher.watch(threadID);
|
||||
}
|
||||
post = {
|
||||
board: g.BOARD,
|
||||
resto: g.THREAD_ID || $('select', qr.el).value,
|
||||
resto: threadID,
|
||||
name: reply.name,
|
||||
email: reply.email,
|
||||
sub: reply.sub,
|
||||
@ -2218,13 +2222,6 @@
|
||||
$.before(input, favicon);
|
||||
}
|
||||
watcher.refresh();
|
||||
if (conf['Auto Watch']) {
|
||||
if (!g.REPLY) {
|
||||
$('.postarea form').action += '?watch';
|
||||
} else if (/watch/.test(location.search) && $('img.favicon').src === Favicon.empty) {
|
||||
watcher.watch(null, g.THREAD_ID);
|
||||
}
|
||||
}
|
||||
return $.on(window, 'storage', function(e) {
|
||||
if (e.key === ("" + NAMESPACE + "watched")) return watcher.refresh();
|
||||
});
|
||||
@ -2274,38 +2271,33 @@
|
||||
return watcher.toggle(this.parentNode);
|
||||
},
|
||||
x: function() {
|
||||
var board, id, _, _ref;
|
||||
_ref = this.nextElementSibling.getAttribute('href').slice(1).split('/'), board = _ref[0], _ = _ref[1], id = _ref[2];
|
||||
return watcher.unwatch(board, id);
|
||||
var thread;
|
||||
thread = this.nextElementSibling.pathname.split('/');
|
||||
return watcher.unwatch(thread[3], thread[1]);
|
||||
}
|
||||
},
|
||||
toggle: function(thread) {
|
||||
var favicon, id;
|
||||
favicon = $('img.favicon', thread);
|
||||
id = favicon.nextSibling.name;
|
||||
if (favicon.src === Favicon.empty) {
|
||||
return watcher.watch(thread, id);
|
||||
} else {
|
||||
return watcher.unwatch(g.BOARD, id);
|
||||
}
|
||||
var id;
|
||||
id = $('.op', thread).id;
|
||||
return watcher.watch(id) || watcher.unwatch(id, g.BOARD);
|
||||
},
|
||||
unwatch: function(board, id) {
|
||||
unwatch: function(id, board) {
|
||||
var watched;
|
||||
watched = $.get('watched', {});
|
||||
delete watched[board][id];
|
||||
$.set('watched', watched);
|
||||
return watcher.refresh();
|
||||
},
|
||||
watch: function(thread, id) {
|
||||
var props, text, watched, _name;
|
||||
text = getTitle(thread);
|
||||
props = {
|
||||
href: "/" + g.BOARD + "/res/" + id,
|
||||
textContent: text
|
||||
};
|
||||
watch: function(id) {
|
||||
var thread, watched, _name;
|
||||
thread = $.id(id);
|
||||
if ($('.favicon', thread).src === Favicon["default"]) return false;
|
||||
watched = $.get('watched', {});
|
||||
watched[_name = g.BOARD] || (watched[_name] = {});
|
||||
watched[g.BOARD][id] = props;
|
||||
watched[g.BOARD][id] = {
|
||||
href: "/" + g.BOARD + "/res/" + id,
|
||||
textContent: getTitle(thread)
|
||||
};
|
||||
$.set('watched', watched);
|
||||
return watcher.refresh();
|
||||
}
|
||||
|
||||
@ -1188,13 +1188,17 @@ qr =
|
||||
return
|
||||
qr.cleanError()
|
||||
|
||||
threadID = g.THREAD_ID or $('select', qr.el).value
|
||||
|
||||
if conf['Auto Hide QR'] and qr.replies.length is 1
|
||||
$.id('autohide').checked = true
|
||||
qr.hide()
|
||||
if conf['Thread Watcher'] and conf['Auto Watch Reply'] and threadID isnt 'new'
|
||||
watcher.watch threadID
|
||||
|
||||
post =
|
||||
board: g.BOARD
|
||||
resto: g.THREAD_ID or $('select', qr.el).value
|
||||
board: g.BOARD
|
||||
resto: threadID
|
||||
name: reply.name
|
||||
email: reply.email
|
||||
sub: reply.sub
|
||||
@ -1768,12 +1772,6 @@ watcher =
|
||||
#populate watcher, display watch buttons
|
||||
watcher.refresh()
|
||||
|
||||
if conf['Auto Watch']
|
||||
unless g.REPLY
|
||||
$('.postarea form').action += '?watch'
|
||||
else if /watch/.test(location.search) and $('img.favicon').src is Favicon.empty
|
||||
watcher.watch null, g.THREAD_ID
|
||||
|
||||
$.on window, 'storage', (e) -> watcher.refresh() if e.key is "#{NAMESPACE}watched"
|
||||
|
||||
refresh: ->
|
||||
@ -1808,33 +1806,28 @@ watcher =
|
||||
toggle: ->
|
||||
watcher.toggle @parentNode
|
||||
x: ->
|
||||
[board, _, id] = @nextElementSibling
|
||||
.getAttribute('href')[1..].split('/')
|
||||
watcher.unwatch board, id
|
||||
thread = @nextElementSibling.pathname.split '/'
|
||||
watcher.unwatch thread[3], thread[1]
|
||||
|
||||
toggle: (thread) ->
|
||||
favicon = $ 'img.favicon', thread
|
||||
id = favicon.nextSibling.name
|
||||
if favicon.src == Favicon.empty
|
||||
watcher.watch thread, id
|
||||
else # favicon.src == Favicon.default
|
||||
watcher.unwatch g.BOARD, id
|
||||
id = $('.op', thread).id
|
||||
watcher.watch(id) or watcher.unwatch id, g.BOARD
|
||||
|
||||
unwatch: (board, id) ->
|
||||
unwatch: (id, board) ->
|
||||
watched = $.get 'watched', {}
|
||||
delete watched[board][id]
|
||||
$.set 'watched', watched
|
||||
watcher.refresh()
|
||||
|
||||
watch: (thread, id) ->
|
||||
text = getTitle thread
|
||||
props =
|
||||
href: "/#{g.BOARD}/res/#{id}"
|
||||
textContent: text
|
||||
watch: (id) ->
|
||||
thread = $.id id
|
||||
return false if $('.favicon', thread).src is Favicon.default
|
||||
|
||||
watched = $.get 'watched', {}
|
||||
watched[g.BOARD] or= {}
|
||||
watched[g.BOARD][id] = props
|
||||
watched[g.BOARD][id] =
|
||||
href: "/#{g.BOARD}/res/#{id}"
|
||||
textContent: getTitle thread
|
||||
$.set 'watched', watched
|
||||
watcher.refresh()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user