summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-06-20 22:35:29 +0200
committeremkael <emkael@tlen.pl>2017-06-20 22:35:29 +0200
commit0646c0253df9536b6b6cbbbc7b5d331f32eac4cf (patch)
tree2575c6d171af7afa5f347fa6e3af38c621c5e55f /http
parentb3a1dbdf8e6a93b346932ed673908ba481e21c7a (diff)
Refactoring param change detection
Diffstat (limited to 'http')
-rw-r--r--http/res/ranking.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/http/res/ranking.js b/http/res/ranking.js
index 61cb856..bae4be9 100644
--- a/http/res/ranking.js
+++ b/http/res/ranking.js
@@ -69,16 +69,18 @@ var ranking = {
savedParams : new Map(),
+ paramChanged: function(params, param) {
+ var newParam = params.get(param) || [];
+ var oldParam = ranking.savedParams.get(param) || [];
+ return (newParam.length != oldParam.length) || (newParam.join(',') != oldParam.join(','));
+ },
+
readHash : function() {
var params = ranking.parseHash(location.hash);
var allParams = ['age', 'gender', 'region', 'name'];
var paramsChanged = false;
allParams.forEach(function(param) {
- var newParam = params.get(param) || [];
- var oldParam = ranking.savedParams.get(param) || [];
- if (newParam.length != oldParam.length || newParam.join(',') != oldParam.join(',')) {
- paramsChanged = true;
- }
+ paramsChanged |= ranking.paramChanged(params, param);
});
$('button.btn-primary').removeClass('btn-primary');
params.forEach(function(values, param) {