fixed a bug in alignDataToRibbon(...)

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-09-06 03:16:48 +04:00
parent b4d339304c
commit 6252ab5fda
3 changed files with 38 additions and 19 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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
}