diff --git a/LICENSE b/LICENSE
index 4f4208dbb..cf0a968f3 100755
--- a/LICENSE
+++ b/LICENSE
@@ -1,5 +1,5 @@
/*
-* 4chan X - Version 1.7.33 - 2014-05-11
+* 4chan X - Version 1.7.33 - 2014-05-16
*
* Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js
index 417dc83e5..1ecbb9208 100644
--- a/builds/4chan-X.user.js
+++ b/builds/4chan-X.user.js
@@ -24,7 +24,7 @@
// ==/UserScript==
/*
-* 4chan X - Version 1.7.33 - 2014-05-11
+* 4chan X - Version 1.7.33 - 2014-05-16
*
* Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
@@ -2651,6 +2651,7 @@
className: 'navLinks',
innerHTML: "Return Bottom "
});
+ this.timeEl = $('time#index-last-refresh', this.navLinks);
this.searchInput = $('#index-search', this.navLinks);
this.searchTest(true);
this.hideLabel = $('#hidden-label', this.navLinks);
@@ -2670,7 +2671,8 @@
$.on(this.selectSort, 'change', this.cb.sort);
$.on(this.selectSize, 'change', this.cb.size);
this.currentPage = this.getCurrentPage();
- $.on(d, 'scroll', Index.scroll);
+ $.on(d, 'scroll', this.scroll);
+ $.on(window, 'focus', this.updateIfNeeded);
$.on(this.pagelist, 'click', this.cb.pageNav);
$.on($('#returnlink a', this.navLinks), 'click', function(e) {
if (g.VIEW === 'index') {
@@ -3181,6 +3183,14 @@
Index.hideLabel.hidden = false;
return $('#hidden-count', Index.hideLabel).textContent = hiddenCount === 1 ? '1 hidden thread' : "" + hiddenCount + " hidden threads";
},
+ updateIfNeeded: function() {
+ var needed, timeEl;
+ timeEl = Index.timeEl;
+ needed = g.VIEW === 'index' && !Index.req && timeEl.dataset.utc && timeEl.dataset.utc < Date.now() - (10 * $.MINUTE);
+ if (needed) {
+ return Index.update();
+ }
+ },
update: function(pageNum) {
var board, now, onload, sortedThreads, _ref, _ref1;
if (!navigator.onLine) {
@@ -3278,7 +3288,7 @@
}
return;
}
- timeEl = $('time#index-last-refresh', Index.navLinks);
+ timeEl = Index.timeEl;
timeEl.dataset.utc = Date.parse(req.getResponseHeader('Last-Modified'));
RelativeDates.update(timeEl);
return Index.scrollToIndex();
@@ -12956,7 +12966,7 @@
}
if (e) {
if (e.shiftKey || e.ctrlKey || (e.type === 'click' && e.button !== 0)) {
- if ((e != null ? e.button : void 0) !== 2) {
+ if (e.button !== 2) {
Navigate.setMode(this);
}
return;
diff --git a/builds/crx/script.js b/builds/crx/script.js
index b4d919749..11408765d 100644
--- a/builds/crx/script.js
+++ b/builds/crx/script.js
@@ -1,6 +1,6 @@
// Generated by CoffeeScript
/*
-* 4chan X - Version 1.7.33 - 2014-05-11
+* 4chan X - Version 1.7.33 - 2014-05-16
*
* Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
@@ -2710,6 +2710,7 @@
className: 'navLinks',
innerHTML: "Return Bottom "
});
+ this.timeEl = $('time#index-last-refresh', this.navLinks);
this.searchInput = $('#index-search', this.navLinks);
this.searchTest(true);
this.hideLabel = $('#hidden-label', this.navLinks);
@@ -2729,7 +2730,8 @@
$.on(this.selectSort, 'change', this.cb.sort);
$.on(this.selectSize, 'change', this.cb.size);
this.currentPage = this.getCurrentPage();
- $.on(d, 'scroll', Index.scroll);
+ $.on(d, 'scroll', this.scroll);
+ $.on(window, 'focus', this.updateIfNeeded);
$.on(this.pagelist, 'click', this.cb.pageNav);
$.on($('#returnlink a', this.navLinks), 'click', function(e) {
if (g.VIEW === 'index') {
@@ -3240,6 +3242,14 @@
Index.hideLabel.hidden = false;
return $('#hidden-count', Index.hideLabel).textContent = hiddenCount === 1 ? '1 hidden thread' : "" + hiddenCount + " hidden threads";
},
+ updateIfNeeded: function() {
+ var needed, timeEl;
+ timeEl = Index.timeEl;
+ needed = g.VIEW === 'index' && !Index.req && timeEl.dataset.utc && timeEl.dataset.utc < Date.now() - (10 * $.MINUTE);
+ if (needed) {
+ return Index.update();
+ }
+ },
update: function(pageNum) {
var board, now, onload, sortedThreads, _ref, _ref1;
if (!navigator.onLine) {
@@ -3337,7 +3347,7 @@
}
return;
}
- timeEl = $('time#index-last-refresh', Index.navLinks);
+ timeEl = Index.timeEl;
timeEl.dataset.utc = Date.parse(req.getResponseHeader('Last-Modified'));
RelativeDates.update(timeEl);
return Index.scrollToIndex();
@@ -12976,7 +12986,7 @@
}
if (e) {
if (e.shiftKey || e.ctrlKey || (e.type === 'click' && e.button !== 0)) {
- if ((e != null ? e.button : void 0) !== 2) {
+ if (e.button !== 2) {
Navigate.setMode(this);
}
return;
diff --git a/src/General/Index.coffee b/src/General/Index.coffee
index a5b6114ae..3eb316dad 100644
--- a/src/General/Index.coffee
+++ b/src/General/Index.coffee
@@ -91,6 +91,7 @@ Index =
@navLinks = $.el 'div',
className: 'navLinks'
innerHTML: <%= importHTML('Features/Index-navlinks') %>
+ @timeEl = $ 'time#index-last-refresh', @navLinks
@searchInput = $ '#index-search', @navLinks
@@ -112,7 +113,8 @@ Index =
@currentPage = @getCurrentPage()
- $.on d, 'scroll', Index.scroll
+ $.on d, 'scroll', @scroll
+ $.on window, 'focus', @updateIfNeeded
$.on @pagelist, 'click', @cb.pageNav
$.on $('#returnlink a', @navLinks), 'click', (e) ->
if g.VIEW is 'index'
@@ -488,6 +490,18 @@ Index =
else
"#{hiddenCount} hidden threads"
+ updateIfNeeded: ->
+ {timeEl} = Index
+ needed =
+ # we're on the index,
+ g.VIEW is 'index' and
+ # not currently refreshing
+ !Index.req and
+ timeEl.dataset.utc and
+ # more than 10 minutes have elapsed since the last refresh.
+ timeEl.dataset.utc < Date.now() - (10 * $.MINUTE)
+ Index.update() if needed
+
update: (pageNum) ->
return unless navigator.onLine
if g.VIEW is 'thread'
@@ -565,7 +579,7 @@ Index =
new Notice 'error', 'Index refresh failed.', 1
return
- timeEl = $ 'time#index-last-refresh', Index.navLinks
+ {timeEl} = Index
timeEl.dataset.utc = Date.parse req.getResponseHeader 'Last-Modified'
RelativeDates.update timeEl
Index.scrollToIndex()
diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee
index fac1d94be..f4e132619 100644
--- a/src/General/Navigate.coffee
+++ b/src/General/Navigate.coffee
@@ -202,8 +202,8 @@ Navigate =
return if @hostname isnt 'boards.4chan.org' or window.location.hostname is 'rs.4chan.org'
if e
if e.shiftKey or e.ctrlKey or (e.type is 'click' and e.button isnt 0) # Not simply a left click
- Navigate.setMode @ unless e?.button is 2 # Right Click
- return
+ Navigate.setMode @ unless e.button is 2 # Right Click
+ return
if @pathname is Navigate.path
if g.VIEW is 'thread'