Merge branch 'master' of github.com:aeosynth/4chan-x

This commit is contained in:
James Campos 2011-06-02 22:43:41 -07:00
commit 5f1bf34ec2
2 changed files with 19 additions and 30 deletions

View File

@ -1531,15 +1531,16 @@
$.bind(favicon, 'click', watcher.cb.toggle); $.bind(favicon, 'click', watcher.cb.toggle);
$.before(input, favicon); $.before(input, favicon);
} }
watcher.refresh($.getValue('watched', {})); watcher.refresh();
return setInterval((function() { return $.bind(window, 'storage', function(e) {
if (watcher.lastUpdated < $.getValue('watcher.lastUpdated', 0)) { if (e.key === 'AEOS.4chan_x.watched') {
return watcher.refresh($.getValue('watched', {})); return watcher.refresh();
} }
}), 1000); });
}, },
refresh: function(watched) { refresh: function() {
var board, dialog, div, favicon, id, link, props, watchedBoard, x, _i, _j, _len, _len2, _ref, _ref2, _ref3; var board, dialog, div, favicon, id, link, props, watched, watchedBoard, x, _i, _j, _len, _len2, _ref, _ref2, _ref3, _results;
watched = $.getValue('watched', {});
dialog = $('#watcher'); dialog = $('#watcher');
_ref = $$('div:not(.move)', dialog); _ref = $$('div:not(.move)', dialog);
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@ -1562,16 +1563,13 @@
} }
watchedBoard = watched[g.BOARD] || {}; watchedBoard = watched[g.BOARD] || {};
_ref3 = $$('img.favicon'); _ref3 = $$('img.favicon');
_results = [];
for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) { for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
favicon = _ref3[_j]; favicon = _ref3[_j];
id = favicon.nextSibling.name; id = favicon.nextSibling.name;
if (id in watchedBoard) { _results.push(id in watchedBoard ? favicon.src = Favicon["default"] : favicon.src = Favicon.empty);
favicon.src = Favicon["default"];
} else {
favicon.src = Favicon.empty;
}
} }
return watcher.lastUpdated = Date.now(); return _results;
}, },
cb: { cb: {
toggle: function(e) { toggle: function(e) {
@ -1598,8 +1596,7 @@
watched = $.getValue('watched', {}); watched = $.getValue('watched', {});
delete watched[board][id]; delete watched[board][id];
$.setValue('watched', watched); $.setValue('watched', watched);
watcher.refresh(watched); return watcher.refresh();
return $.setValue('watcher.lastUpdated', Date.now());
}, },
watch: function(thread, id) { watch: function(thread, id) {
var props, tc, watched, _name; var props, tc, watched, _name;
@ -1612,8 +1609,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);
watcher.refresh(watched); return watcher.refresh();
return $.setValue('watcher.lastUpdated', Date.now());
} }
}; };
anonymize = { anonymize = {

View File

@ -1245,14 +1245,12 @@ watcher =
$.before input, favicon $.before input, favicon
#populate watcher, display watch buttons #populate watcher, display watch buttons
watcher.refresh $.getValue 'watched', {} watcher.refresh()
setInterval (-> $.bind window, 'storage', (e) -> watcher.refresh() if e.key is 'AEOS.4chan_x.watched'
if watcher.lastUpdated < $.getValue 'watcher.lastUpdated', 0
watcher.refresh $.getValue 'watched', {}
), 1000
refresh: (watched) -> refresh: ->
watched = $.getValue 'watched', {}
dialog = $ '#watcher' dialog = $ '#watcher'
for div in $$ 'div:not(.move)', dialog for div in $$ 'div:not(.move)', dialog
$.rm div $.rm div
@ -1274,7 +1272,6 @@ watcher =
favicon.src = Favicon.default favicon.src = Favicon.default
else else
favicon.src = Favicon.empty favicon.src = Favicon.empty
watcher.lastUpdated = Date.now()
cb: cb:
toggle: (e) -> toggle: (e) ->
@ -1296,9 +1293,7 @@ watcher =
watched = $.getValue 'watched', {} watched = $.getValue 'watched', {}
delete watched[board][id] delete watched[board][id]
$.setValue 'watched', watched $.setValue 'watched', watched
watcher.refresh()
watcher.refresh watched
$.setValue 'watcher.lastUpdated', Date.now()
watch: (thread, id) -> watch: (thread, id) ->
tc = $('span.filetitle', thread).textContent or $('blockquote', thread).textContent tc = $('span.filetitle', thread).textContent or $('blockquote', thread).textContent
@ -1310,9 +1305,7 @@ watcher =
watched[g.BOARD] or= {} watched[g.BOARD] or= {}
watched[g.BOARD][id] = props watched[g.BOARD][id] = props
$.setValue 'watched', watched $.setValue 'watched', watched
watcher.refresh()
watcher.refresh watched
$.setValue 'watcher.lastUpdated', Date.now()
anonymize = anonymize =
init: -> init: ->