From 79c0845f3c6bf1c7cdc6e81bf66e1de97f586b81 Mon Sep 17 00:00:00 2001 From: Philippe Pepiot Date: Wed, 17 Jan 2018 11:31:13 +0100 Subject: [PATCH] Add branch state in url on regression page Add a 'branch' parameter in the url so the branch selection can be shared through the url. --- asv/www/regressions.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/asv/www/regressions.js b/asv/www/regressions.js index 318ca1303..3befe4fe5 100644 --- a/asv/www/regressions.js +++ b/asv/www/regressions.js @@ -42,6 +42,14 @@ $(document).ready(function() { } } + function update_url(params) { + var info = $.asv.parse_hash_string(window.location.hash); + $.each(params || {}, function(key, value) { + info.params[key] = value; + }); + window.location.hash = $.asv.format_hash_string(info); + } + function display_data(data, params) { var main_div = $('
'); var branches = $.asv.master_json.params['branch']; @@ -79,6 +87,7 @@ $(document).ready(function() { dropdown_menu.append($('
  • ').append(branch_link)); branch_link.on('click', function(evt) { current_title = "Regressions in " + branch + " branch"; + update_url({'branch': [branch]}); $("#title").text(current_title); $(".regression-div").hide(); $(".ignored").hide(); @@ -113,11 +122,19 @@ $(document).ready(function() { }); }); + var branch_index = 0; if (branches && branches.length > 1) { - current_title = "Regressions in " + branches[0] + " branch"; + var info = $.asv.parse_hash_string(window.location.hash); + if (info.params.branch) { + branch_index = branches.indexOf(info.params.branch[0]); + if (branch_index < 0) { + branch_index = 0; + } + } + current_title = "Regressions in " + branches[branch_index] + " branch"; } $("#title").text(current_title); - main_div.find("#regression-div-0").show(); + main_div.find("#regression-div-" + branch_index).show(); main_div.show(); if (local_storage_available) { @@ -419,11 +436,7 @@ $(document).ready(function() { }); table.bind('aftertablesort', function (event, data) { - var info = $.asv.parse_hash_string(window.location.hash); - info.params['sort'] = [data.column]; - info.params['dir'] = [data.direction]; - window.location.hash = $.asv.format_hash_string(info); - + update_url({'sort': [data.column], 'dir': [data.direction]}); /* Update appearance */ table.find('thead th').removeClass('asc'); table.find('thead th').removeClass('desc');