Better thread watcher list update on un/watch.
This commit is contained in:
parent
6584da2a68
commit
fa2ebec87a
32
4chan_x.js
32
4chan_x.js
@ -1496,6 +1496,28 @@
|
|||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
},
|
},
|
||||||
|
list: function(watched) {
|
||||||
|
var board, div, id, props, _results;
|
||||||
|
div = $('#watcher > div:not(.move)');
|
||||||
|
while (div) {
|
||||||
|
$.remove(div);
|
||||||
|
div = $('#watcher > div:not(.move)');
|
||||||
|
}
|
||||||
|
_results = [];
|
||||||
|
for (board in watched) {
|
||||||
|
_results.push((function() {
|
||||||
|
var _ref, _results;
|
||||||
|
_ref = watched[board];
|
||||||
|
_results = [];
|
||||||
|
for (id in _ref) {
|
||||||
|
props = _ref[id];
|
||||||
|
_results.push(watcher.addLink(props, $('#watcher')));
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
})());
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
},
|
||||||
addLink: function(props, dialog) {
|
addLink: function(props, dialog) {
|
||||||
var div, link, x;
|
var div, link, x;
|
||||||
dialog || (dialog = $('#watcher'));
|
dialog || (dialog = $('#watcher'));
|
||||||
@ -1529,17 +1551,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
unwatch: function(board, id) {
|
unwatch: function(board, id) {
|
||||||
var div, favicon, href, input, watched;
|
var favicon, input, watched;
|
||||||
href = "/" + board + "/res/" + id;
|
|
||||||
div = $("#watcher a[href=\"" + href + "\"]").parentNode;
|
|
||||||
$.remove(div);
|
|
||||||
if (input = $("input[name=\"" + id + "\"]")) {
|
if (input = $("input[name=\"" + id + "\"]")) {
|
||||||
favicon = input.previousSibling;
|
favicon = input.previousSibling;
|
||||||
favicon.src = Favicon.empty;
|
favicon.src = Favicon.empty;
|
||||||
}
|
}
|
||||||
watched = $.getValue('watched', {});
|
watched = $.getValue('watched', {});
|
||||||
delete watched[board][id];
|
delete watched[board][id];
|
||||||
return $.setValue('watched', watched);
|
$.setValue('watched', watched);
|
||||||
|
return watcher.list(watched);
|
||||||
},
|
},
|
||||||
watch: function(thread) {
|
watch: function(thread) {
|
||||||
var favicon, id, props, tc, watched, _name;
|
var favicon, id, props, tc, watched, _name;
|
||||||
@ -1558,7 +1578,7 @@
|
|||||||
watched[_name = g.BOARD] || (watched[_name] = {});
|
watched[_name = g.BOARD] || (watched[_name] = {});
|
||||||
watched[g.BOARD][id] = props;
|
watched[g.BOARD][id] = props;
|
||||||
$.setValue('watched', watched);
|
$.setValue('watched', watched);
|
||||||
return watcher.addLink(props);
|
return watcher.list(watched);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
anonymize = {
|
anonymize = {
|
||||||
|
|||||||
@ -1184,6 +1184,15 @@ watcher =
|
|||||||
$.bind favicon, 'click', watcher.cb.toggle
|
$.bind favicon, 'click', watcher.cb.toggle
|
||||||
$.before input, favicon
|
$.before input, favicon
|
||||||
|
|
||||||
|
list: (watched) ->
|
||||||
|
div = $ '#watcher > div:not(.move)'
|
||||||
|
while div
|
||||||
|
$.remove div
|
||||||
|
div = $ '#watcher > div:not(.move)'
|
||||||
|
for board of watched
|
||||||
|
for id, props of watched[board]
|
||||||
|
watcher.addLink props, $ '#watcher'
|
||||||
|
|
||||||
addLink: (props, dialog) ->
|
addLink: (props, dialog) ->
|
||||||
dialog or= $ '#watcher'
|
dialog or= $ '#watcher'
|
||||||
div = $.el 'div'
|
div = $.el 'div'
|
||||||
@ -1212,10 +1221,6 @@ watcher =
|
|||||||
watcher.unwatch g.BOARD, id
|
watcher.unwatch g.BOARD, id
|
||||||
|
|
||||||
unwatch: (board, id) ->
|
unwatch: (board, id) ->
|
||||||
href = "/#{board}/res/#{id}"
|
|
||||||
div = $("#watcher a[href=\"#{href}\"]").parentNode
|
|
||||||
$.remove div
|
|
||||||
|
|
||||||
if input = $ "input[name=\"#{id}\"]"
|
if input = $ "input[name=\"#{id}\"]"
|
||||||
favicon = input.previousSibling
|
favicon = input.previousSibling
|
||||||
favicon.src = Favicon.empty
|
favicon.src = Favicon.empty
|
||||||
@ -1224,6 +1229,8 @@ watcher =
|
|||||||
delete watched[board][id]
|
delete watched[board][id]
|
||||||
$.setValue 'watched', watched
|
$.setValue 'watched', watched
|
||||||
|
|
||||||
|
watcher.list watched
|
||||||
|
|
||||||
watch: (thread) ->
|
watch: (thread) ->
|
||||||
favicon = $ 'img.favicon', thread
|
favicon = $ 'img.favicon', thread
|
||||||
return if favicon.src is Favicon.default
|
return if favicon.src is Favicon.default
|
||||||
@ -1240,7 +1247,7 @@ watcher =
|
|||||||
watched[g.BOARD][id] = props
|
watched[g.BOARD][id] = props
|
||||||
$.setValue 'watched', watched
|
$.setValue 'watched', watched
|
||||||
|
|
||||||
watcher.addLink props
|
watcher.list watched
|
||||||
|
|
||||||
anonymize =
|
anonymize =
|
||||||
init: ->
|
init: ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user