From 1d95163ef89bced3b5af24a887edb1962f7b42ce Mon Sep 17 00:00:00 2001 From: alxnegrila Date: Thu, 11 Aug 2016 08:13:18 +0300 Subject: [PATCH] Fix bot-list scroll and height (#166) * Add collapse on bots menu(similar to Settings) - hide/show bot(names). * Fix bot-list scroll and height(optimise for mobile devices). * Add configurable request frequency. --- config/userdata.js.example | 6 ++++++ css/main.css | 3 ++- js/main.js | 16 ++++++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/config/userdata.js.example b/config/userdata.js.example index c16c899..abfd931 100644 --- a/config/userdata.js.example +++ b/config/userdata.js.example @@ -9,3 +9,9 @@ var userInfo = { botPath: true, actionsEnabled: false }; +//milliseconds +var dataUpdates = { + updateTrainer: 1000, + addCatchable: 1000, + addInventory: 5000 +}; \ No newline at end of file diff --git a/css/main.css b/css/main.css index b48f12f..a9a3b21 100644 --- a/css/main.css +++ b/css/main.css @@ -74,7 +74,8 @@ html, body { float: left; } #bots-list { - max-height: 80vh; + max-height: 70vh; + overflow-y: scroll; } #bots-list::-webkit-scrollbar { display: none; diff --git a/js/main.js b/js/main.js index 1033fd7..ff0c288 100644 --- a/js/main.js +++ b/js/main.js @@ -161,7 +161,7 @@ var mapView = { settings: {}, init: function() { var self = this; - self.settings = $.extend(true, self.settings, userInfo); + self.settings = $.extend(true, self.settings, userInfo, dataUpdates); self.bindUi(); $.getScript('https://maps.googleapis.com/maps/api/js?key={0}&libraries=drawing'.format(self.settings.gMapsAPIKey), function() { @@ -290,9 +290,9 @@ var mapView = { }); self.placeTrainer(); self.addCatchable(); - setInterval(self.updateTrainer, 1000); - setInterval(self.addCatchable, 1000); - setInterval(self.addInventory, 5000); + setInterval(self.updateTrainer, self.settings.updateTrainer); + setInterval(self.addCatchable, self.settings.addCatchable); + setInterval(self.addInventory, self.settings.addInventory); }, addCatchable: function() { var self = mapView; @@ -979,8 +979,12 @@ var mapView = { xhr.onreadystatechange = function() { if (xhr.readyState === XMLHttpRequest.DONE) { if (xhr.status === 200) { - if (success) - success(JSON.parse(xhr.responseText.replace(/\bNaN\b/g, 'null')), successData); + if (success) { + try { + success(JSON.parse(xhr.responseText.replace(/\bNaN\b/g, 'null')), successData); + } catch (err) { + } + } } else { if (error) error(xhr);