summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-06-06 22:36:50 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2018-06-06 22:38:03 +0200
commitb19c24c0cabfb8b25a16d816b806d1dc51069721 (patch)
tree82e150c9baa40ba3714b3af0783681c850362f93
parent13009ff016ce8bde41e46a0927d8cb46898523e4 (diff)
downloadbackoffice-b19c24c0cabfb8b25a16d816b806d1dc51069721.tar.gz
backoffice-b19c24c0cabfb8b25a16d816b806d1dc51069721.tar.bz2
backoffice-b19c24c0cabfb8b25a16d816b806d1dc51069721.zip
Scrolling feature.
Disabling the scrolling feature after the page gets filled by /track/transaction results. Such results are not guaranteed to be sorted in any way, so there is little point in scrolling down towards "older" results. The scrolling feature will be re-enabled once the page will again be filled with results from /history - notably, on page refresh.
-rw-r--r--js/backoffice.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/js/backoffice.js b/js/backoffice.js
index 82b0ae6..35e5c88 100644
--- a/js/backoffice.js
+++ b/js/backoffice.js
@@ -31,6 +31,7 @@ var FRACTION = 100000000;
var START = 0;
var DELTA = 5
var LAST = 0;
+var SCROLL = true;
/**
* This function *could* "type check" 'amount',
@@ -161,6 +162,13 @@ var track_transfer = function(exchange, wtid, cb){
if(4 == req.readyState){
switch(req.status){
case 200:
+ /* Scroll is disabled after showing /track/transfer
+ * results on the page; that's because those results
+ * are not guaranteed to be sorted any how, so there
+ * is little to no point in scrolling towards "older"
+ * results: older than what? The scroll feature will
+ * be re-enabled from the /history callback. */
+ SCROLL = false;
var tracks = JSON.parse(req.responseText);
cb(false,
tracks.deposits_sums,
@@ -538,6 +546,7 @@ function change_instance(){
* to 'fill_table()'.
*/
function get_history(scroll, cb){
+ SCROLL = true;
var qs = `/history?instance=${get_instance()}&delta=${DELTA}`;
if(scroll){
START = LAST;
@@ -579,8 +588,8 @@ document.addEventListener
document.addEventListener
("scroll", function(){
/* If page bottom is hit */
- if(window.innerHeight + window.scrollY
- >= document.body.offsetHeight)
+ if((window.innerHeight + window.scrollY
+ >= document.body.offsetHeight) && SCROLL)
get_history(true, fill_table);
});