fixed a bug in getLoadedGIDs(..), now it will sort the results...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-01-16 04:52:11 +04:00
parent be0a5bc2d4
commit a76753eaa5
3 changed files with 22 additions and 10 deletions

View File

@ -277,6 +277,12 @@ function filterImagesDialog(){
updateStatus('Filter...').show()
cfg = {}
cfg['GID |'
+'Use gid or gid tail part to find an\n'
+'image.\n'
+'\n'
+'NOTE: use of at least 6 characters is\n'
+'recommended.'] = ''
cfg['sep0'] = '---'
cfg['Name'] = ''
cfg['Path |'
@ -345,7 +351,11 @@ function filterImagesDialog(){
var filter = {}
// build the filter...
for(var field in res){
if(/^Name/.test(field) && res[field].trim() != ''){
// this will search for gid or gid part at the end of a gid...
if(/^GID/.test(field) && res[field].trim() != ''){
filter['id'] = res[field] + '$'
} else if(/^Name/.test(field) && res[field].trim() != ''){
filter['name'] = res[field]
} else if(/^Path/.test(field) && res[field].trim() != ''){

View File

@ -536,9 +536,6 @@ function linSearch(target, lst, check, return_position, get){
// no hit...
return return_position ? -1 : null
}
Array.prototype.linSearch = function(target, cmp, get){
return linSearch(target, this, cmp, true, get)
}
*/
@ -575,11 +572,6 @@ function binSearch(target, lst, check, return_position, get){
// no result...
return return_position ? -1 : null
}
/* XXX do we actually need to patch Array???
Array.prototype.binSearch = function(target, cmp, get){
return binSearch(target, this, cmp, true, get)
}
*/
// This is a cheating fast sort...
@ -800,7 +792,9 @@ function getAllGids(data){
// Get all the currently loaded gids...
//
// NOTE: this will return an unsorted list of gids...
function getLoadedGIDs(gids, data){
// NOTE: this will sort the result unless either no_sort is true or gids
// is not given...
function getLoadedGIDs(gids, data, no_sort){
data = data == null ? DATA : data
var res = []
data.ribbons.forEach(function(r){
@ -811,6 +805,9 @@ function getLoadedGIDs(gids, data){
return res.indexOf(e) >= 0
})
}
if(!no_sort){
res = fastSortGIDsByOrder(res)
}
return res
}

View File

@ -236,6 +236,11 @@ function makeMarkUpdater(img_class, mark_class, test){
// NOTE: this supports only shifts by one position...
// XXX this is similar to insertGIDToPosition(..) do we need both?
// ...this one is a special case and insertGIDToPosition(..) is
// general, the later uses search to find the position, here we
// know the aproximate location, the question is if this speedup
// is worth the effort of maintaining a special case function...
function shiftGIDToOrderInList(gid, direction, list){
var gid_o = DATA.order.indexOf(gid)
var gid_m = list.indexOf(gid)