mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 02:40:08 +00:00
added get attr to most generic search/cmp functions...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
ef6b5d6c76
commit
20a9f68c90
@ -99,6 +99,10 @@ Roadmap
|
|||||||
|
|
|
|
||||||
| $('[order='+$('.current.image').attr('order')+']').length
|
| $('[order='+$('.current.image').attr('order')+']').length
|
||||||
|
|
|
|
||||||
|
| happens when:
|
||||||
|
| ribbon length: ~42
|
||||||
|
| screen width: 4
|
||||||
|
| jumping to end from start of ribbon
|
||||||
[_] usable empty view -- w.o. data...
|
[_] usable empty view -- w.o. data...
|
||||||
[_] single image mode transition (alpha-blend/fade/none)
|
[_] single image mode transition (alpha-blend/fade/none)
|
||||||
[_] 0% Tablet UI
|
[_] 0% Tablet UI
|
||||||
@ -176,6 +180,7 @@ Roadmap
|
|||||||
| positioning is OK but ribbons are not fully visible...
|
| positioning is OK but ribbons are not fully visible...
|
||||||
[_] BUG: BASE_URL seems to gain a new trailing '/' on each save...
|
[_] BUG: BASE_URL seems to gain a new trailing '/' on each save...
|
||||||
| low priority as this does not affect anything...
|
| low priority as this does not affect anything...
|
||||||
|
[_] start/stop gif animations...
|
||||||
[X] BUG: shifting ribbon left sometimes results in wrong order...
|
[X] BUG: shifting ribbon left sometimes results in wrong order...
|
||||||
| i.e. an image with order 12 before image with order 11
|
| i.e. an image with order 12 before image with order 11
|
||||||
|
|
|
|
||||||
|
|||||||
31
ui/data.js
31
ui/data.js
@ -260,11 +260,12 @@ function imageOrderCmp(a, b, get, data){
|
|||||||
// - -1 if a is less than position i
|
// - -1 if a is less than position i
|
||||||
// - +1 if a is greater than position i
|
// - +1 if a is greater than position i
|
||||||
//
|
//
|
||||||
// NOTE: the signature is different from the traditional lcmp(a, b) so as
|
// NOTE: the signature is different from the traditional cmp(a, b) so as
|
||||||
// to enable more complex comparisons involving adjacent elements
|
// to enable more complex comparisons involving adjacent elements
|
||||||
// (see isBetween(...) for an example)
|
// (see isBetween(...) for an example)
|
||||||
function lcmp(a, i, lst){
|
function lcmp(a, i, lst, get){
|
||||||
var b = lst[i]
|
var b = get == null ? lst[i] : get(lst[i])
|
||||||
|
|
||||||
if(a == b){
|
if(a == b){
|
||||||
return 0
|
return 0
|
||||||
} else if(a < b){
|
} else if(a < b){
|
||||||
@ -282,9 +283,9 @@ function lcmp(a, i, lst){
|
|||||||
// - -1 if a is "below" position i
|
// - -1 if a is "below" position i
|
||||||
// - +1 if a is "above" position i
|
// - +1 if a is "above" position i
|
||||||
//
|
//
|
||||||
// NOTE: this is here mostly to make debuging easy...
|
// NOTE: this is here mostly to make debugging easy...
|
||||||
function isBetween(a, i, lst){
|
function isBetween(a, i, lst, get){
|
||||||
var b = lst[i]
|
var b = get == null ? lst[i] : get(lst[i])
|
||||||
|
|
||||||
// special case: tail...
|
// special case: tail...
|
||||||
if(i == lst.length-1 && a >= b){
|
if(i == lst.length-1 && a >= b){
|
||||||
@ -306,14 +307,15 @@ function isBetween(a, i, lst){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
// Basic liner search...
|
// Basic liner search...
|
||||||
//
|
//
|
||||||
// NOTE: this is here for testing reasons only...
|
// NOTE: this is here for testing reasons only...
|
||||||
function linSearch(target, lst, check, return_position){
|
function linSearch(target, lst, check, return_position, get){
|
||||||
check = check == null ? lcmp : check
|
check = check == null ? lcmp : check
|
||||||
|
|
||||||
for(var i=0; i < lst.length; i++){
|
for(var i=0; i < lst.length; i++){
|
||||||
if(check(target, i, lst) == 0){
|
if(check(target, i, lst, get) == 0){
|
||||||
return return_position ? i : lst[i]
|
return return_position ? i : lst[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,9 +323,10 @@ function linSearch(target, lst, check, return_position){
|
|||||||
// no hit...
|
// no hit...
|
||||||
return return_position ? -1 : null
|
return return_position ? -1 : null
|
||||||
}
|
}
|
||||||
Array.prototype.linSearch = function(target, cmp){
|
Array.prototype.linSearch = function(target, cmp, get){
|
||||||
return linSearch(target, this, cmp, true)
|
return linSearch(target, this, cmp, true, get)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Basic binary search implementation...
|
// Basic binary search implementation...
|
||||||
@ -331,7 +334,7 @@ Array.prototype.linSearch = function(target, cmp){
|
|||||||
// NOTE: this will return the object by default, to return position set
|
// NOTE: this will return the object by default, to return position set
|
||||||
// return_position to true.
|
// return_position to true.
|
||||||
// NOTE: by default this will use cmp as a predicate.
|
// NOTE: by default this will use cmp as a predicate.
|
||||||
function binSearch(target, lst, check, return_position){
|
function binSearch(target, lst, check, return_position, get){
|
||||||
check = check == null ? lcmp : check
|
check = check == null ? lcmp : check
|
||||||
var h = 0
|
var h = 0
|
||||||
var t = lst.length - 1
|
var t = lst.length - 1
|
||||||
@ -339,7 +342,7 @@ function binSearch(target, lst, check, return_position){
|
|||||||
|
|
||||||
while(h <= t){
|
while(h <= t){
|
||||||
m = Math.floor((h + t)/2)
|
m = Math.floor((h + t)/2)
|
||||||
res = check(target, m, lst)
|
res = check(target, m, lst, get)
|
||||||
|
|
||||||
// match...
|
// match...
|
||||||
if(res == 0){
|
if(res == 0){
|
||||||
@ -358,8 +361,8 @@ function binSearch(target, lst, check, return_position){
|
|||||||
// no result...
|
// no result...
|
||||||
return return_position ? -1 : null
|
return return_position ? -1 : null
|
||||||
}
|
}
|
||||||
Array.prototype.binSearch = function(target, cmp){
|
Array.prototype.binSearch = function(target, cmp, get){
|
||||||
return binSearch(target, this, cmp, true)
|
return binSearch(target, this, cmp, true, get)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user