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