diff options
author | christian | 2016-08-08 17:12:45 +0200 |
---|---|---|
committer | christian | 2016-08-08 17:12:45 +0200 |
commit | 0c4caeb31ff5f258bb838c23033879cc88e144a8 (patch) | |
tree | fdbc65088d59e6b878cfca9b2a6613a5aebd709c /wqflask | |
parent | d5d205b442de942f9004dfd393631344d73eedfe (diff) | |
download | genenetwork2-0c4caeb31ff5f258bb838c23033879cc88e144a8.tar.gz |
Refactor BD-related code into a module
Diffstat (limited to 'wqflask')
6 files changed, 29 insertions, 27 deletions
diff --git a/wqflask/wqflask/static/new/javascript/biodalliance.js b/wqflask/wqflask/static/new/javascript/biodalliance.js index 2dde6365..1b3062e0 100644 --- a/wqflask/wqflask/static/new/javascript/biodalliance.js +++ b/wqflask/wqflask/static/new/javascript/biodalliance.js @@ -1,13 +1,15 @@ "use strict"; -var bd_browser = null; -var bd_data = {}; + +var BD = {}; +BD.browser = null; +BD.data = {}; var getChrLen = function(chr) { return js_data[chr * 1]; }; -var createBDBrowser = function(chr, start, end, speciesName, sources) { +BD.createBrowser = function(chr, start, end, speciesName, sources) { console.log("creating BD browser"); var b = new Browser({ chr: chr, @@ -30,32 +32,27 @@ var createBDBrowser = function(chr, start, end, speciesName, sources) { return b; }; -var showBDButton = function() { +BD.showButton = function() { $('#open_bd').show(); $('#close_bd').hide(); }; -var hideBDButton = function() { +BD.hideButton = function() { $('#close_bd').show(); $('#open_bd').hide(); }; -var setBDData = function(chr, length) { - // bd_data = { chr: chr, length: length }; - bd_data.chr = chr; - bd_data.length = length; -}; - -var setBDSpecies = function(species) { - bd_data.species = species; +BD.putData = function(data) { + for (var key in data) { + BD.data[key] = data[key]; + } }; - -var openBDBrowser = function() { +BD.openBrowser = function() { console.log("opening browser"); - if (!bd_browser) { - bd_browser = createBDBrowser(bd_data.chr, 0, bd_data.length * 1000000, bd_data.species, + if (!BD.browser) { + BD.browser = BD.createBrowser(BD.data.chr, 0, BD.data.length * 1000000, BD.data.species, [{name: 'Genome', twoBitURI: 'http://www.biodalliance.org/datasets/GRCm38/mm10.2bit', desc: 'Mouse reference genome build GRCm38', @@ -68,8 +65,8 @@ var openBDBrowser = function() { }] ); } else { - bd_browser.setLocation(bd_data.chr, 0, bd_data.length * 1000000); + BD.browser.setLocation(BD.data.chr, 0, BD.data.length * 1000000); } - bd_browser.maxViewWidth = bd_data.length * 1000000; + BD.browser.maxViewWidth = BD.data.length * 1000000; }; diff --git a/wqflask/wqflask/static/new/javascript/chr_lod_chart.coffee b/wqflask/wqflask/static/new/javascript/chr_lod_chart.coffee index d3c1ee7d..173f8186 100644 --- a/wqflask/wqflask/static/new/javascript/chr_lod_chart.coffee +++ b/wqflask/wqflask/static/new/javascript/chr_lod_chart.coffee @@ -273,7 +273,8 @@ class Chr_Lod_Chart $("#return_to_full_view").hide()
$('#topchart').remove()
$('#chart_container').append('<div class="qtlcharts" id="topchart"></div>')
- hideBDButton()
+ BD.hideButton()
+ $('#bd_container').hide()
create_lod_chart()
show_marker_in_table: (marker_info) ->
diff --git a/wqflask/wqflask/static/new/javascript/chr_lod_chart.js b/wqflask/wqflask/static/new/javascript/chr_lod_chart.js index 0032858f..01bb4601 100644 --- a/wqflask/wqflask/static/new/javascript/chr_lod_chart.js +++ b/wqflask/wqflask/static/new/javascript/chr_lod_chart.js @@ -260,7 +260,8 @@ Chr_Lod_Chart = (function() { $("#return_to_full_view").hide(); $('#topchart').remove(); $('#chart_container').append('<div class="qtlcharts" id="topchart"></div>'); - hideBDButton(); + BD.hideButton(); + $('#bd_container').hide(); return create_lod_chart(); }; diff --git a/wqflask/wqflask/static/new/javascript/lod_chart.coffee b/wqflask/wqflask/static/new/javascript/lod_chart.coffee index 2da2e5bb..a65df84f 100644 --- a/wqflask/wqflask/static/new/javascript/lod_chart.coffee +++ b/wqflask/wqflask/static/new/javascript/lod_chart.coffee @@ -123,8 +123,8 @@ lodchart = () -> .on("click", (d) -> console.log("d is:", d) redraw_plot(d) - setBDData(d[0], d[1]) - showBDButton() + BD.putData({chr: d[0], length: d[1]}); + BD.showButton() ) # x-axis labels diff --git a/wqflask/wqflask/static/new/javascript/lod_chart.js b/wqflask/wqflask/static/new/javascript/lod_chart.js index c6d1045c..f1df6bd8 100644 --- a/wqflask/wqflask/static/new/javascript/lod_chart.js +++ b/wqflask/wqflask/static/new/javascript/lod_chart.js @@ -118,8 +118,11 @@ lodchart = function() { }).attr("stroke", "none").on("click", function(d) { console.log("d is:", d); redraw_plot(d); - setBDData(d[0], d[1]); - return showBDButton(); + BD.putData({ + chr: d[0], + length: d[1] + }); + return BD.showButton(); }); xaxis = g.append("g").attr("class", "x axis"); xaxis.selectAll("empty").data(data.chrnames).enter().append("text").text(function(d) { diff --git a/wqflask/wqflask/templates/marker_regression_gn1.html b/wqflask/wqflask/templates/marker_regression_gn1.html index 6eba7ffa..8e2af3cb 100644 --- a/wqflask/wqflask/templates/marker_regression_gn1.html +++ b/wqflask/wqflask/templates/marker_regression_gn1.html @@ -291,7 +291,7 @@ <script type="text/javascript" charset="utf-8"> $(document).ready( function () { - setBDSpecies("{{ dataset.group.species }}"); + BD.putData({species: "{{ dataset.group.species }}" }); console.time("Creating table"); $('#qtl_results').dataTable( { @@ -355,7 +355,7 @@ $('#topchart').hide(); $('#bd_container').show(); - openBDBrowser(); + BD.openBrowser(); }) }); |