commit cc62bd8409c595e22e7284a194d4c085f99b7e6e Author: Iain R. Learmonth irl@fsfe.org Date: Tue Nov 21 20:52:14 2017 +0000
Adds back a perisistent search box (Fixes: #24274) --- index.html | 9 +++++++++ js/router.js | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+)
diff --git a/index.html b/index.html index 731653b..fab491f 100644 --- a/index.html +++ b/index.html @@ -139,6 +139,15 @@ <li><a href="https://metrics.torproject.org/services.html">Services</a></li> <li class="active">Relay Search</li> </ul> + <form class="hidden-xs navbar-form pull-right" role="search" id="secondary-search"> + <div class="input-group add-on"> + <input class="form-control" placeholder="Search" name="secondary-search-query" id="secondary-search-query" type="text" autocorrect="off" autocapitalize="none"> + <div class="input-group-btn"> + <button class="btn btn-secondary" id="secondary-search-clear" type="button"><i class="glyphicon glyphicon-remove-circle"></i></span> + <button class="btn btn-primary" id="secondary-search-submit" type="submit"><i class="glyphicon glyphicon-search"></i></button> + </div> + </div> + </form> <h1>Relay Search</h1> <div class="progress progress-info progress-striped active"> <div class="bar"></div> diff --git a/js/router.js b/js/router.js index 1844203..03553fc 100644 --- a/js/router.js +++ b/js/router.js @@ -40,6 +40,7 @@ define([ $(".progress").hide(); $("#content").show(); $(".breadcrumb").html("<li><a href="https://metrics.torproject.org/%5C%22%3EHome</a></li><li><a href="https://metrics.torproject.org/services.html%5C%22%3EServices</a></li><li><a href="#">Relay Search</a></li><li class="active">Details for " + relay.get('nickname') + "</li>"); + $("#secondary-search").show();
}, error: function() { @@ -47,6 +48,7 @@ define([ $(".progress").hide(); $("#content").show(); $(".breadcrumb").html("<li><a href="https://metrics.torproject.org/%5C%22%3EHome</a></li><li><a href="https://metrics.torproject.org/services.html%5C%22%3EServices</a></li><li><a href="#">Relay Search</a></li><li class="active">Error</li>"); + $("#secondary-search").show(); } }); }, @@ -54,6 +56,8 @@ define([ // Perform a search on Atlas doSearch: function(query){ $(".breadcrumb").html("<li><a href="https://metrics.torproject.org/%5C%22%3EHome</a></li><li><a href="https://metrics.torproject.org/services.html%5C%22%3EServices</a></li><li><a href="#">Relay Search</a></li><li class="active">Search for " + query + "</li>"); + $("#secondary-search").show(); + $("#secondary-search-query").val(query);
$("#content").hide(); $(".progress").show(); @@ -96,6 +100,9 @@ define([ showTopRelays: function(){ $(".breadcrumb").html("<li><a href="https://metrics.torproject.org/%5C%22%3EHome</a></li><li><a href="https://metrics.torproject.org/services.html%5C%22%3EServices</a></li><li><a href="#">Relay Search</a></li><li class="active">Top Relays</li>");
+ $("#secondary-search").show(); + $("#secondary-search-query").val(""); + $("#content").hide(); $(".progress").show();
@@ -122,6 +129,8 @@ define([ // No matched rules go to the default home page defaultAction: function(actions){ $(".breadcrumb").html("<li><a href="https://metrics.torproject.org/%5C%22%3EHome</a></li><li><a href="https://metrics.torproject.org/services.html%5C%22%3EServices</a></li><li class="active">Relay Search</li>"); + $("#secondary-search").hide(); + $("#secondary-search-query").val("");
mainSearchView.render();
@@ -134,6 +143,22 @@ define([ var initialize = function(){ var app_router = new AppRouter; Backbone.history.start(); + + $("#secondary-search-submit").bind('click', function(){ + document.location = "#search/"+encodeURI($('#secondary-search-query').val()); + return false; + }); + + $("#secondary-search-clear").bind('click', function(){ + $("#secondary-search-query").val(""); + return false; + }); + + $("#secondary-search").bind('submit', function(){ + document.location = "#search/"+encodeURI($('#secondary-search-query').val()); + return false; + }); + }; return { initialize: initialize
tor-commits@lists.torproject.org