From 746b182396dcbc64c6f23b9da9f5af01a9b50521 Mon Sep 17 00:00:00 2001 From: Marcus Poeckelmann <marcus.poeckelmann@informatik.uni-halle.de> Date: Thu, 30 Mar 2023 13:32:23 +0200 Subject: [PATCH] Bugfixes --- README | 2 +- catview.js | 40 ++++++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/README b/README index a3c801b..7aeb9ee 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ Thank you for using CATview - the Colored & Aligned Texts view. -This is version 2.5.1 +This is version 2.5.2 For information about the features and usage of CATview, please visit: https://catview.uzi.uni-halle.de diff --git a/catview.js b/catview.js index d6e2ec8..18a9fd0 100644 --- a/catview.js +++ b/catview.js @@ -22,7 +22,7 @@ SOFTWARE. */ -// CATview - the Colored & Aligned Texts view - version 2.5.1 +// CATview - the Colored & Aligned Texts view - version 2.5.2 const CATview = new function() { this.debug = false; @@ -31,7 +31,7 @@ const CATview = new function() { if(CATview.debug) console.log('CATview.initialize'); - CATview.version = '2.5'; + CATview.version = '2.5.2'; // id of the parent container that will include CATview CATview.parent_id = 'CATview'; @@ -53,7 +53,8 @@ const CATview = new function() { // content settings CATview.content = null; CATview.space_for_egdes_axis = 24; // reserved drawing size of the edges axis - CATview.space_for_names_axis = 4; // reserved drawing size of the name axis (more size is in respect to the actual names is added in .draw_svg) + CATview.space_for_names_axis = 0; // reserved drawing size of the name axis (calculated in respect to the actual names in .draw_svg) + CATview.extra_space_for_names_axis = 4; // some extra reserved space for the names axis CATview.space_for_tool_icons = 22; // reserved drawing size for tool icons CATview.space_for_other = 2; // reserved size opposite to the edges axis CATview.margin = {left: 0, top: 0, right: 0, bottom: 0}; @@ -222,11 +223,11 @@ const CATview = new function() { // query new data from the server and call draw_svg // this requires jQuery - this.server_update = function (url, callback){ + this.server_update = function (_url, _callback){ if(CATview.debug) console.log('CATview.server_update'); - $.ajax({type: 'get', url: url, dataType: 'json'}).done(function (data) { + $.ajax({type: 'get', url: _url, dataType: 'json'}).done(function (data) { if(CATview.debug) console.log(data); CATview.names = data.names; @@ -237,17 +238,19 @@ const CATview = new function() { } CATview.edges = data.edges; - CATview.remaining_edges = data.remaining_edges; - CATview.extra_segments = data.extra_segments; CATview.edge_names = data.edge_names; + // CATview.remaining_edges = data.remaining_edges; + CATview.extra_segments = data.extra_segments; + CATview.rect_linking_data = data.rect_linking_data; + CATview.rect_scaling = data.rect_scaling; }).done(function() { // todo check whether the data is valid CATview.scale = 1; // current zooming factor CATview.translate = 0; // current translation for zoomed-in excerpt CATview.draw_svg(); - if (callback) { - callback(); + if (_callback) { + _callback(); } }); }; @@ -305,7 +308,7 @@ const CATview = new function() { } } - CATview.set_scale_edges(0, CATview.edges.length + 1) + CATview.set_scale_edges(0, CATview.edges.length + 1); CATview.scale_edges_original = CATview.scale_edges.copy(); CATview.refresh_content(CATview.from, CATview.to); return true; @@ -342,7 +345,7 @@ const CATview = new function() { if(names_offset < names[i].getComputedTextLength()) names_offset = names[i].getComputedTextLength(); } - CATview.space_for_names_axis += names_offset; + CATview.space_for_names_axis = names_offset + CATview.extra_space_for_names_axis; //// than remove this temporary elements let element = document.getElementById('CATview_prerendered_names'); element.parentNode.removeChild(element); @@ -414,11 +417,16 @@ const CATview = new function() { if(CATview.debug) console.log('CATview.refresh_content(' + _from + ', ' + _to + ')'); + if(_from === undefined && CATview.from === null) + _from = 1; + if(_to === undefined && CATview.to === null) + _to = CATview.edges.length; + if(CATview.content){ - if (_from !== null) CATview.from = _from; - if (_from === 0) CATview.from = 1; - if (_to !== null) CATview.to = _to; - if (_to > CATview.edges.length) CATview.to = CATview.edges.length; + if (_from !== null && _from !== undefined) CATview.from = parseInt(_from); + if (CATview.from < 1) CATview.from = 1; + if (_to !== null &&_to !== undefined) CATview.to = parseInt(_to); + if (CATview.to > CATview.edges.length) CATview.to = CATview.edges.length; // refresh the edges-scale (with one bin offset) CATview.set_scale_edges(Math.max(CATview.from - 1, 0), Math.min(CATview.to + 1, CATview.edges.length + 1)); @@ -426,7 +434,7 @@ const CATview = new function() { CATview.draw_extra_segments(); CATview.draw_search_results(); if(CATview.enable_scroll_spy) - CATview.draw_scroll_spy(); + CATview.draw_scroll_spy(); //CATview.draw_remaining_edges(); } else -- GitLab