[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [atlas/master] Refactor the loading content state transitions
commit fbed2dfd7ac33e592f7c2e64e754af9bdfb2717d
Author: cypherpunks <cypherpunks@xxxxxxxxxxxxxx>
Date: Fri Mar 3 10:52:18 2017 +0000
Refactor the loading content state transitions
Part of #21623.
---
js/router.js | 30 ++++++++++++------------------
js/views/about/main.js | 1 -
js/views/details/main.js | 3 ---
js/views/search/do.js | 3 ---
js/views/search/main.js | 7 -------
5 files changed, 12 insertions(+), 32 deletions(-)
diff --git a/js/router.js b/js/router.js
index 65cf8af..1a54f2d 100644
--- a/js/router.js
+++ b/js/router.js
@@ -33,21 +33,21 @@ define([
$("#home").removeClass("active");
$("#about").removeClass("active");
- $("#loading").show();
$("#content").hide();
+ $("#loading").show();
mainDetailsView.model.fingerprint = this.hashFingerprint(fingerprint);
mainDetailsView.model.lookup({
success: function(relay) {
- $("#content").show();
mainDetailsView.render();
$("#loading").hide();
+ $("#content").show();
},
error: function() {
- $("#content").show();
mainDetailsView.error();
$("#loading").hide();
+ $("#content").show();
}
});
},
@@ -57,15 +57,15 @@ define([
$("#home").removeClass("active");
$("#about").removeClass("active");
- $("#loading").show();
$("#content").hide();
+ $("#loading").show();
$("#nav-search").val(query);
if (query == "") {
- $("#content").show();
doSearchView.error = 5;
doSearchView.renderError();
$("#loading").hide();
+ $("#content").show();
} else {
doSearchView.collection.url =
doSearchView.collection.baseurl + this.hashFingerprint(query);
@@ -80,18 +80,18 @@ define([
doSearchView.relays[0].fingerprint;
return;
}
- $("#content").show();
doSearchView.error = err;
doSearchView.render(query);
$("#search-title").text(query);
$("#loading").hide();
+ $("#content").show();
},
error: function(err){
- $("#content").show();
doSearchView.error = err;
doSearchView.renderError();
$("#loading").hide();
+ $("#content").show();
}
});
}
@@ -100,24 +100,24 @@ define([
$("#home").removeClass("active");
$("#about").removeClass("active");
- $("#loading").show();
$("#content").hide();
+ $("#loading").show();
doSearchView.collection.url = "https://onionoo.torproject.org/summary?type=relay&order=-consensus_weight&limit=10&running=true";
doSearchView.collection.lookup({
success: function(relays){
- $("#content").show();
doSearchView.relays = doSearchView.collection.models;
doSearchView.render("");
$("#search-title").text("Top 10 Relays by Consensus Weight");
$("#loading").hide();
+ $("#content").show();
},
error: function(erno){
- $("#content").show();
doSearchView.error = erno;
doSearchView.renderError();
$("#loading").hide();
+ $("#content").show();
}
});
},
@@ -126,13 +126,10 @@ define([
$("#home").removeClass("active");
$("#about").addClass("active");
- $("#loading").show();
- //$("#content").hide();
-
aboutView.render();
$("#loading").hide();
- //$("#content").show();
+ $("#content").show();
},
// No matched rules go to the default home page
@@ -140,13 +137,10 @@ define([
$("#home").addClass("active");
$("#about").removeClass("active");
- $("#loading").show();
- //$("#content").hide();
-
mainSearchView.render();
- //$("#content").show();
$("#loading").hide();
+ $("#content").show();
}
});
diff --git a/js/views/about/main.js b/js/views/about/main.js
index 4d6aad1..c92518c 100644
--- a/js/views/about/main.js
+++ b/js/views/about/main.js
@@ -17,7 +17,6 @@ define([
var data = {};
var compiledTemplate = _.template(aboutTemplate, data);
this.el.html(compiledTemplate);
- //$("#loading").hide();
}
});
return new aboutView;
diff --git a/js/views/details/main.js b/js/views/details/main.js
index cc4d51a..5605c0c 100644
--- a/js/views/details/main.js
+++ b/js/views/details/main.js
@@ -21,7 +21,6 @@ define([
this.model = new relayModel;
this.graph = new graphModel;
//console.log(this.graph);
- $("#loading").show();
},
plot: function(g, data, labels, legendPos, colors, tickFormat,
tooltipFormat) {
@@ -238,12 +237,10 @@ define([
});
}
- $("#loading").hide();
$(".tip").tooltip({ placement: 'right' });
},
error: function() {
var compiledTemplate = _.template(errorDetailsTemplate, {relay: null});
- $("#loading").hide();
this.el.html(compiledTemplate);
}
});
diff --git a/js/views/search/do.js b/js/views/search/do.js
index 1899e85..8bc38b8 100644
--- a/js/views/search/do.js
+++ b/js/views/search/do.js
@@ -15,7 +15,6 @@ define([
el: $("#content"),
initialize: function() {
this.collection = new resultsCollection;
- $("#loading").show();
},
filtering: function() {
var rangefilter = function(data) {
@@ -150,7 +149,6 @@ define([
var asInitVals = new Array();
var compiledTemplate = _.template(doSearchTemplate, {relays: this.relays, countries: CountryCodes, error: this.error});
this.el.html(compiledTemplate);
- $("#loading").hide();
var fp = this;
// This creates the table using DataTables
var oTable = $('#torstatus_results').dataTable({
@@ -230,7 +228,6 @@ define([
renderError: function(){
var compiledTemplate = _.template(doSearchTemplate, {relays: null, error: this.error, countries: null});
- $("#loading").hide();
this.el.html(compiledTemplate);
}
diff --git a/js/views/search/main.js b/js/views/search/main.js
index c9ab9a2..6a099f9 100644
--- a/js/views/search/main.js
+++ b/js/views/search/main.js
@@ -8,9 +8,6 @@ define([
], function($, _, Backbone, mainSearchTemplate){
var mainSearchView = Backbone.View.extend({
el: $("#content"),
- initialize: function(){
- $("#loading").show();
- },
render: function(query){
document.title = "Atlas";
@@ -19,7 +16,6 @@ define([
this.el.html(compiledTemplate);
$("#do_search").bind('click', function(){
var query = _.escape($('#query').val());
- $("#loading").show();
$("#suggestion").hide();
document.location = "#search/"+query;
return false;
@@ -27,13 +23,10 @@ define([
$("#home-search").bind('submit', function(){
var query = _.escape($('#query').val());
- $("#loading").show();
$("#suggestion").hide();
document.location = "#search/"+query;
return false;
});
-
- $("#loading").hide();
}
});
return new mainSearchView;
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits