From 6252ab5fda67b355a1ce6573fe8ac18965415857 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 6 Sep 2013 03:16:48 +0400 Subject: [PATCH] fixed a bug in alignDataToRibbon(...) Signed-off-by: Alex A. Naanou --- buildcache.py | 5 +++-- ui/base.js | 4 ++++ ui/data.js | 48 +++++++++++++++++++++++++++++++----------------- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/buildcache.py b/buildcache.py index 617b1829..fb4e205c 100755 --- a/buildcache.py +++ b/buildcache.py @@ -1,7 +1,7 @@ #======================================================================= __version__ = '''0.0.01''' -__sub_version__ = '''20130707233437''' +__sub_version__ = '''20130903200809''' __copyright__ = '''(c) Alex A. Naanou 2011''' @@ -672,7 +672,8 @@ def handle_commandline(): print print 'Time: %.1fm' % ((progress_state['done at'] - progress_state['started at'])/60) - return res +## # XXX this makes the script spit out res to stdout... +## return res diff --git a/ui/base.js b/ui/base.js index dad182fa..a9b9a1ef 100755 --- a/ui/base.js +++ b/ui/base.js @@ -635,6 +635,10 @@ function centerRibbon(ribbon, image, mode){ function centerRibbons(mode, no_skip_current){ return $('.ribbon') .each(function(){ +// // skip empty ribbons... +// if($(this).find('.image').length == 0){ +// return +// } if(no_skip_current == true && $(this).find('.current.image').length > 0){ return } diff --git a/ui/data.js b/ui/data.js index 70eb3bd9..b4fabe60 100755 --- a/ui/data.js +++ b/ui/data.js @@ -727,6 +727,26 @@ function dataFromImages(images){ } +// Clean out empty ribbons... +// +function dropEmptyRibbons(data){ + data = data == null ? DATA : data + + var ribbons = data.ribbons + + var i = 0 + while(i < ribbons.length){ + if(ribbons[i].length == 0){ + ribbons.splice(i, 1) + } else { + i++ + } + } + + return data +} + + // Merge two or more data objects // // Each data object can be: @@ -919,11 +939,17 @@ function alignDataToRibbon(ribbon, data){ //ribbon = ribbon == null ? getRibbonIndex() : ribbon data = data == null ? DATA : data - // get the ribbon above... - var r = data.ribbons[ribbon-1] - + // get the first and last elements of the ribbon-set above the base + // ribbon... + var r = [] + for(var i=0; i < ribbon; i++){ + r.push(data.ribbons[i][0]) + r.push(data.ribbons[i][data.ribbons[i].length-1]) + } + r.sort(function(a, b){return imageOrderCmp(a, b, null, data)}) var start = r[0] var end = r[r.length-1] + // NOTE: this can be null/undefined if we are looking at the last // element... end = data.order[data.order.indexOf(end)+1] @@ -937,13 +963,7 @@ function alignDataToRibbon(ribbon, data){ var res = mergeData.apply(null, sections) res.current = data.current - // clean out empty ribbons from head and tail... - while(res.ribbons[0].length == 0){ - res.ribbons.splice(0, 1) - } - while(res.ribbons[res.ribbons.length-1].length == 0){ - res.ribbons.pop() - } + dropEmptyRibbons(res) return res } @@ -991,13 +1011,7 @@ function shiftRibbonsBy(n, gid, data){ var res = mergeData.apply(null, sections) res.current = data.current - // clean out empty ribbons from head and tail... - while(res.ribbons[0].length == 0){ - res.ribbons.splice(0, 1) - } - while(res.ribbons[res.ribbons.length-1].length == 0){ - res.ribbons.pop() - } + dropEmptyRibbons(res) return res }